← Commit list

035660726

Sören Tempel
Sören Tempel
2020-06-09
SUCCESS Duration: 152s

Subject

deluser: check if specified home is a directory before removing it

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

loginutils/deluser.c+8 -2
@@ -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: