Behavior of usermod was improved regarding (re)moving the old homedir.

This commit is contained in:
nekral-guest
2010-08-27 17:57:42 +00:00
parent a6336f11f8
commit 3472bee15a
3 changed files with 20 additions and 12 deletions
@@ -1,3 +0,0 @@
-rw-r--r-- foo:foo `/home/foo2/toto'
drwxr-xr-x foo:foo `/home/foo2/.'
drwxr-xr-x root:root `/home/foo2/..'
@@ -0,0 +1 @@
usermod: The previous home directory (/dev/null) was not a directory. It is not removed and no home directories are created.
@@ -18,7 +18,24 @@ trap 'log_status "$0" "FAILURE"; restore_config' 0
change_config
echo -n "Change the user's home directory (usermod -m -d /home/foo2 foo)..."
usermod -m -d /home/foo2 foo
usermod -m -d /home/foo2 foo 2>tmp/usermod.err && exit 1 || {
status=$?
}
echo "OK"
echo -n "Check returned status ($status)..."
test "$status" = "12"
echo "OK"
echo "usermod reported:"
echo "======================================================================="
cat tmp/usermod.err
echo "======================================================================="
echo -n "Check that there were a failure message..."
diff -au data/usermod.err tmp/usermod.err
echo "error message OK."
rm -f tmp/usermod.err
echo "OK"
echo -n "Check the passwd file..."
@@ -37,15 +54,8 @@ echo -n "Make sure /dev/null was not removed..."
test -c /dev/null
echo "OK"
echo -n "Make sure the user's home directory was not removed..."
test -d /home/foo2
test ! -e /home/foo2
echo "OK"
echo -n "Check content of /home/foo2/..."
stat --printf "%A %U:%G %N\n" /home/foo2/* /home/foo2/.* 2>/dev/null | sort > tmp/home_ls-a
diff -rauN data/home_ls-a tmp/home_ls-a
echo "OK"
echo -n "Remove the new home directory..."
rm -rf /home/foo2
echo "done"
log_status "$0" "SUCCESS"
restore_config