summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2019-05-13 16:55:49 +0200
committerAndreas Schneider <asn@cryptomilk.org>2019-05-23 09:41:17 +0000
commit6086efb6808089c431e7307fa239924bfda1185b (patch)
tree2902ec5ed8f157155220d21c0baf8f456045f1fe
parent30622ed876cffff305a9b03686edb48de987704f (diff)
downloadsamba-6086efb6808089c431e7307fa239924bfda1185b.tar.gz
s3:smbspool: Add the 'lp' group to the users groups
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>
-rw-r--r--source3/client/smbspool_krb5_wrapper.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/client/smbspool_krb5_wrapper.c b/source3/client/smbspool_krb5_wrapper.c
index 5c4da33238b..e6684fc0d0c 100644
--- a/source3/client/smbspool_krb5_wrapper.c
+++ b/source3/client/smbspool_krb5_wrapper.c
@@ -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) {