1
0
Fork 0
forked from mirrors/openup

Remove support for firmwares -- it's pretty useless.

Rework usage and add -c (check/cron option).
Initial implementation of the vuxml parsing - still WIP but seems to work ok (just wear glasses if you want to read the corresponding function)... regex foo!
This commit is contained in:
Antoine Jacoutot 2013-08-27 13:01:01 +02:00
commit 9efbb1531a

66
openup
View file

@ -17,7 +17,8 @@
# Author: Antoine Jacoutot <antoine@mtier.org>
# TODO
# https://stable.mtier.org/vuxml/53.xml
# check_vuxml(): add support for binpatches
# check_vuxml(): compare with installed version to not output all vulns of a pkg
### user defined variables
OPENUP_URL="https://stable.mtier.org/openup"
@ -25,6 +26,7 @@ PKG_CERT_URL="https://stable.mtier.org/mtier.cert"
PKG_CERT_FPRINT="DE:29:0F:7F:B8:0E:36:5A:AF:A9:BF:E0:4E:08:C2:0F:2D:50:16:97"
PKG_PATH_MAIN="http://ftp.fr.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(arch -s)"
PKG_PATH_UPDATE="https://stable.mtier.org/updates/$(uname -r)/$(arch -s)"
PKG_VUXML="https://stable.mtier.org/vuxml/53.xml"
### end of user defined variables
########################################################################
@ -36,10 +38,13 @@ _OPENUP_MINREL=53
usage() {
echo
echo "usage: ${0##*/} [-SUn]" >&2
echo " -S do not check for package signatures"
echo " -U do not check for openup update"
echo " -n dry run mode, no modification is done"
echo "Usage: ${0##*/} [-SUn]" >&2
echo
echo "Options:"
echo " -S do not check for package signatures"
echo " -U do not check for openup update"
echo " -c check/cron mode, other options are ignored"
echo " -n dry-run mode, no modification is done"
exit 1
}
@ -169,34 +174,49 @@ update_pkg() {
eval ${_CMD}
}
update_fw() {
local _CMD
check_vuxml() {
local _OUTDATED
pr_bigarrow "Updating firmware(s)"
_CMD="fw_update ${fw_opt}"
pr_smallarrow "${_CMD}"
eval ${_CMD}
_OUTDATED=$(pkg_add -nuv -D nosig 2>/dev/null| grep Adding | \
sed -e 's,Adding ,,;s,(pretending),,;s,->.*,,' | \
sort -u | perl -ne '/^(.*)-(\d[^-]*)[-]?(\w*)(.*)$/ && print "$1\n"')
for p in ${_OUTDATED}
do
awk "/<name>${p}/,/<\/vuln>/" /tmp/53.xml | \
sed -n -e 's/.*<name>\(.*\)<\/name>.*/\1/p' \
-e 's/.*<range><lt>\(.*\)<\/lt><\/range>.*/\1/p' \
-e 's/.*<p>\(.*\)<\/p>.*/\1/p' | \
while read l
do
if [ "${l}" != "${p}" ]; then
echo -n "${l} "
else
echo "\n"
pr_bigarrow "${l} <"
fi
done
done | fmt | sed '/^$/d' | uniq -u
}
outdated_pkg() {
# XXX binpatches, firmwares
pkg_add -nuv | grep Adding | sed -e 's,Adding ,,;s,(pretending),,' | sort -u
}
while getopts 'SUn' arg; do
while getopts 'SUcn' arg; do
case ${arg} in
S) nosig=1; pkg_opt="${pkg_opt} -D nosig" ;;
U) noselfupdate=1 ;;
n) dryrun=" (dry run)"; pkg_opt="${pkg_opt} -n -D nosig"; fw_opt="-n" ;;
c) checkmode=1 ;;
n) dryrun=" (dry run)"; pkg_opt="${pkg_opt} -n -D nosig" ;;
*) usage ;;
esac
done
[ $# = $(($OPTIND-1)) ] || usage
[[ -z $noselfupdate ]] && update_self
[[ -z $nosig ]] && get_cert
update_binpatches
update_pkg
update_fw
if [ -z "${checkmode}" ]; then
[[ -z $noselfupdate ]] && update_self
[[ -z $nosig ]] && get_cert
update_binpatches
update_pkg
else
check_vuxml
fi
rm -f ${_TMPDIR}/openup-*