s3:client: Pass DEVICE_URI and AUTH_INFO_REQUIRED env to smbspool
authorAndreas Schneider <asn@samba.org>
Tue, 12 Mar 2019 08:40:58 +0000 (09:40 +0100)
committerKarolin Seeger <kseeger@samba.org>
Tue, 26 Mar 2019 07:49:17 +0000 (07:49 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13832

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Bryan Mason <bmason@redhat.com>
Signed-off-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit 43160184d254a57f87bb2adeba47f48d8539533a)

source3/client/smbspool_krb5_wrapper.c

index dee3b4c54bee7e5a8db2a61bcb2a3357a7176c1a..5c4da33238b44a3d3e08ec4ba23964d464e57b1f 100644 (file)
@@ -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,