]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
cgconfigparser: Allow SUID and SGID permissions in 'fperm' and 'dperm' options.
authorJan Safranek <jsafrane@redhat.com>
Wed, 30 Nov 2011 14:42:08 +0000 (15:42 +0100)
committerJan Safranek <jsafrane@redhat.com>
Tue, 6 Dec 2011 09:42:14 +0000 (10:42 +0100)
libcgroup should allow SUID, SGID or sticky bit to be set either in
cgconfig.conf file or in API calls. Especially the sticky bit can be useful for
cooperation with systemd.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
src/api.c

index 0c55f1ab3a276e84cdf792d89764df681b8c4524..e2d56ef3d2d7d553ac34ef36bbde809f4b9c788f 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -197,6 +197,7 @@ int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask)
                 * Use owner permissions as an umask for group and others
                 * permissions because we trust kernel to initialize owner
                 * permissions to something useful.
+                * Keep SUID and SGID bits.
                 */
                if (stat(path, &buf) == -1)
                        goto fail;
@@ -204,7 +205,7 @@ int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask)
                gmask = umask >> 3;
                omask = gmask >> 3;
 
-               mask = umask|gmask|omask;
+               mask = umask|gmask|omask|S_ISUID|S_ISGID|S_ISVTX;
        }
 
        if (chmod(path, mode & mask))