summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/deluser.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/loginutils/deluser.c b/loginutils/deluser.c
index 56bc7ea..8e7df73 100644
--- a/loginutils/deluser.c
+++ b/loginutils/deluser.c
@@ -99,8 +99,14 @@ int deluser_main(int argc, char **argv)
pfile = bb_path_passwd_file;
if (ENABLE_FEATURE_SHADOWPASSWDS)
sfile = bb_path_shadow_file;
- if (opt_delhome)
- remove_file(pw->pw_dir, FILEUTILS_RECUR);
+ if (opt_delhome) {
+ struct stat st;
+
+ /* Make sure home is an actual directory before
+ * removing it (e.g. users with /dev/null as home) */
+ if (stat(pw->pw_dir, &st) == 0 && S_ISDIR(st.st_mode))
+ remove_file(pw->pw_dir, FILEUTILS_RECUR);
+ }
} else {
struct group *gr;
do_delgroup: