mirror of
https://github.com/troglobit/finit.git
synced 2026-09-30 21:13:01 +07:00
tmpfiles: fix 'e' type to only adjust existing directories
According to tmpfiles.d(5), the 'e' type adjusts the mode and ownership of existing paths but should not create them. Previously, mksubsys() was used which could create directories. Now we explicitly check if the path is an existing directory before adjusting its permissions.
This commit is contained in:
+18
-2
@@ -577,8 +577,24 @@ static void tmpfiles(char *line)
|
||||
if (glob(path, GLOB_NOESCAPE, NULL, &gl))
|
||||
break;
|
||||
|
||||
for (size_t i = 0; i < gl.gl_pathc; i++)
|
||||
rc += mksubsys(gl.gl_pathv[i], mode ?: 0755, user, group);
|
||||
for (size_t i = 0; i < gl.gl_pathc; i++) {
|
||||
char *p = gl.gl_pathv[i];
|
||||
int uid, gid;
|
||||
|
||||
/* e only adjusts existing directories */
|
||||
if (!fisdir(p))
|
||||
continue;
|
||||
|
||||
uid = parse_uid(user);
|
||||
gid = parse_gid(group);
|
||||
if (gid < 0)
|
||||
gid = 0;
|
||||
|
||||
if (mode)
|
||||
chmod(p, mode);
|
||||
if (uid >= 0 && chown(p, uid, gid))
|
||||
warn("Failed chown(%s, %d, %d)", p, uid, gid);
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
case 'F':
|
||||
|
||||
Reference in New Issue
Block a user