Use "checkpath -W" instead of dir_writable()

This commit is contained in:
Christian Ruppert 2012-01-28 19:32:05 +01:00
parent 5a8344a3d1
commit fb4aa20d05
5 changed files with 7 additions and 12 deletions

View File

@ -20,7 +20,7 @@ cleanup_tmp_dir()
if ! [ -d "$dir" ]; then if ! [ -d "$dir" ]; then
mkdir -p "$dir" || return $? mkdir -p "$dir" || return $?
fi fi
dir_writable "$dir" || return 1 checkpath -W "$dir" || return 1
chmod a+rwt "$dir" 2> /dev/null chmod a+rwt "$dir" 2> /dev/null
cd "$dir" || return 1 cd "$dir" || return 1
if yesno $wipe_tmp; then if yesno $wipe_tmp; then
@ -117,7 +117,7 @@ start()
migrate_to_run /var/run /run migrate_to_run /var/run /run
fi fi
if dir_writable /var/run; then if checkpath -W /var/run; then
ebegin "Creating user login records" ebegin "Creating user login records"
local xtra= local xtra=
[ "$RC_UNAME" = NetBSD ] && xtra=x [ "$RC_UNAME" = NetBSD ] && xtra=x
@ -159,7 +159,7 @@ start()
cleanup_tmp_dir "$tmp" cleanup_tmp_dir "$tmp"
done done
if dir_writable /tmp; then if checkpath -W /tmp; then
# Make sure our X11 stuff have the correct permissions # Make sure our X11 stuff have the correct permissions
# Omit the chown as bootmisc is run before network is up # Omit the chown as bootmisc is run before network is up
# and users may be using lame LDAP auth #139411 # and users may be using lame LDAP auth #139411
@ -172,7 +172,7 @@ start()
fi fi
if yesno $log_dmesg; then if yesno $log_dmesg; then
if $logw || dir_writable /var/log; then if $logw || checkpath -W /var/log; then
# Create an 'after-boot' dmesg log # Create an 'after-boot' dmesg log
if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ ]; then if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ ]; then
dmesg > /var/log/dmesg dmesg > /var/log/dmesg

View File

@ -54,7 +54,7 @@ start()
eend $retval eend $retval
# Store the last font so we can use it ASAP on boot # Store the last font so we can use it ASAP on boot
if [ $retval -eq 0 ] && dir_writable "$RC_LIBEXECDIR"; then if [ $retval -eq 0 ] && checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console mkdir -p "$RC_LIBEXECDIR"/console
for font in /usr/share/consolefonts/"$consolefont".*; do for font in /usr/share/consolefonts/"$consolefont".*; do
: :

View File

@ -63,7 +63,7 @@ start()
fi fi
# Save the keymapping for use immediately at boot # Save the keymapping for use immediately at boot
if dir_writable "$RC_LIBEXECDIR"; then if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console mkdir -p "$RC_LIBEXECDIR"/console
dumpkeys >"$RC_LIBEXECDIR"/console/keymap dumpkeys >"$RC_LIBEXECDIR"/console/keymap
fi fi

View File

@ -35,7 +35,7 @@ start()
done done
# Save the encoding for use immediately at boot # Save the encoding for use immediately at boot
if dir_writable "$RC_LIBEXECDIR"; then if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console mkdir -p "$RC_LIBEXECDIR"/console
if yesno ${unicode:-${UNICODE}}; then if yesno ${unicode:-${UNICODE}}; then
echo "" > "$RC_LIBEXECDIR"/console/unicode echo "" > "$RC_LIBEXECDIR"/console/unicode

View File

@ -4,11 +4,6 @@
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name> # Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license. # Released under the 2-clause BSD license.
dir_writable()
{
mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$
}
sourcex() sourcex()
{ {
if [ "$1" = "-e" ]; then if [ "$1" = "-e" ]; then