From f37cbed4d3ee98f6ae3c5737da624ec9d803cd65 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 04 Apr 2019 03:18:29 -0400 Subject: opkg-key: New file https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob_plain;f=package/system/opkg/files/opkg-key;h=ae5e8a4591078764352ae766000f92e8230265fb;hb=beca028bd6bb71898052faadff680d8e76f61eb3 --- (limited to 'opkg-key') diff --git a/opkg-key b/opkg-key new file mode 100644 index 0000000..ae5e8a4 --- /dev/null +++ b/opkg-key @@ -0,0 +1,56 @@ +#!/bin/sh + +usage() { + cat < +Commands: + add : Add keyfile to opkg trusted keys + remove : Remove keyfile matching from opkg trusted keys + verify : Check list file against signature file + +EOF + exit 1 +} + +opkg_key_verify() { + local sigfile="$1" + local msgfile="$2" + + ( + zcat "$msgfile" 2>/dev/null || + cat "$msgfile" 2>/dev/null + ) | usign -V -P /etc/opkg/keys -q -x "$sigfile" -m - +} + +opkg_key_add() { + local key="$1" + [ -n "$key" ] || usage + [ -f "$key" ] || echo "Cannot open file $1" + local fingerprint="$(usign -F -p "$key")" + mkdir -p "/etc/opkg/keys" + cp "$key" "/etc/opkg/keys/$fingerprint" +} + +opkg_key_remove() { + local key="$1" + [ -n "$key" ] || usage + [ -f "$key" ] || echo "Cannot open file $1" + local fingerprint="$(usign -F -p "$key")" + rm -f "/etc/opkg/keys/$fingerprint" +} + +case "$1" in + add) + shift + opkg_key_add "$@" + ;; + remove) + shift + opkg_key_remove "$@" + ;; + verify) + shift + opkg_key_verify "$@" + ;; + *) usage ;; +esac -- cgit v0.9.1