diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-04-06 19:39:51 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-04-06 19:39:51 +0000 |
commit | beca028bd6bb71898052faadff680d8e76f61eb3 (patch) | |
tree | 14a05ceeedb3c6c18f4ff09eb0659b16ebb8e386 /package/system/opkg/files | |
parent | dde8214d167415015d42cc826ebb535f726dd90d (diff) | |
download | upstream-beca028bd6bb71898052faadff680d8e76f61eb3.tar.gz upstream-beca028bd6bb71898052faadff680d8e76f61eb3.tar.bz2 upstream-beca028bd6bb71898052faadff680d8e76f61eb3.zip |
build: add integration for managing opkg package feed keys
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 45286
Diffstat (limited to 'package/system/opkg/files')
-rwxr-xr-x | package/system/opkg/files/opkg-key | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/package/system/opkg/files/opkg-key b/package/system/opkg/files/opkg-key new file mode 100755 index 0000000000..ae5e8a4591 --- /dev/null +++ b/package/system/opkg/files/opkg-key @@ -0,0 +1,56 @@ +#!/bin/sh + +usage() { + cat <<EOF +Usage: $0 <command> <arguments...> +Commands: + add <file>: Add keyfile <file> to opkg trusted keys + remove <file>: Remove keyfile matching <file> from opkg trusted keys + verify <sigfile> <list>: Check list file <list> against signature file <sigfile> + +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 |