Skip to content

Commit 0534a1d

Browse files
committed
run_part: skip scripts with insecure ownership/permission
Skip scripts that are either - not owned be the executing user or root, - not owned by the executing group or root, - world-writable.
1 parent f094823 commit 0534a1d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/run_part.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,24 @@ int run_parts (const char *directory, const char *name, const char *action)
8181
return (1);
8282
}
8383

84-
if (S_ISREG (sb.st_mode)) {
85-
execute_result = run_part (s, name, action);
84+
if (!S_ISREG (sb.st_mode)) {
85+
free(s);
86+
free (namelist[n]);
87+
continue;
8688
}
8789

90+
if ((sb.st_uid != 0 && sb.st_uid != getuid()) ||
91+
(sb.st_gid != 0 && sb.st_gid != getgid()) ||
92+
(sb.st_mode & 0002)) {
93+
fprintf (shadow_logfd, "skipping %s due to insecure ownership/permission\n",
94+
namelist[n]->d_name);
95+
free(s);
96+
free (namelist[n]);
97+
continue;
98+
}
99+
100+
execute_result = run_part (s, name, action);
101+
88102
free (s);
89103

90104
if (execute_result!=0) {

0 commit comments

Comments
 (0)