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:
parent
6e63ce4179
commit
9efbb1531a
1 changed files with 44 additions and 24 deletions
54
openup
54
openup
|
|
@ -17,7 +17,8 @@
|
||||||
# Author: Antoine Jacoutot <antoine@mtier.org>
|
# Author: Antoine Jacoutot <antoine@mtier.org>
|
||||||
|
|
||||||
# TODO
|
# 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
|
### user defined variables
|
||||||
OPENUP_URL="https://stable.mtier.org/openup"
|
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_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_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_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
|
### end of user defined variables
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
@ -36,10 +38,13 @@ _OPENUP_MINREL=53
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo
|
echo
|
||||||
echo "usage: ${0##*/} [-SUn]" >&2
|
echo "Usage: ${0##*/} [-SUn]" >&2
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
echo " -S do not check for package signatures"
|
echo " -S do not check for package signatures"
|
||||||
echo " -U do not check for openup update"
|
echo " -U do not check for openup update"
|
||||||
echo " -n dry run mode, no modification is done"
|
echo " -c check/cron mode, other options are ignored"
|
||||||
|
echo " -n dry-run mode, no modification is done"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,34 +174,49 @@ update_pkg() {
|
||||||
eval ${_CMD}
|
eval ${_CMD}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_fw() {
|
check_vuxml() {
|
||||||
local _CMD
|
local _OUTDATED
|
||||||
|
|
||||||
pr_bigarrow "Updating firmware(s)"
|
_OUTDATED=$(pkg_add -nuv -D nosig 2>/dev/null| grep Adding | \
|
||||||
_CMD="fw_update ${fw_opt}"
|
sed -e 's,Adding ,,;s,(pretending),,;s,->.*,,' | \
|
||||||
pr_smallarrow "${_CMD}"
|
sort -u | perl -ne '/^(.*)-(\d[^-]*)[-]?(\w*)(.*)$/ && print "$1\n"')
|
||||||
eval ${_CMD}
|
|
||||||
|
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() {
|
while getopts 'SUcn' arg; do
|
||||||
# XXX binpatches, firmwares
|
|
||||||
pkg_add -nuv | grep Adding | sed -e 's,Adding ,,;s,(pretending),,' | sort -u
|
|
||||||
}
|
|
||||||
|
|
||||||
while getopts 'SUn' arg; do
|
|
||||||
case ${arg} in
|
case ${arg} in
|
||||||
S) nosig=1; pkg_opt="${pkg_opt} -D nosig" ;;
|
S) nosig=1; pkg_opt="${pkg_opt} -D nosig" ;;
|
||||||
U) noselfupdate=1 ;;
|
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 ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
[ $# = $(($OPTIND-1)) ] || usage
|
[ $# = $(($OPTIND-1)) ] || usage
|
||||||
|
|
||||||
|
if [ -z "${checkmode}" ]; then
|
||||||
[[ -z $noselfupdate ]] && update_self
|
[[ -z $noselfupdate ]] && update_self
|
||||||
[[ -z $nosig ]] && get_cert
|
[[ -z $nosig ]] && get_cert
|
||||||
update_binpatches
|
update_binpatches
|
||||||
update_pkg
|
update_pkg
|
||||||
update_fw
|
else
|
||||||
|
check_vuxml
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f ${_TMPDIR}/openup-*
|
rm -f ${_TMPDIR}/openup-*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue