summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2002-06-10 07:16:42 +0000
committerdougb <dougb@FreeBSD.org>2002-06-10 07:16:42 +0000
commit59fc4b6f17817691759178174ac0b7e7085a7028 (patch)
tree46247cfd9bd8d1074dbdc7009da80de99e2ae818 /usr.sbin
parent319e2fb2b8c0400c55e769fc8b9c53477a3bf4b1 (diff)
downloadFreeBSD-src-59fc4b6f17817691759178174ac0b7e7085a7028.zip
FreeBSD-src-59fc4b6f17817691759178174ac0b7e7085a7028.tar.gz
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.
Diffstat (limited to 'usr.sbin')
-rwxr-xr-xusr.sbin/mergemaster/mergemaster.sh54
1 files changed, 31 insertions, 23 deletions
diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh
index 9c89e0f..08dc425 100755
--- a/usr.sbin/mergemaster/mergemaster.sh
+++ b/usr.sbin/mergemaster/mergemaster.sh
@@ -559,36 +559,36 @@ find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null
# 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
-'')
- case "${NEW_UMASK}" in
- '')
- USER_UMASK=`umask`
- ;;
- *)
- USER_UMASK="${NEW_UMASK}"
- ;;
- esac
-
+if [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then
+ USER_UMASK=`umask`
case "${USER_UMASK}" in
0022|022) ;;
*)
echo ''
- echo " *** Your umask is currently set to ${USER_UMASK}. This script installs"
- echo ' all files with the same user, group, and modes that they'
- echo " are created with by ${SOURCEDIR}/Makefile."
+ echo " *** Your umask is currently set to ${USER_UMASK}. By default, this script"
+ echo " installs all files with the same user, group and modes that"
+ 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 ' If you would like different permissions for the files or'
- echo ' directories, you will have to set them after installation.'
+ echo " No world permissions can sometimes cause problems. A umask of"
+ 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 ''
- press_to_continue
+ echo -n "What umask should I use? [${USER_UMASK}] "
+ read NEW_UMASK
+
+ NEW_UMASK="${NEW_UMASK:-$USER_UMASK}"
;;
esac
echo ''
- ;;
-esac
+fi
+
+CONFIRMED_UMASK=${NEW_UMASK:-0022}
# Warn users who still have ${DESTDIR}/etc/sysconfig
#
@@ -622,7 +622,7 @@ if [ -e "${DESTDIR}/etc/sysconfig" ]; then
esac
fi
-# Use the mode information to install the files
+# Use the umask/mode information to install the files
# Create directories as needed
#
do_install_and_rm () {
@@ -630,6 +630,14 @@ do_install_and_rm () {
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 () {
local INSTALL_DIR
INSTALL_DIR=${1#.}
@@ -642,11 +650,11 @@ mm_install () {
esac
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}"
fi
- FILE_MODE=`stat -f "%OMp%OLp" "${1}"`
+ FILE_MODE=`find_mode "${1}"`
if [ ! -x "${1}" ]; then
case "${1#.}" in
OpenPOWER on IntegriCloud