From: Andreas Schneider Date: Wed, 22 Jun 2022 06:34:20 +0000 (+0200) Subject: lib:cmdline: Fix error handling of --use-krb5-ccache=CCACHE X-Git-Tag: tevent-0.13.0~344 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cc340f972afa8320c0e4c1a2b5f1e11483bb4eb;p=thirdparty%2Fsamba.git lib:cmdline: Fix error handling of --use-krb5-ccache=CCACHE Best reviewed with `git show -b` BUG: https://bugzilla.samba.org/show_bug.cgi?id=15104 Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c index 707c93cc70a..de2992d3c32 100644 --- a/lib/cmdline/cmdline.c +++ b/lib/cmdline/cmdline.c @@ -934,37 +934,43 @@ static void popt_common_credentials_callback(poptContext popt_ctx, } break; } - case OPT_USE_KERBEROS_CCACHE: - if (arg != NULL) { - const char *error_string = NULL; - int rc; + case OPT_USE_KERBEROS_CCACHE: { + const char *error_string = NULL; + int rc; - ok = cli_credentials_set_kerberos_state(creds, - CRED_USE_KERBEROS_REQUIRED, - CRED_SPECIFIED); - if (!ok) { - fprintf(stderr, - "Failed to set Kerberos state to %s!\n", arg); - exit(1); - } + if (arg == NULL) { + fprintf(stderr, + "Failed to parse --use-krb5-ccache=CCACHE: " + "Missing argument\n"); + exit(1); + } - rc = cli_credentials_set_ccache(creds, - lp_ctx, - arg, - CRED_SPECIFIED, - &error_string); - if (rc != 0) { - fprintf(stderr, - "Error reading krb5 credentials cache: '%s'" - " - %s\n", - arg, - error_string); - exit(1); - } + ok = cli_credentials_set_kerberos_state(creds, + CRED_USE_KERBEROS_REQUIRED, + CRED_SPECIFIED); + if (!ok) { + fprintf(stderr, + "Failed to set Kerberos state to %s!\n", arg); + exit(1); + } - skip_password_callback = true; + rc = cli_credentials_set_ccache(creds, + lp_ctx, + arg, + CRED_SPECIFIED, + &error_string); + if (rc != 0) { + fprintf(stderr, + "Error reading krb5 credentials cache: '%s'" + " - %s\n", + arg, + error_string); + exit(1); } + + skip_password_callback = true; break; + } case OPT_USE_WINBIND_CCACHE: { uint32_t gensec_features;