ecc2cf7
From d973b896cd9983f95efcccf900e26d398f406110 Mon Sep 17 00:00:00 2001
ecc2cf7
From: Harald Hoyer <harald@redhat.com>
ecc2cf7
Date: Wed, 6 Apr 2011 09:22:21 +0200
ecc2cf7
Subject: [PATCH] mkdir always with -m 0755
ecc2cf7
ecc2cf7
---
ecc2cf7
 modules.d/01fips/fips.sh                      |    2 +-
ecc2cf7
 modules.d/01fips/module-setup.sh              |    2 +-
ecc2cf7
 modules.d/10rpmversion/module-setup.sh        |    2 +-
ecc2cf7
 modules.d/45ifcfg/write-ifcfg.sh              |    6 +++---
ecc2cf7
 modules.d/50plymouth/plymouth-populate-initrd |    4 ++--
ecc2cf7
 modules.d/50plymouth/plymouth-pretrigger.sh   |    2 +-
ecc2cf7
 modules.d/90dmsquash-live/dmsquash-live-root  |   18 +++++++++---------
ecc2cf7
 modules.d/90lvm/lvm_scan.sh                   |    2 +-
ecc2cf7
 modules.d/95dasd_mod/parse-dasd-mod.sh        |    2 +-
ecc2cf7
 modules.d/95fcoe/module-setup.sh              |    2 +-
ecc2cf7
 modules.d/95nfs/module-setup.sh               |    6 +++---
ecc2cf7
 modules.d/95nfs/nfsroot-cleanup.sh            |    3 ++-
ecc2cf7
 modules.d/98syslog/module-setup.sh            |    2 +-
ecc2cf7
 modules.d/99base/dracut-lib.sh                |    4 ++--
ecc2cf7
 14 files changed, 29 insertions(+), 28 deletions(-)
ecc2cf7
ecc2cf7
diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh
ecc2cf7
index 857c355..960e589 100755
ecc2cf7
--- a/modules.d/01fips/fips.sh
ecc2cf7
+++ b/modules.d/01fips/fips.sh
ecc2cf7
@@ -33,7 +33,7 @@ do_fips()
ecc2cf7
 
ecc2cf7
     [ -e "$boot" ]
ecc2cf7
 
ecc2cf7
-    mkdir /boot
ecc2cf7
+    mkdir -m 0755 /boot
ecc2cf7
     info "Mounting $boot as /boot"
ecc2cf7
     mount -oro "$boot" /boot
ecc2cf7
 
ecc2cf7
diff --git a/modules.d/01fips/module-setup.sh b/modules.d/01fips/module-setup.sh
ecc2cf7
index cdcded6..23c550a 100755
ecc2cf7
--- a/modules.d/01fips/module-setup.sh
ecc2cf7
+++ b/modules.d/01fips/module-setup.sh
ecc2cf7
@@ -15,7 +15,7 @@ installkernel() {
ecc2cf7
     FIPSMODULES="$FIPSMODULES des deflate ecb eseqiv hmac seqiv sha256 sha512"
ecc2cf7
     FIPSMODULES="$FIPSMODULES cryptomgr crypto_null tcrypt" 
ecc2cf7
 
ecc2cf7
-    mkdir -p "${initdir}/etc/modprobe.d"
ecc2cf7
+    mkdir -m 0755 -p "${initdir}/etc/modprobe.d"
ecc2cf7
 
ecc2cf7
     for mod in $FIPSMODULES; do 
ecc2cf7
         if instmods $mod; then
ecc2cf7
diff --git a/modules.d/10rpmversion/module-setup.sh b/modules.d/10rpmversion/module-setup.sh
ecc2cf7
index 60a8d89..2b32e27 100755
ecc2cf7
--- a/modules.d/10rpmversion/module-setup.sh
ecc2cf7
+++ b/modules.d/10rpmversion/module-setup.sh
ecc2cf7
@@ -17,7 +17,7 @@ install() {
ecc2cf7
     else
ecc2cf7
         if rpm -qf $(type -P $0) &>/dev/null; then
ecc2cf7
             dracut_rpm_version=$(rpm -qf --qf '%{name}-%{version}-%{release}\n' $(type -P $0) | { ver="";while read line;do ver=$line;done;echo $ver;} )
ecc2cf7
-            mkdir -m 0755 -p $initdir/lib $initdir/lib/dracut
ecc2cf7
+            mkdir -m 0755 -p $initdir/lib/dracut
ecc2cf7
             echo $dracut_rpm_version > $initdir/lib/dracut/$dracut_rpm_version
ecc2cf7
         fi
ecc2cf7
     fi
ecc2cf7
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
ecc2cf7
index fe72dbe..fb88318 100755
ecc2cf7
--- a/modules.d/45ifcfg/write-ifcfg.sh
ecc2cf7
+++ b/modules.d/45ifcfg/write-ifcfg.sh
ecc2cf7
@@ -17,7 +17,7 @@ if [ -e /tmp/bridge.info ]; then
ecc2cf7
     . /tmp/bridge.info
ecc2cf7
 fi
ecc2cf7
 
ecc2cf7
-mkdir -p /tmp/ifcfg/
ecc2cf7
+mkdir -m 0755 -p /tmp/ifcfg/
ecc2cf7
 
ecc2cf7
 for netif in $IFACES ; do
ecc2cf7
     # bridge?
ecc2cf7
@@ -134,9 +134,9 @@ for netif in $IFACES ; do
ecc2cf7
 done
ecc2cf7
 
ecc2cf7
 # Pass network opts
ecc2cf7
-mkdir -p /run/initramfs
ecc2cf7
+mkdir -m 0755 -p /run/initramfs
ecc2cf7
 cp /tmp/net.* /run/initramfs/ >/dev/null 2>&1
ecc2cf7
-mkdir -p /run/initramfs/state/etc/sysconfig/network-scripts/
ecc2cf7
+mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts/
ecc2cf7
 cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/ >/dev/null 2>&1
ecc2cf7
 echo "files /etc/sysconfig/network-scripts" > /run/initramfs/rwtab
ecc2cf7
 cp -a /tmp/ifcfg/* /run/initramfs/state/etc/sysconfig/network-scripts/ >/dev/null 2>&1
ecc2cf7
diff --git a/modules.d/50plymouth/plymouth-populate-initrd b/modules.d/50plymouth/plymouth-populate-initrd
ecc2cf7
index 199cab0..28c225c 100755
ecc2cf7
--- a/modules.d/50plymouth/plymouth-populate-initrd
ecc2cf7
+++ b/modules.d/50plymouth/plymouth-populate-initrd
ecc2cf7
@@ -9,7 +9,7 @@ dracut_install /bin/plymouth \
ecc2cf7
     "${PLYMOUTH_LOGO_FILE}" \
ecc2cf7
     /etc/system-release 
ecc2cf7
 
ecc2cf7
-mkdir -p "${initdir}/usr/share/plymouth"
ecc2cf7
+mkdir -m 0755 -p "${initdir}/usr/share/plymouth"
ecc2cf7
 
ecc2cf7
 if [[ $hostonly ]]; then 
ecc2cf7
     dracut_install "${usrlibdir}/plymouth/text.so" \
ecc2cf7
@@ -34,7 +34,7 @@ else
ecc2cf7
     for x in /usr/share/plymouth/themes/{text,details}/* ; do
ecc2cf7
         [[ -f "$x" ]] || continue
ecc2cf7
         THEME_DIR=$(dirname "$x")
ecc2cf7
-        mkdir -p "${initdir}/$THEME_DIR"
ecc2cf7
+        mkdir -m 0755 -p "${initdir}/$THEME_DIR"
ecc2cf7
         dracut_install "$x"
ecc2cf7
     done
ecc2cf7
     for x in "${usrlibdir}"/plymouth/{text,details}.so ; do
ecc2cf7
diff --git a/modules.d/50plymouth/plymouth-pretrigger.sh b/modules.d/50plymouth/plymouth-pretrigger.sh
ecc2cf7
index 477975f..6f8628d 100755
ecc2cf7
--- a/modules.d/50plymouth/plymouth-pretrigger.sh
ecc2cf7
+++ b/modules.d/50plymouth/plymouth-pretrigger.sh
ecc2cf7
@@ -17,7 +17,7 @@ if getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
ecc2cf7
     [ -e /dev/fb ] || ln -s fb0 /dev/fb
ecc2cf7
 
ecc2cf7
     info "Starting plymouth daemon"
ecc2cf7
-    mkdir -m 0755 -p /run/plymouth
ecc2cf7
+    mkdir -m 0755 /run/plymouth
ecc2cf7
     [ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid
ecc2cf7
     [ -x /lib/udev/console_init ] && /lib/udev/console_init tty0
ecc2cf7
     /bin/plymouth --show-splash 2>&1 | vinfo
ecc2cf7
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root b/modules.d/90dmsquash-live/dmsquash-live-root
ecc2cf7
index c54a46d..928aff9 100755
ecc2cf7
--- a/modules.d/90dmsquash-live/dmsquash-live-root
ecc2cf7
+++ b/modules.d/90dmsquash-live/dmsquash-live-root
ecc2cf7
@@ -43,7 +43,7 @@ getarg ro && liverw=ro
ecc2cf7
 getarg rw && liverw=rw
ecc2cf7
 [ -z "$liverw" ] && liverw=ro
ecc2cf7
 # mount the backing of the live image first
ecc2cf7
-mkdir -p /run/initramfs/live
ecc2cf7
+mkdir -m 0755 -p /run/initramfs/live
ecc2cf7
 if [ -f $livedev ]; then
ecc2cf7
     # no mount needed - we've already got the LiveOS image in initramfs
ecc2cf7
     case $livedev in
ecc2cf7
@@ -84,7 +84,7 @@ do_live_overlay() {
ecc2cf7
     # need to know where to look for the overlay
ecc2cf7
     setup=""
ecc2cf7
     if [ -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
ecc2cf7
-        mkdir /overlayfs
ecc2cf7
+        mkdir -m 0755 /run/initramfs/overlayfs
ecc2cf7
         mount -n -t auto $devspec /overlayfs || :
ecc2cf7
         if [ -f /overlayfs$pathspec -a -w /overlayfs$pathspec ]; then
ecc2cf7
             losetup $OVERLAY_LOOPDEV /overlayfs$pathspec
ecc2cf7
@@ -93,7 +93,7 @@ do_live_overlay() {
ecc2cf7
             fi
ecc2cf7
             setup="yes"
ecc2cf7
         fi
ecc2cf7
-        umount -l /overlayfs || :
ecc2cf7
+        umount -l /run/initramfs/overlayfs || :
ecc2cf7
     fi
ecc2cf7
 
ecc2cf7
     if [ -z "$setup" ]; then
ecc2cf7
@@ -125,11 +125,11 @@ if [ -n "$OSMINSQFS" ]; then
ecc2cf7
     dd if=$OSMINSQFS of=/osmin.img 2> /dev/null
ecc2cf7
     OSMIN_SQUASHED_LOOPDEV=$( losetup -f )
ecc2cf7
     losetup -r $OSMIN_SQUASHED_LOOPDEV /osmin.img
ecc2cf7
-    mkdir -p /squashfs.osmin
ecc2cf7
-    mount -n -t squashfs -o ro $OSMIN_SQUASHED_LOOPDEV /squashfs.osmin
ecc2cf7
+    mkdir -m 0755 -p /run/initramfs/squashfs.osmin
ecc2cf7
+    mount -n -t squashfs -o ro $OSMIN_SQUASHED_LOOPDEV /run/initramfs/squashfs.osmin
ecc2cf7
     OSMIN_LOOPDEV=$( losetup -f )
ecc2cf7
-    losetup -r $OSMIN_LOOPDEV /squashfs.osmin/osmin
ecc2cf7
-    umount -l /squashfs.osmin
ecc2cf7
+    losetup -r $OSMIN_LOOPDEV /run/initramfs/squashfs.osmin/osmin
ecc2cf7
+    umount -l /run/initramfs/squashfs.osmin
ecc2cf7
 fi
ecc2cf7
 
ecc2cf7
 # we might have an embedded fs image to use as rootfs (uncompressed live)
ecc2cf7
@@ -164,8 +164,8 @@ if [ -e "$SQUASHED" ] ; then
ecc2cf7
 
ecc2cf7
     SQUASHED_LOOPDEV=$( losetup -f )
ecc2cf7
     losetup -r $SQUASHED_LOOPDEV $SQUASHED
ecc2cf7
-    mkdir -p /squashfs
ecc2cf7
-    mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /squashfs
ecc2cf7
+    mkdir -m 0755 -p /run/initramfs/squashfs
ecc2cf7
+    mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /run/initramfs/squashfs
ecc2cf7
 
ecc2cf7
     BASE_LOOPDEV=$( losetup -f )
ecc2cf7
     if [ -f /squashfs/LiveOS/ext3fs.img ]; then
ecc2cf7
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
ecc2cf7
index fab0017..3f2a923 100755
ecc2cf7
--- a/modules.d/90lvm/lvm_scan.sh
ecc2cf7
+++ b/modules.d/90lvm/lvm_scan.sh
ecc2cf7
@@ -11,7 +11,7 @@ LVS=$(getargs rd.lvm.lv rd_LVM_LV=)
ecc2cf7
 SNAPSHOT=$(getargs rd.lvm.snapshot rd_LVM_SNAPSHOT=)
ecc2cf7
 SNAPSIZE=$(getargs rd.lvm.snapsize rd_LVM_SNAPSIZE=)
ecc2cf7
 
ecc2cf7
-[ -d /etc/lvm ] || mkdir -p /etc/lvm
ecc2cf7
+[ -d /etc/lvm ] || mkdir -m 0755 -p /etc/lvm
ecc2cf7
 # build a list of devices to scan
ecc2cf7
 lvmdevs=$(
ecc2cf7
     for f in /tmp/.lvm_scan-*; do
ecc2cf7
diff --git a/modules.d/95dasd_mod/parse-dasd-mod.sh b/modules.d/95dasd_mod/parse-dasd-mod.sh
ecc2cf7
index 2bccab4..b550156 100755
ecc2cf7
--- a/modules.d/95dasd_mod/parse-dasd-mod.sh
ecc2cf7
+++ b/modules.d/95dasd_mod/parse-dasd-mod.sh
ecc2cf7
@@ -1,7 +1,7 @@
ecc2cf7
 #!/bin/sh
ecc2cf7
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
ecc2cf7
 # ex: ts=8 sw=4 sts=4 et filetype=sh
ecc2cf7
-[ -d /etc/modprobe.d ] || mkdir /etc/modprobe.d
ecc2cf7
+[ -d /etc/modprobe.d ] || mkdir -m 0755 -p /etc/modprobe.d
ecc2cf7
 
ecc2cf7
 dasd_arg=$(getarg rd.dasd_mod.dasd rd_DASD_MOD=)
ecc2cf7
 if [ -n "$dasd_arg" ]; then
ecc2cf7
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
ecc2cf7
index f07a9ae..2ebff09 100755
ecc2cf7
--- a/modules.d/95fcoe/module-setup.sh
ecc2cf7
+++ b/modules.d/95fcoe/module-setup.sh
ecc2cf7
@@ -26,7 +26,7 @@ install() {
ecc2cf7
     inst fipvlan
ecc2cf7
     inst lldpad
ecc2cf7
 
ecc2cf7
-    mkdir -p "$initdir/var/lib/lldpad"
ecc2cf7
+    mkdir -m 0755 -p "$initdir/var/lib/lldpad"
ecc2cf7
 
ecc2cf7
     inst "$moddir/fcoe-up" "/sbin/fcoe-up"
ecc2cf7
     inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh"
ecc2cf7
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
ecc2cf7
index 84673ab..ad6c257 100755
ecc2cf7
--- a/modules.d/95nfs/module-setup.sh
ecc2cf7
+++ b/modules.d/95nfs/module-setup.sh
ecc2cf7
@@ -49,9 +49,9 @@ install() {
ecc2cf7
     inst_hook cmdline 90 "$moddir/parse-nfsroot.sh"
ecc2cf7
     inst_hook pre-pivot 99 "$moddir/nfsroot-cleanup.sh"
ecc2cf7
     inst "$moddir/nfsroot" "/sbin/nfsroot"
ecc2cf7
-    mkdir -p "$initdir/var/lib/nfs/rpc_pipefs"
ecc2cf7
-    mkdir -p "$initdir/var/lib/rpcbind"
ecc2cf7
-    mkdir -p "$initdir/var/lib/nfs/statd/sm"
ecc2cf7
+    mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs"
ecc2cf7
+    mkdir -m 0755 -p "$initdir/var/lib/rpcbind"
ecc2cf7
+    mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm"
ecc2cf7
 
ecc2cf7
     # Rather than copy the passwd file in, just set a user for rpcbind
ecc2cf7
     # We'll save the state and restart the daemon from the root anyway
ecc2cf7
diff --git a/modules.d/95nfs/nfsroot-cleanup.sh b/modules.d/95nfs/nfsroot-cleanup.sh
ecc2cf7
index b9fa771..b2f178e 100755
ecc2cf7
--- a/modules.d/95nfs/nfsroot-cleanup.sh
ecc2cf7
+++ b/modules.d/95nfs/nfsroot-cleanup.sh
ecc2cf7
@@ -16,7 +16,8 @@ pid=$(pidof rpcbind)
ecc2cf7
 
ecc2cf7
 if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then 
ecc2cf7
     # try to create the destination directory
ecc2cf7
-    [ -d $NEWROOT/$rpcpipefspath ] || mkdir -p $NEWROOT/$rpcpipefspath 2>/dev/null
ecc2cf7
+    [ -d $NEWROOT/$rpcpipefspath ] || \
ecc2cf7
+        mkdir -m 0755 -p $NEWROOT/$rpcpipefspath 2>/dev/null
ecc2cf7
 
ecc2cf7
     if [ -d $NEWROOT/$rpcpipefspath ]; then
ecc2cf7
         mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath
ecc2cf7
diff --git a/modules.d/98syslog/module-setup.sh b/modules.d/98syslog/module-setup.sh
ecc2cf7
index 056e9d9..2fbef16 100755
ecc2cf7
--- a/modules.d/98syslog/module-setup.sh
ecc2cf7
+++ b/modules.d/98syslog/module-setup.sh
ecc2cf7
@@ -35,7 +35,7 @@ install() {
ecc2cf7
         inst_hook pre-pivot 99 "$moddir/syslog-cleanup.sh"
ecc2cf7
         inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start
ecc2cf7
         inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop
ecc2cf7
-        mkdir -p ${initdir}/etc/templates
ecc2cf7
+        mkdir -m 0755 -p ${initdir}/etc/templates
ecc2cf7
         inst_simple "${moddir}/rsyslog.conf" /etc/templates
ecc2cf7
     fi
ecc2cf7
 }
ecc2cf7
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
ecc2cf7
index 930138a..a5a3f59 100755
ecc2cf7
--- a/modules.d/99base/dracut-lib.sh
ecc2cf7
+++ b/modules.d/99base/dracut-lib.sh
ecc2cf7
@@ -453,10 +453,10 @@ mkuniqdir() {
ecc2cf7
     local dir="$1"; local prefix="$2"
ecc2cf7
     local retdir; local retdir_new
ecc2cf7
 
ecc2cf7
-    [ -d "${dir}" ] || mkdir -p "${dir}" || return 1
ecc2cf7
+    [ -d "${dir}" ] || mkdir -m 0755 -p "${dir}" || return 1
ecc2cf7
 
ecc2cf7
     retdir=$(funiq "${dir}" "${prefix}") || return 1
ecc2cf7
-    until mkdir "${retdir}" 2>/dev/null; do
ecc2cf7
+    until mkdir -m 0755 "${retdir}" 2>/dev/null; do
ecc2cf7
         retdir_new=$(funiq "${dir}" "${prefix}") || return 1
ecc2cf7
         [ "$retdir_new" = "$retdir" ] && return 1
ecc2cf7
         retdir="$retdir_new"