]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:cmdline: Fix error handling of --use-krb5-ccache=CCACHE
authorAndreas Schneider <asn@samba.org>
Wed, 22 Jun 2022 06:34:20 +0000 (08:34 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 22 Jun 2022 10:53:36 +0000 (10:53 +0000)
Best reviewed with `git show -b`

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15104

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/cmdline/cmdline.c

index 707c93cc70a788d2bacc599b91cd02a9f0c90df7..de2992d3c320b86817df7396b3ac7aad2af51734 100644 (file)
@@ -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;