]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbspool: Add the 'lp' group to the users groups
authorAndreas Schneider <asn@samba.org>
Mon, 13 May 2019 14:55:49 +0000 (16:55 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 23 May 2019 09:41:17 +0000 (09:41 +0000)
This is required to access files in /var/spool/cups which have been
temporarily created in there by CUPS.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13939

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/client/smbspool_krb5_wrapper.c

index 5c4da33238b44a3d3e08ec4ba23964d464e57b1f..e6684fc0d0c95c1e158c4fc7b39d79aaaf33e5b8 100644 (file)
@@ -82,6 +82,7 @@ int main(int argc, char *argv[])
 {
        char smbspool_cmd[PATH_MAX] = {0};
        struct passwd *pwd;
+       struct group *g = NULL;
        char gen_cc[PATH_MAX] = {0};
        struct stat sb;
        char *env = NULL;
@@ -89,6 +90,7 @@ int main(int argc, char *argv[])
        char device_uri[4096] = {0};
        uid_t uid = (uid_t)-1;
        gid_t gid = (gid_t)-1;
+       gid_t groups[1] = { (gid_t)-1 };
        unsigned long tmp;
        int cmp;
        int rc;
@@ -176,6 +178,26 @@ int main(int argc, char *argv[])
                return CUPS_BACKEND_FAILED;
        }
 
+       /*
+        * We need the primary group of the 'lp' user. This is needed to access
+        * temporary files in /var/spool/cups/.
+        */
+       g = getgrnam("lp");
+       if (g == NULL) {
+               CUPS_SMB_ERROR("Failed to find user 'lp' - %s",
+                              strerror(errno));
+               return CUPS_BACKEND_FAILED;
+       }
+
+       CUPS_SMB_DEBUG("Adding group 'lp' (%u)", g->gr_gid);
+       groups[0] = g->gr_gid;
+       rc = setgroups(sizeof(groups), groups);
+       if (rc != 0) {
+               CUPS_SMB_ERROR("Failed to set groups for 'lp' - %s",
+                              strerror(errno));
+               return CUPS_BACKEND_FAILED;
+       }
+
        CUPS_SMB_DEBUG("Switching to gid=%d", gid);
        rc = setgid(gid);
        if (rc != 0) {