From f0f56e7e84f44a6336dd9aef2d57bfbdb9c89347 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 12 Mar 2019 09:40:58 +0100 Subject: s3:client: Pass DEVICE_URI and AUTH_INFO_REQUIRED env to smbspool BUG: https://bugzilla.samba.org/show_bug.cgi?id=13832 Signed-off-by: Andreas Schneider Reviewed-by: Bryan Mason Signed-off-by: Guenther Deschner (cherry picked from commit 43160184d254a57f87bb2adeba47f48d8539533a) --- source3/client/smbspool_krb5_wrapper.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source3/client/smbspool_krb5_wrapper.c b/source3/client/smbspool_krb5_wrapper.c index dee3b4c54be..5c4da33238b 100644 --- a/source3/client/smbspool_krb5_wrapper.c +++ b/source3/client/smbspool_krb5_wrapper.c @@ -84,24 +84,36 @@ int main(int argc, char *argv[]) struct passwd *pwd; char gen_cc[PATH_MAX] = {0}; struct stat sb; - char *env; + char *env = NULL; + char auth_info_required[256] = {0}; + char device_uri[4096] = {0}; uid_t uid = (uid_t)-1; gid_t gid = (gid_t)-1; unsigned long tmp; int cmp; int rc; + env = getenv("DEVICE_URI"); + if (env != NULL && strlen(env) > 2) { + snprintf(device_uri, sizeof(device_uri), "%s", env); + } + /* Check if AuthInfoRequired is set to negotiate */ env = getenv("AUTH_INFO_REQUIRED"); /* If not set, then just call smbspool. */ - if (env == NULL) { + if (env == NULL || env[0] == 0) { CUPS_SMB_DEBUG("AUTH_INFO_REQUIRED is not set - " "execute smbspool"); goto smbspool; } else { CUPS_SMB_DEBUG("AUTH_INFO_REQUIRED=%s", env); + snprintf(auth_info_required, + sizeof(auth_info_required), + "%s", + env); + cmp = strcmp(env, "username,password"); if (cmp == 0) { CUPS_SMB_DEBUG("Authenticate using username/password - " @@ -223,12 +235,18 @@ create_env: #else { extern char **environ; - environ = calloc(1, sizeof(*environ)); + environ = calloc(3, sizeof(*environ)); } #endif CUPS_SMB_DEBUG("Setting KRB5CCNAME to '%s'", gen_cc); setenv("KRB5CCNAME", gen_cc, 1); + if (device_uri[0] != '\0') { + setenv("DEVICE_URI", device_uri, 1); + } + if (auth_info_required[0] != '\0') { + setenv("AUTH_INFO_REQUIRED", auth_info_required, 1); + } smbspool: snprintf(smbspool_cmd, -- cgit v1.2.1