Thu, 04 Oct 2012 20:30:05 +0200
Correct out of date build configuration, porting to Solaris 11 network
link infrastructure and new libpcap logic. This additionally allows for
device drivers in subdirectories of /dev. Correct packaged nmap
personalities and signatures to work out of the box. Finally, hack
arpd logic to properly close sockets and quit on TERM by repeating
signaling in the run command script. Sadly, all this fails to correct
the run time behaviour of honeyd which fails to bind to the IP layer.
michael@428 | 1 | #!@l_prefix@/lib/openpkg/bash |
michael@428 | 2 | ## |
michael@428 | 3 | ## uuid -- OpenPKG UUID Update Utility |
michael@428 | 4 | ## Copyright (c) 2000-2012 OpenPKG GmbH <http://openpkg.com/> |
michael@428 | 5 | ## |
michael@428 | 6 | ## This software is property of the OpenPKG GmbH, DE MUC HRB 160208. |
michael@428 | 7 | ## All rights reserved. Licenses which grant limited permission to use, |
michael@428 | 8 | ## copy, modify and distribute this software are available from the |
michael@428 | 9 | ## OpenPKG GmbH. |
michael@428 | 10 | ## |
michael@428 | 11 | ## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
michael@428 | 12 | ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
michael@428 | 13 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
michael@428 | 14 | ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
michael@428 | 15 | ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@428 | 16 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@428 | 17 | ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
michael@428 | 18 | ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
michael@428 | 19 | ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
michael@428 | 20 | ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
michael@428 | 21 | ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
michael@428 | 22 | ## SUCH DAMAGE. |
michael@428 | 23 | ## |
michael@428 | 24 | |
michael@428 | 25 | # configuration |
michael@428 | 26 | prefix="@l_prefix@" |
michael@428 | 27 | musr="@l_musr@" |
michael@428 | 28 | mgrp="@l_mgrp@" |
michael@428 | 29 | |
michael@428 | 30 | # minimum command line parsing |
michael@428 | 31 | opt_v=no |
michael@428 | 32 | while [ 1 ]; do |
michael@428 | 33 | case "$1" in |
michael@428 | 34 | -v | --verbose ) opt_v=yes; shift ;; |
michael@428 | 35 | * ) break ;; |
michael@428 | 36 | esac |
michael@428 | 37 | done |
michael@428 | 38 | |
michael@428 | 39 | # determine temporary directory |
michael@428 | 40 | tmpdir="${TMPDIR-/tmp}" |
michael@428 | 41 | |
michael@428 | 42 | # helper function for checking the signature |
michael@428 | 43 | valid_signature () { |
michael@428 | 44 | script="%{lua: print(rpm.signature(\"$1\", nil," |
michael@428 | 45 | script="$script \"$prefix/etc/openpkg/openpkg.com.pgp\"," |
michael@428 | 46 | script="$script \"7D121A8FC05DC18A4329E9EF67042EC961B7AE34\")) }" |
michael@428 | 47 | result=`$prefix/bin/openpkg rpm --eval "$script" 2>/dev/null || true` |
michael@428 | 48 | if [ ".$result" == .true ]; then |
michael@428 | 49 | return 0 |
michael@428 | 50 | else |
michael@428 | 51 | return 1 |
michael@428 | 52 | fi |
michael@428 | 53 | } |
michael@428 | 54 | |
michael@428 | 55 | # display usage help |
michael@428 | 56 | do_help () { |
michael@428 | 57 | echo "openpkg license help .......................... show usage help (this text)" |
michael@428 | 58 | echo "openpkg license install <id> <file>|<url>|- ... install a new license" |
michael@428 | 59 | echo "openpkg license update <id> <file>|<url>|- .... update an installed license" |
michael@428 | 60 | echo "openpkg license uninstall <id> ................ uninstall an installed license" |
michael@428 | 61 | echo "openpkg license activate <id> ................. activate an installed license" |
michael@428 | 62 | echo "openpkg license view <id> ..................... view an installed license" |
michael@428 | 63 | echo "openpkg license list .......................... list all installed licenses" |
michael@428 | 64 | echo "openpkg license active ........................ list the currently activated license" |
michael@428 | 65 | echo "openpkg license sanity ........................ sanity check installed license" |
michael@428 | 66 | } |
michael@428 | 67 | |
michael@428 | 68 | # install license |
michael@428 | 69 | do_install () { |
michael@428 | 70 | if [ $# -ne 2 ]; then |
michael@428 | 71 | echo "openpkg:license:USAGE: openpkg license install <id> <file>|-" 1>&2 |
michael@428 | 72 | exit 1 |
michael@428 | 73 | fi |
michael@428 | 74 | id="$1" |
michael@428 | 75 | src="$2" |
michael@428 | 76 | case "$src" in |
michael@428 | 77 | http:* | https:* | ftp:* ) |
michael@428 | 78 | tmp="$tmpdir/openpkg.license.txt" |
michael@428 | 79 | ( rm -f $tmp >/dev/null 2>&1 || true |
michael@428 | 80 | set -o noclobber |
michael@428 | 81 | $prefix/lib/openpkg/curl -s -q -f -L $src >$tmp |
michael@428 | 82 | ) || exit $? |
michael@428 | 83 | src="$tmp" |
michael@428 | 84 | ;; |
michael@428 | 85 | "-" ) |
michael@428 | 86 | src="$tmpdir/openpkg.license.txt" |
michael@428 | 87 | ( rm -f $src >/dev/null 2>&1 || true |
michael@428 | 88 | set -o noclobber |
michael@428 | 89 | cat >$src |
michael@428 | 90 | ) || exit $? |
michael@428 | 91 | ;; |
michael@428 | 92 | esac |
michael@428 | 93 | if [ -f $prefix/etc/openpkg/license.d/$id ]; then |
michael@428 | 94 | echo "openpkg:license:ERROR: license with id \"$id\" already exists -- uninstall first" 1>&2 |
michael@428 | 95 | exit 1 |
michael@428 | 96 | fi |
michael@428 | 97 | if ! valid_signature $src; then |
michael@428 | 98 | echo "openpkg:license:ERROR: invalid signature on license file" 1>&2 |
michael@428 | 99 | exit 1 |
michael@428 | 100 | fi |
michael@428 | 101 | if [ ! -w $prefix/etc/openpkg/license.d ]; then |
michael@428 | 102 | echo "openpkg:license:ERROR: unable to store signature -- permission problems?" 1>&2 |
michael@428 | 103 | exit 1 |
michael@428 | 104 | fi |
michael@428 | 105 | cat $src >$prefix/etc/openpkg/license.d/$id || exit $? |
michael@428 | 106 | chown $musr:$mgrp $prefix/etc/openpkg/license.d/$id >/dev/null 2>&1 || true |
michael@428 | 107 | } |
michael@428 | 108 | |
michael@428 | 109 | # update license |
michael@428 | 110 | do_update () { |
michael@428 | 111 | if [ $# -ne 2 ]; then |
michael@428 | 112 | echo "openpkg:license:USAGE: openpkg license update <id> <file>|-" 1>&2 |
michael@428 | 113 | exit 1 |
michael@428 | 114 | fi |
michael@428 | 115 | id="$1" |
michael@428 | 116 | src="$2" |
michael@428 | 117 | case "$src" in |
michael@428 | 118 | http:* | https:* | ftp:* ) |
michael@428 | 119 | tmp="$tmpdir/openpkg.license.txt" |
michael@428 | 120 | ( rm -f $tmp >/dev/null 2>&1 || true |
michael@428 | 121 | set -o noclobber |
michael@428 | 122 | $prefix/lib/openpkg/curl -s -q -f -L $src >$tmp |
michael@428 | 123 | ) || exit $? |
michael@428 | 124 | src="$tmp" |
michael@428 | 125 | ;; |
michael@428 | 126 | "-" ) |
michael@428 | 127 | src="$tmpdir/openpkg.license.txt" |
michael@428 | 128 | ( rm -f $src >/dev/null 2>&1 || true |
michael@428 | 129 | set -o noclobber |
michael@428 | 130 | cat >$src |
michael@428 | 131 | ) || exit $? |
michael@428 | 132 | ;; |
michael@428 | 133 | esac |
michael@428 | 134 | if [ ! -f $prefix/etc/openpkg/license.d/$id ]; then |
michael@428 | 135 | echo "openpkg:license:ERROR: license with id \"$id\" does not exist -- install first to update" 1>&2 |
michael@428 | 136 | exit 1 |
michael@428 | 137 | fi |
michael@428 | 138 | if ! valid_signature $src; then |
michael@428 | 139 | echo "openpkg:license:ERROR: invalid signature on license file" 1>&2 |
michael@428 | 140 | exit 1 |
michael@428 | 141 | fi |
michael@428 | 142 | if [ ! -w $prefix/etc/openpkg/license.d ]; then |
michael@428 | 143 | echo "openpkg:license:ERROR: unable to store signature -- permission problems?" 1>&2 |
michael@428 | 144 | exit 1 |
michael@428 | 145 | fi |
michael@428 | 146 | cat $src >$prefix/etc/openpkg/license.d/$id || exit $? |
michael@428 | 147 | chown $musr:$mgrp $prefix/etc/openpkg/license.d/$id >/dev/null 2>&1 || true |
michael@428 | 148 | } |
michael@428 | 149 | |
michael@428 | 150 | # uninstall license |
michael@428 | 151 | do_uninstall () { |
michael@428 | 152 | if [ $# -ne 1 ]; then |
michael@428 | 153 | echo "openpkg:license:USAGE: openpkg license uninstall <id>" 1>&2 |
michael@428 | 154 | exit 1 |
michael@428 | 155 | fi |
michael@428 | 156 | id="$1" |
michael@428 | 157 | if [ ! -f $prefix/etc/openpkg/license.d/$id ]; then |
michael@428 | 158 | echo "openpkg:license:ERROR: no license under id \"$id\" installed" 1>&2 |
michael@428 | 159 | exit 1 |
michael@428 | 160 | fi |
michael@428 | 161 | id_active="`cat $prefix/etc/openpkg/license`" |
michael@428 | 162 | if [ ".$id" = ".$id_active" ]; then |
michael@428 | 163 | echo "openpkg:license:ERROR: license under id \"$id\" still activated -- activate a different one first" 1>&2 |
michael@428 | 164 | exit 1 |
michael@428 | 165 | fi |
michael@428 | 166 | rm -f $prefix/etc/openpkg/license.d/$id |
michael@428 | 167 | if [ $? -ne 0 ]; then |
michael@428 | 168 | echo "openpkg:license:ERROR: failed to uninstall license" 1>&2 |
michael@428 | 169 | exit 1 |
michael@428 | 170 | fi |
michael@428 | 171 | } |
michael@428 | 172 | |
michael@428 | 173 | # activate license |
michael@428 | 174 | do_activate () { |
michael@428 | 175 | if [ $# -ne 1 ]; then |
michael@428 | 176 | echo "openpkg:license:USAGE: openpkg license activate <id>" 1>&2 |
michael@428 | 177 | exit 1 |
michael@428 | 178 | fi |
michael@428 | 179 | id="$1" |
michael@428 | 180 | if [ ! -f $prefix/etc/openpkg/license.d/$id ]; then |
michael@428 | 181 | echo "openpkg:license:ERROR: no license under id \"$id\" installed" 1>&2 |
michael@428 | 182 | exit 1 |
michael@428 | 183 | fi |
michael@428 | 184 | id_active="`cat $prefix/etc/openpkg/license`" |
michael@428 | 185 | if [ ".$id" = ".$id_active" ]; then |
michael@428 | 186 | echo "openpkg:license:ERROR: license id \"$id\" is already activated" 1>&2 |
michael@428 | 187 | exit 1 |
michael@428 | 188 | fi |
michael@428 | 189 | echo "$id" >$prefix/etc/openpkg/license |
michael@428 | 190 | if [ $? -ne 0 ]; then |
michael@428 | 191 | echo "openpkg:license:ERROR: failed to activate license under id \"$id\"" 1>&2 |
michael@428 | 192 | exit 1 |
michael@428 | 193 | fi |
michael@428 | 194 | } |
michael@428 | 195 | |
michael@428 | 196 | # view license |
michael@428 | 197 | do_view () { |
michael@428 | 198 | if [ $# -ne 1 ]; then |
michael@428 | 199 | echo "openpkg:license:USAGE: openpkg license view <id>" 1>&2 |
michael@428 | 200 | exit 1 |
michael@428 | 201 | fi |
michael@428 | 202 | id="$1" |
michael@428 | 203 | if [ ! -f $prefix/etc/openpkg/license.d/$id ]; then |
michael@428 | 204 | echo "openpkg:license:ERROR: no license under id \"$id\" installed" 1>&2 |
michael@428 | 205 | exit 1 |
michael@428 | 206 | fi |
michael@428 | 207 | viewer="" |
michael@428 | 208 | for name in less more cat; do |
michael@428 | 209 | for dir in `echo $PATH | sed -e 's;:; ;g'`; do |
michael@428 | 210 | if [ -x $dir/$name ]; then |
michael@428 | 211 | viewer="$dir/$name" |
michael@428 | 212 | break |
michael@428 | 213 | fi |
michael@428 | 214 | done |
michael@428 | 215 | if [ ".$viewer" != . ]; then |
michael@428 | 216 | break |
michael@428 | 217 | fi |
michael@428 | 218 | done |
michael@428 | 219 | eval $viewer $prefix/etc/openpkg/license.d/$id |
michael@428 | 220 | } |
michael@428 | 221 | |
michael@428 | 222 | # list license |
michael@428 | 223 | do_list () { |
michael@428 | 224 | if [ $# -ne 0 ]; then |
michael@428 | 225 | echo "openpkg:license:USAGE: openpkg license list" 1>&2 |
michael@428 | 226 | exit 1 |
michael@428 | 227 | fi |
michael@428 | 228 | id_active="`cat $prefix/etc/openpkg/license`" |
michael@428 | 229 | for file in `cd / && find $prefix/etc/openpkg/license.d -type f -print | sort`; do |
michael@428 | 230 | id=`echo $file | sed -e "s;^$prefix/etc/openpkg/license.d/;;"` |
michael@428 | 231 | status="-" |
michael@428 | 232 | if [ ".$id" = ".$id_active" ]; then |
michael@428 | 233 | status="+" |
michael@428 | 234 | fi |
michael@428 | 235 | echo . | awk '{ printf("%s %s\n", status, id); }' id="$id" status="$status" |
michael@428 | 236 | done |
michael@428 | 237 | } |
michael@428 | 238 | |
michael@428 | 239 | # list currently activate license |
michael@428 | 240 | do_active () { |
michael@428 | 241 | if [ $# -ne 0 ]; then |
michael@428 | 242 | echo "openpkg:license:USAGE: openpkg license active" 1>&2 |
michael@428 | 243 | exit 1 |
michael@428 | 244 | fi |
michael@428 | 245 | cat $prefix/etc/openpkg/license |
michael@428 | 246 | } |
michael@428 | 247 | |
michael@428 | 248 | # sanity-check license |
michael@428 | 249 | do_sanity () { |
michael@428 | 250 | if [ $# -ne 0 ]; then |
michael@428 | 251 | echo "openpkg:license:USAGE: openpkg license sanity" 1>&2 |
michael@428 | 252 | exit 1 |
michael@428 | 253 | fi |
michael@428 | 254 | id="`cat $prefix/etc/openpkg/license`" |
michael@428 | 255 | if [ ! -f $prefix/etc/openpkg/license.d/$id ]; then |
michael@428 | 256 | echo "openpkg:license:ERROR: active license with id \"$id\" does not exist" 1>&2 |
michael@428 | 257 | exit 1 |
michael@428 | 258 | fi |
michael@428 | 259 | if ! valid_signature $prefix/etc/openpkg/license.d/$id; then |
michael@428 | 260 | echo "openpkg:license:ERROR: invalid signature on active license" 1>&2 |
michael@428 | 261 | exit 1 |
michael@428 | 262 | fi |
michael@428 | 263 | } |
michael@428 | 264 | |
michael@428 | 265 | # Command Line Dispatching |
michael@428 | 266 | cmd="$1" |
michael@428 | 267 | shift |
michael@428 | 268 | case "$cmd" in |
michael@428 | 269 | help ) do_help ${1+"$@"} ;; |
michael@428 | 270 | install ) do_install ${1+"$@"} ;; |
michael@428 | 271 | update ) do_update ${1+"$@"} ;; |
michael@428 | 272 | uninstall ) do_uninstall ${1+"$@"} ;; |
michael@428 | 273 | activate ) do_activate ${1+"$@"} ;; |
michael@428 | 274 | view ) do_view ${1+"$@"} ;; |
michael@428 | 275 | list ) do_list ${1+"$@"} ;; |
michael@428 | 276 | active ) do_active ${1+"$@"} ;; |
michael@428 | 277 | sanity ) do_sanity ${1+"$@"} ;; |
michael@428 | 278 | "" ) echo "openpkg:license:ERROR: no command given (use \"help\" for usage)" 1>&2; exit 1 ;; |
michael@428 | 279 | * ) echo "openpkg:license:ERROR: invalid command \"$cmd\" (use \"help\" for usage)" 1>&2; exit 1 ;; |
michael@428 | 280 | esac |
michael@428 | 281 |