From 28bbb580dead3f4a523335f89f020ce522458571 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 28 Oct 2019 09:38:08 +0100 Subject: [PATCH 2/4] s3:smbspool_krb5_wrapper: Map AUTH_INFO_REQUIRED=none to anonymous Signed-off-by: Andreas Schneider --- selftest/target/Samba4.pm | 3 +++ source3/client/smbspool_krb5_wrapper.c | 18 ++++++++++++------ source3/script/tests/test_smbspool.sh | 10 +++------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 1310e2ff09f..23dafba1574 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -1845,6 +1845,9 @@ sub provision_ad_dc($$$$$$) copy = print1 [print3] copy = print1 +[print4] + copy = print1 + guest ok = yes [lp] copy = print1 "; diff --git a/source3/client/smbspool_krb5_wrapper.c b/source3/client/smbspool_krb5_wrapper.c index bff1df417e8..bd6319ca9c3 100644 --- a/source3/client/smbspool_krb5_wrapper.c +++ b/source3/client/smbspool_krb5_wrapper.c @@ -149,17 +149,19 @@ int main(int argc, char *argv[]) env = getenv("AUTH_INFO_REQUIRED"); /* If not set, then just call smbspool. */ - if (env == NULL || env[0] == 0) { + if (env == NULL || env == "none" || 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, "none"); + if (cmp == 0) { + CUPS_SMB_DEBUG("Authenticate using none (anonymous) - " + "execute smbspool"); + goto smbspool; + } cmp = strcmp(env, "username,password"); if (cmp == 0) { @@ -168,13 +170,17 @@ int main(int argc, char *argv[]) goto smbspool; } - /* if AUTH_INFO_REQUIRED=none */ cmp = strcmp(env, "negotiate"); if (cmp != 0) { CUPS_SMB_ERROR("Authentication unsupported"); fprintf(stderr, "ATTR: auth-info-required=negotiate\n"); return CUPS_BACKEND_AUTH_REQUIRED; } + + snprintf(auth_info_required, + sizeof(auth_info_required), + "%s", + env); } uid = getuid(); diff --git a/source3/script/tests/test_smbspool.sh b/source3/script/tests/test_smbspool.sh index 7ba03f01fc7..01d72101615 100755 --- a/source3/script/tests/test_smbspool.sh +++ b/source3/script/tests/test_smbspool.sh @@ -48,7 +48,7 @@ test_smbspool_noargs() test_smbspool_authinforequired_none() { - cmd='$samba_smbspool_krb5 smb://$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps 2>&1' + cmd='$samba_smbspool_krb5 smb://$SERVER_IP/print4 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps 2>&1' AUTH_INFO_REQUIRED="none" export AUTH_INFO_REQUIRED @@ -60,14 +60,10 @@ test_smbspool_authinforequired_none() if [ $ret != 0 ]; then echo "$out" echo "failed to execute $smbspool_krb5" - fi - - echo "$out" | grep 'ATTR: auth-info-required=negotiate' - ret=$? - if [ $ret != 0 ] ; then - echo "$out" return 1 fi + + return 0 } # -- 2.20.1