Go back to taking the user's umask into account. Thanks to Alfred for

hatching the idea of using dc, and Giorgos (keramida) for incubating it.

This also reverses most of the previous commit which took out or
modified the text about umask stuff.
This commit is contained in:
dougb 2002-06-10 07:16:42 +00:00
parent c724db6eda
commit fad7f319c9

View File

@ -559,36 +559,36 @@ find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null
# Get ready to start comparing files # Get ready to start comparing files
# Check umask if we are not doing an autorun # Check umask if not specified on the command line,
# and we are not doing an autorun
# #
case "${AUTO_RUN}" in if [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then
'') USER_UMASK=`umask`
case "${NEW_UMASK}" in
'')
USER_UMASK=`umask`
;;
*)
USER_UMASK="${NEW_UMASK}"
;;
esac
case "${USER_UMASK}" in case "${USER_UMASK}" in
0022|022) ;; 0022|022) ;;
*) *)
echo '' echo ''
echo " *** Your umask is currently set to ${USER_UMASK}. This script installs" echo " *** Your umask is currently set to ${USER_UMASK}. By default, this script"
echo ' all files with the same user, group, and modes that they' echo " installs all files with the same user, group and modes that"
echo " are created with by ${SOURCEDIR}/Makefile." echo " they are created with by ${SOURCEDIR}/Makefile, compared to"
echo " a umask of 022. This umask allows world read permission when"
echo " the file's default permissions have it."
echo '' echo ''
echo ' If you would like different permissions for the files or' echo " No world permissions can sometimes cause problems. A umask of"
echo ' directories, you will have to set them after installation.' echo " 022 will restore the default behavior, but is not mandatory."
echo " /etc/master.passwd is a special case. Its file permissions"
echo " will be 600 (rw-------) if installed."
echo '' echo ''
press_to_continue echo -n "What umask should I use? [${USER_UMASK}] "
read NEW_UMASK
NEW_UMASK="${NEW_UMASK:-$USER_UMASK}"
;; ;;
esac esac
echo '' echo ''
;; fi
esac
CONFIRMED_UMASK=${NEW_UMASK:-0022}
# Warn users who still have ${DESTDIR}/etc/sysconfig # Warn users who still have ${DESTDIR}/etc/sysconfig
# #
@ -622,7 +622,7 @@ if [ -e "${DESTDIR}/etc/sysconfig" ]; then
esac esac
fi fi
# Use the mode information to install the files # Use the umask/mode information to install the files
# Create directories as needed # Create directories as needed
# #
do_install_and_rm () { do_install_and_rm () {
@ -630,6 +630,14 @@ do_install_and_rm () {
rm -f "${2}" rm -f "${2}"
} }
# 4095 = "obase=10;ibase=8;07777" | bc
find_mode () {
local OCTAL
OCTAL=$(( ~$(echo "obase=10; ibase=8; ${CONFIRMED_UMASK}" | bc) & 4095 &
$(echo "obase=10; ibase=8; $(stat -f "%OMp%OLp" ${1})" | bc) ))
printf "%04o\n" ${OCTAL}
}
mm_install () { mm_install () {
local INSTALL_DIR local INSTALL_DIR
INSTALL_DIR=${1#.} INSTALL_DIR=${1#.}
@ -642,11 +650,11 @@ mm_install () {
esac esac
if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
DIR_MODE=`stat -f "%OMp%OLp" "${TEMPROOT}/${INSTALL_DIR}"` DIR_MODE=`find_mode "${TEMPROOT}/${INSTALL_DIR}"`
install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}" install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}"
fi fi
FILE_MODE=`stat -f "%OMp%OLp" "${1}"` FILE_MODE=`find_mode "${1}"`
if [ ! -x "${1}" ]; then if [ ! -x "${1}" ]; then
case "${1#.}" in case "${1#.}" in