From b02f5150474f35a62c8785150c9bbf713eea139c Mon Sep 17 00:00:00 2001 From: Steve Youngs Date: Wed, 19 Dec 2012 10:55:29 +1000 Subject: [PATCH 1/1] minor updates Signed-off-by: Steve Youngs --- etc/pkgusr/bash_profile | 18 +++++--- etc/pkgusr/handy_funcs | 4 +- etc/pkgusr/skel-package/.project | 12 +++--- etc/pkgusr/skel-package/build | 21 +++++----- usr/bin/header-symbol-search | 5 ++- usr/bin/lesspipe.sh | 14 +++---- usr/bin/library-symbol-search | 31 +++++++------- usr/bin/list_suspicious_files | 71 ++++++++++++++++++++------------ usr/sbin/install_package | 1 + 9 files changed, 102 insertions(+), 75 deletions(-) diff --git a/etc/pkgusr/bash_profile b/etc/pkgusr/bash_profile index 58d3c4d..b1c0040 100644 --- a/etc/pkgusr/bash_profile +++ b/etc/pkgusr/bash_profile @@ -4,10 +4,12 @@ umask 022 LC_ALL=POSIX ## PATH -# The wrappers directory must be the first entry in the PATH. Once -# you are no longer needing or using the tools dir you can remove it -# from the PATH if you want, but leaving it there won't hurt -PATH=/usr/lib/pkgusr:/usr/bin:/bin:/usr/X11R6/bin:/tools/bin +# The wrappers directory must be the first entry in the PATH. +# +# Once you are no longer needing or using the tools dir you can remove it +# from the PATH if you want, but leaving it there won't hurt. +#PATH=/usr/lib/pkgusr:/usr/bin:/bin:/usr/X11R6/bin:/opt/qt/bin:/tools/bin +PATH=/usr/lib/pkgusr:/usr/bin:/bin:/usr/X11R6/bin:/opt/qt/bin ## A couple things to make less(1) nicer. LESS=-MRgisw @@ -18,10 +20,14 @@ LESSOPEN='|lesspipe.sh %s' TZ='Australia/Brisbane' ## pkg-config -PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/X11R6/lib/pkgconfig +PKG_CONFIG_PATH=$(pkg-config --variable pc_path pkg-config):/usr/X11R6/lib/pkgconfig:/usr/X11R6/share/pkgconfig +PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/qt/lib/pkgconfig + +## QT +QTDIR=/opt/qt ### export everything -export LC_ALL PATH LESS LESSCHARSET LESSOPEN TZ PKG_CONFIG_DIR +export LC_ALL PATH LESS LESSCHARSET LESSOPEN TZ PKG_CONFIG_PATH QTDIR # Make prompt reflect that we are a package user. diff --git a/etc/pkgusr/handy_funcs b/etc/pkgusr/handy_funcs index 28d90a6..19922bb 100644 --- a/etc/pkgusr/handy_funcs +++ b/etc/pkgusr/handy_funcs @@ -156,7 +156,7 @@ xtar() tar) opts=xf ;; gzip) opts=zxf ;; bzip2) opts=jxf ;; - xz) opts=Jxf ;; + xz|XZ) opts=Jxf ;; *) # try lzma if lzmainfo ${fname} &>/dev/null; then @@ -188,7 +188,7 @@ vtar() tar) opts=tvvvf ;; gzip) opts=ztvvvf ;; bzip2) opts=jtvvvf ;; - xz) opts=Jtvvvf ;; + xz|XZ) opts=Jtvvvf ;; *) # lzma. Here because lzmainfo is too stupid if lzmainfo ${fname} &>/dev/null; then diff --git a/etc/pkgusr/skel-package/.project b/etc/pkgusr/skel-package/.project index 7e36f16..c4998d2 100644 --- a/etc/pkgusr/skel-package/.project +++ b/etc/pkgusr/skel-package/.project @@ -14,12 +14,12 @@ Install Notes: Use the build script. Configure options used... - ./configure --prefix=/usr \ - --infodir=/usr/share/info \ - --mandir=/usr/share/man \ - --sysconfdir=/etc \ - --libexecdir=/usr/lib \ - --localstatedir=/var + ./configure --prefix=/usr \ + --infodir=/usr/share/info \ + --mandir=/usr/share/man \ + --sysconfdir=/etc \ + --libexecdir=/usr/lib \ + --localstatedir=/var General Notes: diff --git a/etc/pkgusr/skel-package/build b/etc/pkgusr/skel-package/build index 5a53927..32dab93 100755 --- a/etc/pkgusr/skel-package/build +++ b/etc/pkgusr/skel-package/build @@ -38,8 +38,8 @@ ## Version info. ourname=${0##*/} -VERSION=1.0 -COPYRIGHT="Copyright (C) 2007 - 2010 Steve Youngs " +VERSION=1.2 +COPYRIGHT="Copyright (C) 2007 - 2011 Steve Youngs " version_str="${ourname}: ${VERSION}\n${COPYRIGHT}" show_version() @@ -91,15 +91,6 @@ install_commands() forall_direntries_from $(whoami) -name \*.la -exec chmod -v 644 {} \; } -update_commands() -{ : - sed -i s/"Last_Updated.*"/"Last_Updated: $(date +%c)"/g ${HOME}/.project - awk '/^CONTENTS:/ { print; exit; } {print}' ${HOME}/.project > ${HOME}/.projtmp - echo "--------" >> ${HOME}/.projtmp - list_package $(whoami) >> ${HOME}/.projtmp - mv ${HOME}/.projtmp ${HOME}/.project -} - #* # Set `arg' to command(s) that output just the version number of the # package. @@ -123,6 +114,14 @@ test_pipe() return 0 } +update_commands() +{ : + sed -i s/"Last_Updated.*"/"Last_Updated: $(date +%c)"/g ${HOME}/.project + awk '/^CONTENTS:/ { print; exit; } {print}' ${HOME}/.project > ${HOME}/.projtmp + echo "--------" >> ${HOME}/.projtmp + list_package $(whoami) >> ${HOME}/.projtmp + mv ${HOME}/.projtmp ${HOME}/.project +} run_configure() { diff --git a/usr/bin/header-symbol-search b/usr/bin/header-symbol-search index a8b5dc8..4856c71 100755 --- a/usr/bin/header-symbol-search +++ b/usr/bin/header-symbol-search @@ -63,7 +63,10 @@ fi # Header directories. # These are the directories we search. If you have other header directories # such as /usr/local/include, /opt/include, add them here. -header_dirs=(/usr/include /usr/X11/include) +header_dirs=(/usr/include /usr/X11R6/include) + +## bastard header directories... +# header_dirs=(/usr/include /usr/X11R6/include /opt/jdk/include /opt/qt/include) sym=${1} diff --git a/usr/bin/lesspipe.sh b/usr/bin/lesspipe.sh index 7850a48..7a5e076 100755 --- a/usr/bin/lesspipe.sh +++ b/usr/bin/lesspipe.sh @@ -55,13 +55,13 @@ lesspipe() { *.bz2) bzip2 -dc "$1" 2>/dev/null ;; *.lzma) lzma -dc "$1" 2>/dev/null ;; *.xz) xz -dc "$1" 2>/dev/null ;; -# *) FILE=`file -L "$1"` ; # Check to see if binary, if so -- view with 'strings' -# FILE1=`echo $FILE | cut -d ' ' -f 2` -# FILE2=`echo $FILE | cut -d ' ' -f 3` -# if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \ -# -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then -# strings "$1" -# fi ;; + *) FILE=`file -L "$1"` ; # Check to see if binary, if so -- view with 'strings' + FILE1=`echo $FILE | cut -d ' ' -f 2` + FILE2=`echo $FILE | cut -d ' ' -f 3` + if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \ + -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then + strings "$1" + fi ;; esac } diff --git a/usr/bin/library-symbol-search b/usr/bin/library-symbol-search index aa9123a..8cee912 100755 --- a/usr/bin/library-symbol-search +++ b/usr/bin/library-symbol-search @@ -46,8 +46,7 @@ # are searched for, but with -a option, all syms, both defined and # undefined are searched. # -# First, it tries with nm(1), and if that gets nowhere (like in the -# case of stripped libraries), fall back on objdump(1). +# Uses objdump(1). ## Code: ourname=${0##*/} @@ -71,32 +70,34 @@ fi # Library directories. # These are the directories we search. If you have other lib directories # such as /usr/local/lib, /opt/lib, add them here. -lib_dirs=(/usr/lib /usr/X11/lib /lib) +lib_dirs=(/usr/lib /usr/X11R6/lib /lib) + +# bastard library directories... +#lib_dirs=(/usr/lib /usr/X11R6/lib /lib /opt/qt/lib) if [ "$1" = "-a" ]; then - nm_opts="--demangle=gnu-v3 --debug-syms" + obj_opts="--demangle=gnu-v3 --reloc --syms --debugging" + want_all=1 shift else - nm_opts="--demangle=gnu-v3 --defined-only --dynamic" + obj_opts="--demangle=gnu-v3 --reloc --syms" + want_all=0 fi -obj_opts="--demangle=gnu-v3 --reloc --dynamic-reloc --syms --dynamic-syms" + # $1 should now be the symbol (or symbol regexp) to search for sym=${1} -all_libs=$(find -H -L ${lib_dirs[*]} -type f \( -name "lib*.so" -o -name "lib*.a" \) -print) +all_libs=$(find ${lib_dirs[*]} -name lost+found -prune -o \( -name lib\*.so\* -o -name lib\*.a \) -print) for lib in ${all_libs} ; do - unset good_file lib_syms - good_file="$(file ${lib}|grep \(\(shared object\)\|\(ar archive\)\) 2>/dev/null)" + unset good_file + good_file="$(file ${lib}|grep '\(shared object\|ar archive\)' 2>/dev/null)" if [ -n "${good_file}" ]; then - lib_syms=$(nm ${nm_opts} ${lib} 2>/dev/null) - if [ -n "${lib_syms}" ]; then - echo ${lib_syms}|grep -E ${sym} 1>/dev/null && echo ${lib} + if [ $want_all -eq 1 ]; then + objdump ${obj_opts} ${lib}|grep -q -E ${sym} && echo ${lib} else - objdump ${obj_opts} ${lib} 2>/dev/null | - grep -E ${sym} 1>/dev/null && - echo ${lib} + objdump ${obj_opts} ${lib}|grep -v UND|grep -q -E ${sym} && echo ${lib} fi fi done diff --git a/usr/bin/list_suspicious_files b/usr/bin/list_suspicious_files index 3697b79..380c5dd 100755 --- a/usr/bin/list_suspicious_files +++ b/usr/bin/list_suspicious_files @@ -3,43 +3,60 @@ # You may do everything with this code except misrepresent its origin. # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND! -#The following list should contain the mount points of all filesystems -#that are to be scanned as a space-separated list within parentheses. -#/ will usually be in this list and if you have /usr -#on a separate partition, it will also be in this list. Other non-special -#filesystems where suspicious files could be located should also be put in -#this list. -#Mount points whose filesystems are special, such as procfs or sysfs should -#not be in this list. - -## Bastard settings -# fs_to_scan=(/ /opt /usr /usr/local /var) +# The following list should contain the mount points of all filesystems +# that are to be scanned as a space-separated list within parentheses. +# / will usually be in this list and if you have /usr +# on a separate partition, it will also be in this list. Other non-special +# filesystems where suspicious files could be located should also be put in +# this list. +# Mount points whose filesystems are special, such as procfs or sysfs should +# not be in this list. fs_to_scan=(/) -#Files with a path prefix found in the following list are ignored. -#DO !!!!NOT!!! PUT /usr/src OR WHATEVER THE HOME DIRECTORY prefix is for your -#package users into this list!!! You DO want to scan those directories in -#order to spot e.g. world-writable tarballs and other abominations that -#may have crept in. -#Ideally, this list should be empty. - ## Bastard settings -# prune_prefixes=(/*/\{arch\}) #NO TRAILING SLASHES!!! +#fs_to_scan=(\ +# / \ +# /opt \ +# /usr \ +# /usr/X11R6 \ +# /usr/lib \ +# /usr/share \ +# /usr/src \ +# /var) + +# Files with a path prefix found in the following list are ignored. +# DO !!!!NOT!!! PUT /usr/src OR WHATEVER THE HOME DIRECTORY prefix is for your +# package users into this list!!! You DO want to scan those directories in +# order to spot e.g. world-writable tarballs and other abominations that +# may have crept in. +# Ideally, this list should be empty. + +prune_prefixes=(/root /*/lost+found) #NO TRAILING SLASHES!!! -prune_prefixes=() - -#If the following variable is set to "yes", then files that contain -#control characters or other non-printable characters (except for space) -#will be reported as suspicious. -#This test slows down the search considerably! +## Bastard settings +#prune_prefixes=(\ +# /root \ +# /{,*/{,*/}}lost+found \ +# /etc/polkit-1/localauthority \ +# /etc/sudoers.d \ +# /opt/pgsql/data \ +# /var/lib/{polkit-1,sasl,net-snmp,udisks} \ +# /var/log/syslog-ng \ +# /mnt \ +# /media) + +# If the following variable is set to "yes", then files that contain +# control characters or other non-printable characters (except for space) +# will be reported as suspicious. +# This test slows down the search considerably! enable_illchars=yes -#suppress ugly debug output from shell +# suppress ugly debug output from shell trap ':' SIGPIPE -#"-false" as 1st argument is used when called by list_suspicious_files_from +# "-false" as 1st argument is used when called by list_suspicious_files_from if [ $# -ge 1 -a "$1" != "-false" ]; then echo 1>&2 echo 1>&2 "USAGE: ${0##*/}" diff --git a/usr/sbin/install_package b/usr/sbin/install_package index 7b8505e..58b3776 100755 --- a/usr/sbin/install_package +++ b/usr/sbin/install_package @@ -27,6 +27,7 @@ if [ $UID -ne 0 ]; then echo Please run this script as root. exit 1 fi + add_package_user "${1}" $2 10000 20000 $3 10000 20000 || exit 1 rm -f /var/mail/$2 su $2 -- 2.25.1