# This file is part of the src2pkg program: # Copyright 2005-2009 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ### fix_pkg_perms fix_pkg_perms() { if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any pre-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/09.pre ]] && . "$HOME"/.src2pkg/extensions/09.pre fi if [[ "$FAILED" = "" ]] ; then if [[ "$CORRECT_PKG_PERMS" != "NO" ]] ; then echo -n $BLUE"Correcting package permissions - "$NORMAL # this is redundant, but won't hurt if [[ "$EUID" = "0" ]] ; then chown root:root "$PKG_DIR" else chown $OWNER:$GROUP "$PKG_DIR" fi cd "$PKG_DIR" ; ## Fix exceptions which are set to 1777 : drwxrwxrwt [[ -d "$PKG_DIR"/tmp ]] && chmod 1777 "$PKG_DIR"/tmp [[ -d "$PKG_DIR"/var/tmp ]] && chmod 1777 "$PKG_DIR"/var/tmp [[ -d "$PKG_DIR"/var/lock ]] && chmod 1777 "$PKG_DIR"/var/lock ## Fix exceptions which are set to 775 : drwxrwxr-x [[ -d "$PKG_DIR"/var/run ]] && chmod 775 "$PKG_DIR"/var/run # Fix common bin and sbin dirs for dir in $BIN_DIRS ; do if [[ -d "$PKG_DIR"/$dir ]] ; then if [[ "$EUID" = "0" ]] ; then chown root:root "$PKG_DIR"/$dir else chown $OWNER:$GROUP "$PKG_DIR"/$dir fi chmod -R 755 "$PKG_DIR"/$dir fi done for dir in $LIB_DIRS; do if [[ -d "$PKG_DIR"/$dir ]] ; then if [[ "$EUID" = "0" ]] ; then chown root:root "$PKG_DIR"/$dir chmod 755 $PKG_DIR/$dir find "$PKG_DIR"/$dir -type d -exec chown root:root {} \; find "$PKG_DIR"/$dir -type d -exec chmod 755 {} \; else chown $OWNER:$GROUP "$PKG_DIR"/$dir chmod 755 $PKG_DIR/$dir find "$PKG_DIR"/$dir -type d -exec chown $OWNER:$GROUP {} \; find "$PKG_DIR"/$dir -type d -exec chmod 755 {} \; fi fi done # make sure all ELF executables have the execute bit set find . | xargs -r file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r chmod 755 2> /dev/null # make sure all ELF shared objects have the execute bit set find . | xargs -r file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r chmod 755 2> /dev/null # make sure all ELF relocatable objects have the execute bit set find . | xargs -r file | grep "relocatable" | grep ELF | cut -f 1 -d : | xargs -r chmod 755 2> /dev/null # make sure all static libs do not have the execute bit set find . | xargs -r file | grep "current ar archive" | grep ELF | cut -f 1 -d : | xargs -r chmod 644 2> /dev/null # unset executable bit for libtool *.la files find . -name "lib*.la" | xargs -r chmod 644 2> /dev/null echo $GREEN"Done"$NORMAL fi fi if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any post-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/09.post ]] && . "$HOME"/.src2pkg/extensions/09.post fi } # end fix_source_perms