pull up r20532 from trunk
authorTom Yu <tlyu@mit.edu>
Mon, 21 Jul 2008 16:08:19 +0000 (16:08 +0000)
committerTom Yu <tlyu@mit.edu>
Mon, 21 Jul 2008 16:08:19 +0000 (16:08 +0000)
 r20532@cathode-dark-space:  tlyu | 2008-07-17 11:44:43 -0400
 ticket: 6030
 tags: pullup
 target_version: 1.6.4

 Apply patch from Mark Phalan to correctly use progname instead of
 argv[0].

ticket: 6030
status: resolved
version_fixed: 1.6.4

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@20549 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/dbutil/dump.c
src/kadmin/dbutil/kdb5_create.c
src/kadmin/dbutil/kdb5_destroy.c
src/kadmin/dbutil/kdb5_stash.c
src/kadmin/dbutil/kdb5_util.c
src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c
src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c
src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c
src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c
src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.h

index 5c627d30cf0c2786d8fde2cdadf7b58aa3d84f66..dc172f885f7a1355b031881935b45499b998418f 100644 (file)
@@ -1016,7 +1016,6 @@ dump_db(argc, argv)
 {
     FILE               *f;
     struct dump_args   arglist;
-    char               *programname;
     char               *ofile;
     krb5_error_code    kret, retval;
     dump_version       *dump;
@@ -1027,9 +1026,6 @@ dump_db(argc, argv)
     /*
      * Parse the arguments.
      */
-    programname = argv[0];
-    if (strrchr(programname, (int) '/'))
-       programname = strrchr(argv[0], (int) '/') + 1;
     ofile = (char *) NULL;
     dump = &r1_3_version;
     arglist.verbose = 0;
@@ -1081,7 +1077,7 @@ dump_db(argc, argv)
      * to be opened if we try a dump that uses it.
      */
     if (!dbactive) {
-       com_err(argv[0], 0, Err_no_database);
+       com_err(progname, 0, Err_no_database);
        exit_status++;
        return;
     }
@@ -1099,7 +1095,7 @@ dump_db(argc, argv)
                                                (char *) NULL, 0,
                                                &master_keyblock);
                    if (retval) {
-                           com_err(argv[0], retval,
+                           com_err(progname, retval,
                                    "while reading master key");
                            exit(1);
                    }
@@ -1107,7 +1103,7 @@ dump_db(argc, argv)
                                                       master_princ,
                                                       &master_keyblock);
                    if (retval) {
-                           com_err(argv[0], retval,
+                           com_err(progname, retval,
                                    "while verifying master key");
                            exit(1);
                    }
@@ -1124,7 +1120,7 @@ dump_db(argc, argv)
                                             TRUE, 
                                             new_mkey_file, 0,
                                             &new_master_keyblock))) { 
-                   com_err(argv[0], retval, "while reading new master key");
+                   com_err(progname, retval, "while reading new master key");
                    exit(1);
            }
     }
@@ -1150,7 +1146,7 @@ dump_db(argc, argv)
        unlink(ofile);
        if (!(f = fopen(ofile, "w"))) {
            fprintf(stderr, ofopen_error,
-                   programname, ofile, error_message(errno));
+                   progname, ofile, error_message(errno));
            exit_status++;
            return;
        }
@@ -1158,7 +1154,7 @@ dump_db(argc, argv)
                                   fileno(f),
                                   KRB5_LOCKMODE_EXCLUSIVE))) {
            fprintf(stderr, oflock_error,
-                   programname, ofile, error_message(kret));
+                   progname, ofile, error_message(kret));
            exit_status++;
        }
        else
@@ -1167,7 +1163,7 @@ dump_db(argc, argv)
        f = stdout;
     }
     if (f && !(kret)) {
-       arglist.programname = programname;
+       arglist.programname = progname;
        arglist.ofile = f;
        arglist.kcontext = util_context;
        fprintf(arglist.ofile, "%s", dump->header);
@@ -1179,13 +1175,13 @@ dump_db(argc, argv)
                                    dump->dump_princ,
                                    (krb5_pointer) &arglist))) { /* TBD: backwards and recursive not supported */
             fprintf(stderr, dumprec_err,
-                    programname, dump->name, error_message(kret));
+                    progname, dump->name, error_message(kret));
             exit_status++;
        }
        if (dump->dump_policy &&
            (kret = krb5_db_iter_policy( util_context, "*", dump->dump_policy,
                                         &arglist))) { 
-            fprintf(stderr, dumprec_err, programname, dump->name,
+            fprintf(stderr, dumprec_err, progname, dump->name,
                     error_message(kret));
             exit_status++;
        }
@@ -2126,7 +2122,6 @@ load_db(argc, argv)
     FILE               *f;
     extern char                *optarg;
     extern int         optind;
-    char               *programname;
     char               *dumpfile;
     char               *dbname;
     char               *dbname_tmp;
@@ -2140,9 +2135,6 @@ load_db(argc, argv)
     /*
      * Parse the arguments.
      */
-    programname = argv[0];
-    if (strrchr(programname, (int) '/'))
-       programname = strrchr(argv[0], (int) '/') + 1;
     dumpfile = (char *) NULL;
     dbname = global_params.dbname;
     load = NULL;
@@ -2180,7 +2172,7 @@ load_db(argc, argv)
 
     if (!(dbname_tmp = (char *) malloc(strlen(dbname)+
                                       strlen(dump_tmptrail)+1))) {
-       fprintf(stderr, no_name_mem_fmt, argv[0]);
+       fprintf(stderr, no_name_mem_fmt, progname);
        exit_status++;
        return;
     }
@@ -2191,7 +2183,7 @@ load_db(argc, argv)
      * Initialize the Kerberos context and error tables.
      */
     if ((kret = kadm5_init_krb5_context(&kcontext))) {
-       fprintf(stderr, ctx_err_fmt, programname);
+       fprintf(stderr, ctx_err_fmt, progname);
        free(dbname_tmp);
        exit_status++;
        return;
@@ -2199,7 +2191,7 @@ load_db(argc, argv)
 
     if( (kret = krb5_set_default_realm(kcontext, util_context->default_realm)) )
     {
-       fprintf(stderr, "%s: Unable to set the default realm\n", programname);
+       fprintf(stderr, "%s: Unable to set the default realm\n", progname);
        free(dbname_tmp);
        exit_status++;
        return;
@@ -2210,14 +2202,14 @@ load_db(argc, argv)
      */
     if (dumpfile) {
        if ((f = fopen(dumpfile, "r")) == NULL) {
-            fprintf(stderr, dfile_err_fmt, programname, dumpfile,
+            fprintf(stderr, dfile_err_fmt, progname, dumpfile,
                     error_message(errno)); 
             exit_status++;
             return;
        }
        if ((kret = krb5_lock_file(kcontext, fileno(f),
                                   KRB5_LOCKMODE_SHARED))) {
-            fprintf(stderr, "%s: Cannot lock %s: %s\n", programname,
+            fprintf(stderr, "%s: Cannot lock %s: %s\n", progname,
                     dumpfile, error_message(errno));
             exit_status++;
             return;
@@ -2233,7 +2225,7 @@ load_db(argc, argv)
     if (load) {
         /* only check what we know; some headers only contain a prefix */
         if (strncmp(buf, load->header, strlen(load->header)) != 0) {
-             fprintf(stderr, head_bad_fmt, programname, dumpfile);
+             fprintf(stderr, head_bad_fmt, progname, dumpfile);
              exit_status++;
              if (dumpfile) fclose(f);
              return;
@@ -2252,7 +2244,7 @@ load_db(argc, argv)
                          strlen(ov_version.header)) == 0)
              load = &ov_version;
         else {
-             fprintf(stderr, head_bad_fmt, programname, dumpfile);
+             fprintf(stderr, head_bad_fmt, progname, dumpfile);
              exit_status++;
              if (dumpfile) fclose(f);
              return;
@@ -2260,7 +2252,7 @@ load_db(argc, argv)
     }
     if (load->updateonly && !update) {
         fprintf(stderr, "%s: dump version %s can only be loaded with the "
-                "-update flag\n", programname, load->name);
+                "-update flag\n", progname, load->name);
         exit_status++;
         return;
     }
@@ -2277,7 +2269,7 @@ load_db(argc, argv)
 
         if ((kret = kadm5_get_config_params(kcontext, 1,
                                             &newparams, &newparams))) {
-             com_err(argv[0], kret,
+             com_err(progname, kret,
                      "while retreiving new configuration parameters");
              exit_status++;
              return;
@@ -2301,11 +2293,11 @@ load_db(argc, argv)
             */
 
            if (emsg != NULL) {
-               fprintf(stderr, "%s: %s\n", programname, emsg);
+               fprintf(stderr, "%s: %s\n", progname, emsg);
                krb5_free_error_message (kcontext, emsg);
            } else {
                fprintf(stderr, dbcreaterr_fmt,
-                       programname, dbname, error_message(kret));
+                       progname, dbname, error_message(kret));
            }
            exit_status++;
            kadm5_free_config_params(kcontext, &newparams);
@@ -2326,11 +2318,11 @@ load_db(argc, argv)
                 */
 
                if (emsg != NULL) {
-                   fprintf(stderr, "%s: %s\n", programname, emsg);
+                   fprintf(stderr, "%s: %s\n", progname, emsg);
                    krb5_free_error_message (kcontext, emsg);
                } else {
                    fprintf(stderr, dbinit_err_fmt,
-                           programname, error_message(kret));
+                           progname, error_message(kret));
                }
                exit_status++;
                goto error;
@@ -2349,7 +2341,7 @@ load_db(argc, argv)
         */
        if (kret != KRB5_PLUGIN_OP_NOTSUPP) {
            fprintf(stderr, "%s: %s while permanently locking database\n",
-                   programname, error_message(kret));
+                   progname, error_message(kret));
            exit_status++;
            goto error;
        }
@@ -2357,10 +2349,10 @@ load_db(argc, argv)
     else
        db_locked = 1;
     
-    if (restore_dump(programname, kcontext, (dumpfile) ? dumpfile : stdin_name,
+    if (restore_dump(progname, kcontext, (dumpfile) ? dumpfile : stdin_name,
                     f, verbose, load)) {
         fprintf(stderr, restfail_fmt,
-                programname, load->name);
+                progname, load->name);
         exit_status++;
     }
 
@@ -2373,14 +2365,14 @@ load_db(argc, argv)
     if (db_locked && (kret = krb5_db_unlock(kcontext))) {
         /* change this error? */
         fprintf(stderr, dbunlockerr_fmt,
-                programname, dbname, error_message(kret));
+                progname, dbname, error_message(kret));
         exit_status++;
     }
 
 #if 0
     if ((kret = krb5_db_fini(kcontext))) {
         fprintf(stderr, close_err_fmt,
-                programname, error_message(kret));
+                progname, error_message(kret));
         exit_status++;
     }
 #endif
@@ -2395,7 +2387,7 @@ load_db(argc, argv)
         */
        if (kret != 0 && kret != KRB5_PLUGIN_OP_NOTSUPP) {
            fprintf(stderr, "%s: cannot make newly loaded database live (%s)\n",
-                   programname, error_message(kret));
+                   progname, error_message(kret));
            exit_status++;
        }
     }
@@ -2416,7 +2408,7 @@ error:
               */
              if (kret != 0 && kret != KRB5_PLUGIN_OP_NOTSUPP) {
                   fprintf(stderr, dbdelerr_fmt,
-                          programname, dbname, error_message(kret));
+                          progname, dbname, error_message(kret));
                   exit_status++;
              }
         }
index da192256ea612e5eb62bd2b93ab5787dada6c175..95d2271d425ec28bd2aa2fcc512ff21fbad232fb 100644 (file)
@@ -162,9 +162,6 @@ void kdb5_create(argc, argv)
     int do_stash = 0;
     krb5_data pwd, seed;
           
-    if (strrchr(argv[0], '/'))
-       argv[0] = strrchr(argv[0], '/')+1;
-
     while ((optchar = getopt(argc, argv, "s")) != -1) {
        switch(optchar) {
        case 's':
@@ -193,7 +190,7 @@ void kdb5_create(argc, argv)
     printf ("Loading random data\n");
     retval = krb5_c_random_os_entropy (util_context, 1, NULL);
     if (retval) {
-      com_err (argv[0], retval, "Loading random data");
+      com_err (progname, retval, "Loading random data");
       exit_status++; return;
     }
     
@@ -203,7 +200,7 @@ void kdb5_create(argc, argv)
                                          global_params.mkey_name,
                                          global_params.realm,  
                                          &mkey_fullname, &master_princ))) {
-       com_err(argv[0], retval, "while setting up master key name");
+       com_err(progname, retval, "while setting up master key name");
        exit_status++; return;
     }
 
@@ -229,7 +226,7 @@ master key name '%s'\n",
        retval = krb5_read_password(util_context, KRB5_KDC_MKEY_1, KRB5_KDC_MKEY_2,
                                    pw_str, &pw_size);
        if (retval) {
-           com_err(argv[0], retval, "while reading master key from keyboard");
+           com_err(progname, retval, "while reading master key from keyboard");
            exit_status++; return;
        }
        mkey_password = pw_str;
@@ -239,14 +236,14 @@ master key name '%s'\n",
     pwd.length = strlen(mkey_password);
     retval = krb5_principal2salt(util_context, master_princ, &master_salt);
     if (retval) {
-       com_err(argv[0], retval, "while calculating master key salt");
+       com_err(progname, retval, "while calculating master key salt");
        exit_status++; return;
     }
 
     retval = krb5_c_string_to_key(util_context, master_keyblock.enctype, 
                                  &pwd, &master_salt, &master_keyblock);
     if (retval) {
-       com_err(argv[0], retval, "while transforming master key from password");
+       com_err(progname, retval, "while transforming master key from password");
        exit_status++; return;
     }
 
@@ -256,28 +253,28 @@ master key name '%s'\n",
     seed.data = master_keyblock.contents;
 
     if ((retval = krb5_c_random_seed(util_context, &seed))) {
-       com_err(argv[0], retval, "while initializing random key generator");
+       com_err(progname, retval, "while initializing random key generator");
        exit_status++; return;
     }
     if ((retval = krb5_db_create(util_context,
                                 db5util_db_args))) {
-       com_err(argv[0], retval, "while creating database '%s'",
+       com_err(progname, retval, "while creating database '%s'",
                global_params.dbname);
        exit_status++; return;
     }
 /*     if ((retval = krb5_db_fini(util_context))) { */
-/*         com_err(argv[0], retval, "while closing current database"); */
+/*         com_err(progname, retval, "while closing current database"); */
 /*         exit_status++; return; */
 /*     } */
 /*     if ((retval = krb5_db_open(util_context, db5util_db_args, KRB5_KDB_OPEN_RW))) { */
-/*     com_err(argv[0], retval, "while initializing the database '%s'", */
+/*     com_err(progname, retval, "while initializing the database '%s'", */
 /*             global_params.dbname); */
 /*     exit_status++; return; */
 /*     } */
     if ((retval = add_principal(util_context, master_princ, MASTER_KEY, &rblock)) ||
        (retval = add_principal(util_context, &tgt_princ, TGT_KEY, &rblock))) {
        (void) krb5_db_fini(util_context);
-       com_err(argv[0], retval, "while adding entries to the database");
+       com_err(progname, retval, "while adding entries to the database");
        exit_status++; return;
     }
     /*
@@ -291,7 +288,7 @@ master key name '%s'\n",
                                      &master_keyblock,
                                      mkey_password);
     if (retval) {
-       com_err(argv[0], errno, "while storing key");
+       com_err(progname, errno, "while storing key");
        printf("Warning: couldn't stash master key.\n");
     }
     /* clean up */
index 22b75eef68dd1a6a87c00462da0be86ef4398e23..02c0c3b9a650fdac2c8afff4ff31aab5eefb5408 100644 (file)
@@ -60,19 +60,16 @@ kdb5_destroy(argc, argv)
     retval1 = kadm5_init_krb5_context(&context);
     if( retval1 )
     {
-       com_err(argv[0], retval1, "while initializing krb5_context");
+       com_err(progname, retval1, "while initializing krb5_context");
        exit(1);
     }
 
     if ((retval1 = krb5_set_default_realm(context,
                                          util_context->default_realm))) {
-       com_err(argv[0], retval1, "while setting default realm name");
+       com_err(progname, retval1, "while setting default realm name");
        exit(1);
     }
     
-    if (strrchr(argv[0], '/'))
-       argv[0] = strrchr(argv[0], '/')+1;
-
     dbname = global_params.dbname;
 
     optind = 1;
@@ -102,7 +99,7 @@ kdb5_destroy(argc, argv)
 
     retval1 = krb5_db_destroy(context, db5util_db_args);
     if (retval1) {
-       com_err(argv[0], retval1, "deleting database '%s'",dbname);
+       com_err(progname, retval1, "deleting database '%s'",dbname);
        exit_status++; return;
     }
 
index 7e8fd3e8b04285a27fb6d08e023a8f8eb08300ed..a34aa132a21bcce1ccba76958b25187b606534d6 100644 (file)
@@ -82,19 +82,16 @@ kdb5_stash(argc, argv)
     char *keyfile = 0;
     krb5_context context;
 
-    if (strrchr(argv[0], '/'))
-       argv[0] = strrchr(argv[0], '/')+1;
-
     retval = kadm5_init_krb5_context(&context);
     if( retval )
     {
-       com_err(argv[0], retval, "while initializing krb5_context");
+       com_err(progname, retval, "while initializing krb5_context");
        exit(1);
     }
 
     if ((retval = krb5_set_default_realm(context,
                                          util_context->default_realm))) {
-       com_err(argv[0], retval, "while setting default realm name");
+       com_err(progname, retval, "while setting default realm name");
        exit(1);
     }
 
@@ -119,10 +116,10 @@ kdb5_stash(argc, argv)
     if (!krb5_c_valid_enctype(master_keyblock.enctype)) {
        char tmp[32];
        if (krb5_enctype_to_string(master_keyblock.enctype, tmp, sizeof(tmp)))
-           com_err(argv[0], KRB5_PROG_KEYTYPE_NOSUPP,
+           com_err(progname, KRB5_PROG_KEYTYPE_NOSUPP,
                    "while setting up enctype %d", master_keyblock.enctype);
        else
-           com_err(argv[0], KRB5_PROG_KEYTYPE_NOSUPP, tmp);
+           com_err(progname, KRB5_PROG_KEYTYPE_NOSUPP, tmp);
        exit_status++; return; 
     }
 
@@ -130,14 +127,14 @@ kdb5_stash(argc, argv)
     retval = krb5_db_setup_mkey_name(context, mkey_name, realm, 
                                     &mkey_fullname, &master_princ);
     if (retval) {
-       com_err(argv[0], retval, "while setting up master key name");
+       com_err(progname, retval, "while setting up master key name");
        exit_status++; return; 
     }
 
     retval = krb5_db_open(context, db5util_db_args, 
                          KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_OTHER);
     if (retval) {
-       com_err(argv[0], retval, "while initializing the database '%s'",
+       com_err(progname, retval, "while initializing the database '%s'",
                dbname);
        exit_status++; return; 
     }
@@ -148,7 +145,7 @@ kdb5_stash(argc, argv)
                                TRUE, FALSE, (char *) NULL,
                                0, &master_keyblock);
     if (retval) {
-       com_err(argv[0], retval, "while reading master key");
+       com_err(progname, retval, "while reading master key");
        (void) krb5_db_fini(context);
        exit_status++; return; 
     }
@@ -156,7 +153,7 @@ kdb5_stash(argc, argv)
     retval = krb5_db_verify_master_key(context, master_princ, 
                                       &master_keyblock);
     if (retval) {
-       com_err(argv[0], retval, "while verifying master key");
+       com_err(progname, retval, "while verifying master key");
        (void) krb5_db_fini(context);
        exit_status++; return; 
     }  
@@ -164,7 +161,7 @@ kdb5_stash(argc, argv)
     retval = krb5_db_store_master_key(context, keyfile, master_princ, 
                                      &master_keyblock, NULL);
     if (retval) {
-       com_err(argv[0], errno, "while storing key");
+       com_err(progname, errno, "while storing key");
        memset((char *)master_keyblock.contents, 0, master_keyblock.length);
        (void) krb5_db_fini(context);
        exit_status++; return; 
@@ -173,7 +170,7 @@ kdb5_stash(argc, argv)
 
     retval = krb5_db_fini(context);
     if (retval) {
-       com_err(argv[0], retval, "closing database '%s'", dbname);
+       com_err(progname, retval, "closing database '%s'", dbname);
        exit_status++; return; 
     }
 
index ff52e4c4246e2830bbe6a8730b80a69d7ac12926..73b8262072ebe855c14c74e9ceb0b225051e1fec 100644 (file)
@@ -247,7 +247,7 @@ int main(argc, argv)
            }
        } else if (strcmp(*argv, "-k") == 0 && ARG_VAL) {
            if (krb5_string_to_enctype(koptarg, &global_params.enctype))
-                com_err(argv[0], 0, "%s is an invalid enctype", koptarg);
+                com_err(progname, 0, "%s is an invalid enctype", koptarg);
            else
                 global_params.mask |= KADM5_CONFIG_ENCTYPE;
        } else if (strcmp(*argv, "-M") == 0 && ARG_VAL) {
@@ -289,7 +289,7 @@ int main(argc, argv)
     retval = kadm5_get_config_params(util_context, 1,
                                     &global_params, &global_params);
     if (retval) {
-        com_err(argv[0], retval, "while retreiving configuration parameters");
+        com_err(progname, retval, "while retreiving configuration parameters");
         exit(1);
     }
 
@@ -302,7 +302,7 @@ int main(argc, argv)
     master_keyblock.enctype = global_params.enctype;
     if ((master_keyblock.enctype != ENCTYPE_UNKNOWN) &&
        (!krb5_c_valid_enctype(master_keyblock.enctype))) {
-       com_err(argv[0], KRB5_PROG_KEYTYPE_NOSUPP,
+       com_err(progname, KRB5_PROG_KEYTYPE_NOSUPP,
                "while setting up enctype %d", master_keyblock.enctype);
     }
 
@@ -336,13 +336,13 @@ void set_dbname(argc, argv)
 
     if (argc < 3) {
        com_err(argv[0], 0, "Too few arguments");
-       com_err(argv[0], 0, "Usage: %s dbpathname realmname", argv[0]);
+       com_err(progname, 0, "Usage: %s dbpathname realmname", argv[0]);
        exit_status++;
        return;
     }
     if (dbactive) {
        if ((retval = krb5_db_fini(util_context)) && retval!= KRB5_KDB_DBNOTINITED) {
-           com_err(argv[0], retval, "while closing previous database");
+           com_err(progname, retval, "while closing previous database");
            exit_status++;
            return;
        }
@@ -355,7 +355,7 @@ void set_dbname(argc, argv)
        dbactive = FALSE;
     }
 
-    (void) set_dbname_help(argv[0], argv[1]);
+    (void) set_dbname_help(progname, argv[1]);
     return;
 }
 #endif
@@ -427,6 +427,7 @@ static int open_db_and_mkey()
        retval = krb5_principal2salt(util_context, master_princ, &scratch);
        if (retval) {
            com_err(progname, retval, "while calculated master key salt");
+           exit_status++;
            return(1);
        }
 
@@ -444,6 +445,7 @@ static int open_db_and_mkey()
        if (retval) {
            com_err(progname, retval,
                    "while transforming master key from password");
+           exit_status++;
            return(1);
        }
        free(scratch.data);
@@ -521,7 +523,7 @@ add_random_key(argc, argv)
     krb5_int32 num_keysalts = 0;
 
     int free_keysalts;
-    char *me = argv[0];
+    char *me = progname;
     char *ks_str = NULL;
     char *pr_str;
 
index 7a6c6411e3983d602c2e8b29c75fc5c46e748e02..576a6f0e659b4cbf9c4ffe67dca0c744933610c0 100644 (file)
@@ -67,7 +67,7 @@ static krb5_error_code init_ldap_realm (int argc, char *argv[]) {
         retval = krb5_ldap_read_krbcontainer_params (util_context,
                 &(ldap_context->krbcontainer));
         if (retval != 0) {
-            com_err(argv[0], retval, "while reading kerberos container information");
+            com_err(progname, retval, "while reading kerberos container information");
             goto cleanup;
         }
     }
@@ -95,7 +95,7 @@ kdb5_ldap_create_policy(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname;
     krb5_error_code retval = 0;
     krb5_ldap_policy_params *policyparams = NULL;
     krb5_boolean print_usage = FALSE;
@@ -322,7 +322,7 @@ kdb5_ldap_destroy_policy(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname;
     krb5_error_code retval = 0;
     krb5_ldap_policy_params *policyparams = NULL;
     krb5_boolean print_usage = FALSE;
@@ -426,7 +426,7 @@ kdb5_ldap_modify_policy(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname;
     krb5_error_code retval = 0;
     krb5_ldap_policy_params *policyparams = NULL;
     krb5_boolean print_usage = FALSE;
@@ -683,7 +683,7 @@ kdb5_ldap_view_policy(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname;
     krb5_ldap_policy_params *policyparams = NULL;
     krb5_error_code retval = 0;
     krb5_boolean print_usage = FALSE;
@@ -804,7 +804,7 @@ void kdb5_ldap_list_policies(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname;
     krb5_error_code retval = 0;
     krb5_boolean print_usage = FALSE;
     char *basedn = NULL;
index 1a0d9fa999ea1bd9e3a6b44b425e40882875552b..0e4ce9574afc905d7de95a57582e34b5e9d6601f 100644 (file)
@@ -152,7 +152,7 @@ static int get_ticket_policy(rparams,i,argv,argc)
     krb5_boolean no_msg = FALSE;
 
     krb5_boolean print_usage = FALSE;
-    char *me = argv[0];
+    char *me = progname;
 
     time(&now);
     if (!strcmp(argv[*i], "-maxtktlife")) {
@@ -364,7 +364,7 @@ void kdb5_ldap_create(argc, argv)
                rparams->subtree = list;
            } else if(strncmp(argv[i], "", strlen(argv[i]))==0) {
                 /* dont allow subtree value to be set at the root(NULL, "") of the tree */
-                com_err(argv[0], EINVAL,
+                com_err(progname, EINVAL,
                          "for subtree while creating realm '%s'",
                           global_params.realm);
                 goto err_nomsg;
@@ -376,7 +376,7 @@ void kdb5_ldap_create(argc, argv)
                goto err_usage;
            if(strncmp(argv[i], "", strlen(argv[i]))==0) {
                 /* dont allow containerref value to be set at the root(NULL, "") of the tree */
-                com_err(argv[0], EINVAL,
+                com_err(progname, EINVAL,
                          "for container reference while creating realm '%s'",
                           global_params.realm);
                 goto err_nomsg;
@@ -401,7 +401,7 @@ void kdb5_ldap_create(argc, argv)
                rparams->search_scope = atoi(argv[i]);
                if ((rparams->search_scope != 1) &&
                    (rparams->search_scope != 2)) {
-                   com_err(argv[0], EINVAL,
+                   com_err(progname, EINVAL,
                            "invalid search scope while creating realm '%s'",
                            global_params.realm);
                    goto err_nomsg;
@@ -498,7 +498,7 @@ void kdb5_ldap_create(argc, argv)
        retval = krb5_read_password(util_context, KRB5_KDC_MKEY_1, KRB5_KDC_MKEY_2,
                                    pw_str, &pw_size);
        if (retval) {
-           com_err(argv[0], retval, "while reading master key from keyboard");
+           com_err(progname, retval, "while reading master key from keyboard");
            goto err_nomsg;
        }
        mkey_password = pw_str;
@@ -516,7 +516,7 @@ void kdb5_ldap_create(argc, argv)
     rparams->realm_name = strdup(global_params.realm);
     if (rparams->realm_name == NULL) {
        retval = ENOMEM;
-       com_err(argv[0], ENOMEM, "while creating realm '%s'",
+       com_err(progname, ENOMEM, "while creating realm '%s'",
                global_params.realm);
        goto err_nomsg;
     }
@@ -588,11 +588,11 @@ void kdb5_ldap_create(argc, argv)
        retval = krb5_ldap_read_krbcontainer_params(util_context,
                                                    &(ldap_context->krbcontainer));
        if (retval) {
-           com_err(argv[0], retval, "while reading kerberos container information");
+           com_err(progname, retval, "while reading kerberos container information");
            goto cleanup;
        }
     } else if (retval) {
-       com_err(argv[0], retval, "while reading kerberos container information");
+       com_err(progname, retval, "while reading kerberos container information");
        goto cleanup;
     }
 
@@ -608,7 +608,7 @@ void kdb5_ldap_create(argc, argv)
                                              global_params.realm,
                                              &(ldap_context->lrparams),
                                              &mask))) {
-       com_err(argv[0], retval, "while reading information of realm '%s'",
+       com_err(progname, retval, "while reading information of realm '%s'",
                global_params.realm);
        goto err_nomsg;
     }
@@ -623,7 +623,7 @@ void kdb5_ldap_create(argc, argv)
                                          global_params.mkey_name,
                                          global_params.realm,
                                          0, &master_princ))) {
-       com_err(argv[0], retval, "while setting up master key name");
+       com_err(progname, retval, "while setting up master key name");
        goto err_nomsg;
     }
 
@@ -635,7 +635,7 @@ void kdb5_ldap_create(argc, argv)
        pwd.length = strlen(mkey_password);
        retval = krb5_principal2salt(util_context, master_princ, &master_salt);
        if (retval) {
-           com_err(argv[0], retval, "while calculating master key salt");
+           com_err(progname, retval, "while calculating master key salt");
            goto err_nomsg;
        }
 
@@ -646,7 +646,7 @@ void kdb5_ldap_create(argc, argv)
            free(master_salt.data);
 
        if (retval) {
-           com_err(argv[0], retval, "while transforming master key from password");
+           com_err(progname, retval, "while transforming master key from password");
            goto err_nomsg;
        }
 
@@ -689,28 +689,28 @@ void kdb5_ldap_create(argc, argv)
        /* Create 'K/M' ... */
        rblock.flags |= KRB5_KDB_DISALLOW_ALL_TIX;
        if ((retval = kdb_ldap_create_principal(util_context, master_princ, MASTER_KEY, &rblock))) {
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
 
        /* Create 'krbtgt' ... */
        rblock.flags = 0; /* reset the flags */
        if ((retval = kdb_ldap_create_principal(util_context, &tgt_princ, TGT_KEY, &rblock))) {
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
 
        /* Create 'kadmin/admin' ... */
        snprintf(princ_name, sizeof(princ_name), "%s@%s", KADM5_ADMIN_SERVICE, global_params.realm);
        if ((retval = krb5_parse_name(util_context, princ_name, &p))) {
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
        rblock.max_life = ADMIN_LIFETIME;
        rblock.flags = KRB5_KDB_DISALLOW_TGT_BASED;
        if ((retval = kdb_ldap_create_principal(util_context, p, TGT_KEY, &rblock))) {
            krb5_free_principal(util_context, p);
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
        krb5_free_principal(util_context, p);
@@ -718,7 +718,7 @@ void kdb5_ldap_create(argc, argv)
        /* Create 'kadmin/changepw' ... */
        snprintf(princ_name, sizeof(princ_name), "%s@%s", KADM5_CHANGEPW_SERVICE, global_params.realm);
        if ((retval = krb5_parse_name(util_context, princ_name, &p))) {
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
        rblock.max_life = CHANGEPW_LIFETIME;
@@ -726,7 +726,7 @@ void kdb5_ldap_create(argc, argv)
            KRB5_KDB_PWCHANGE_SERVICE;
        if ((retval = kdb_ldap_create_principal(util_context, p, TGT_KEY, &rblock))) {
            krb5_free_principal(util_context, p);
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
        krb5_free_principal(util_context, p);
@@ -734,26 +734,26 @@ void kdb5_ldap_create(argc, argv)
        /* Create 'kadmin/history' ... */
        snprintf(princ_name, sizeof(princ_name), "%s@%s", KADM5_HIST_PRINCIPAL, global_params.realm);
        if ((retval = krb5_parse_name(util_context, princ_name, &p))) {
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
        rblock.max_life = global_params.max_life;
        rblock.flags = 0;
        if ((retval = kdb_ldap_create_principal(util_context, p, TGT_KEY, &rblock))) {
            krb5_free_principal(util_context, p);
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
        krb5_free_principal(util_context, p);
 
        /* Create 'kadmin/<hostname>' ... */
        if ((retval=krb5_sname_to_principal(util_context, NULL, "kadmin", KRB5_NT_SRV_HST, &p))) {
-           com_err(argv[0], retval, "krb5_sname_to_principal, while adding entries to the database");
+           com_err(progname, retval, "krb5_sname_to_principal, while adding entries to the database");
            goto err_nomsg;
        }
 
        if ((retval=krb5_copy_principal(util_context, p, &temp_p))) {
-           com_err(argv[0], retval, "krb5_copy_principal, while adding entries to the database");
+           com_err(progname, retval, "krb5_copy_principal, while adding entries to the database");
            goto err_nomsg;
        }
 
@@ -762,7 +762,7 @@ void kdb5_ldap_create(argc, argv)
        temp_p->realm.length = strlen(util_context->default_realm);
        temp_p->realm.data = strdup(util_context->default_realm);
        if (temp_p->realm.data == NULL) {
-           com_err(argv[0], ENOMEM, "while adding entries to the database");
+           com_err(progname, ENOMEM, "while adding entries to the database");
            goto err_nomsg;
        }
 
@@ -770,7 +770,7 @@ void kdb5_ldap_create(argc, argv)
        rblock.flags = KRB5_KDB_DISALLOW_TGT_BASED;
        if ((retval = kdb_ldap_create_principal(util_context, temp_p, TGT_KEY, &rblock))) {
            krb5_free_principal(util_context, p);
-           com_err(argv[0], retval, "while adding entries to the database");
+           com_err(progname, retval, "while adding entries to the database");
            goto err_nomsg;
        }
        krb5_free_principal(util_context, temp_p);
@@ -798,7 +798,7 @@ void kdb5_ldap_create(argc, argv)
                                                         LDAP_KDC_SERVICE, rparams->kdcservers[i],
                                                         rparams->realm_name, rparams->subtree, rightsmask)) != 0) {
                    printf("failed\n");
-                   com_err(argv[0], retval, "while assigning rights to '%s'",
+                   com_err(progname, retval, "while assigning rights to '%s'",
                            rparams->realm_name);
                    goto err_nomsg;
                }
@@ -814,7 +814,7 @@ void kdb5_ldap_create(argc, argv)
                                                         LDAP_ADMIN_SERVICE, rparams->adminservers[i],
                                                         rparams->realm_name, rparams->subtree, rightsmask)) != 0) {
                    printf("failed\n");
-                   com_err(argv[0], retval, "while assigning rights to '%s'",
+                   com_err(progname, retval, "while assigning rights to '%s'",
                            rparams->realm_name);
                    goto err_nomsg;
                }
@@ -830,7 +830,7 @@ void kdb5_ldap_create(argc, argv)
                                                         LDAP_PASSWD_SERVICE, rparams->passwdservers[i],
                                                         rparams->realm_name, rparams->subtree, rightsmask)) != 0) {
                    printf("failed\n");
-                   com_err(argv[0], retval, "while assigning rights to '%s'",
+                   com_err(progname, retval, "while assigning rights to '%s'",
                            rparams->realm_name);
                    goto err_nomsg;
                }
@@ -850,7 +850,7 @@ void kdb5_ldap_create(argc, argv)
                                     master_princ,
                                     &master_keyblock, NULL);
        if (retval) {
-           com_err(argv[0], errno, "while storing key");
+           com_err(progname, errno, "while storing key");
            printf("Warning: couldn't stash master key.\n");
        }
     }
@@ -879,7 +879,7 @@ cleanup:
 
     if (retval) {
        if (!no_msg) {
-           com_err(argv[0], retval, "while creating realm '%s'",
+           com_err(progname, retval, "while creating realm '%s'",
                    global_params.realm);
        }
        exit_status++;
@@ -932,7 +932,7 @@ void kdb5_ldap_modify(argc, argv)
 
     if ((retval = krb5_ldap_read_krbcontainer_params(util_context,
                                                     &(ldap_context->krbcontainer)))) {
-       com_err(argv[0], retval, "while reading Kerberos container information");
+       com_err(progname, retval, "while reading Kerberos container information");
        goto err_nomsg;
     }
 
@@ -986,7 +986,7 @@ void kdb5_ldap_modify(argc, argv)
                rparams->subtree =  slist;
            } else if(strncmp(argv[i], "", strlen(argv[i]))==0) {
                 /* dont allow subtree value to be set at the root(NULL, "") of the tree */
-                   com_err(argv[0], EINVAL,
+                   com_err(progname, EINVAL,
                            "for subtree while modifying realm '%s'",
                            global_params.realm);
                    goto err_nomsg;
@@ -998,7 +998,7 @@ void kdb5_ldap_modify(argc, argv)
                goto err_usage;
            if(strncmp(argv[i], "", strlen(argv[i]))==0) {
                 /* dont allow containerref value to be set at the root(NULL, "") of the tree */
-                com_err(argv[0], EINVAL,
+                com_err(progname, EINVAL,
                          "for container reference while modifying realm '%s'",
                           global_params.realm);
                 goto err_nomsg;
@@ -1024,7 +1024,7 @@ void kdb5_ldap_modify(argc, argv)
                if ((rparams->search_scope != 1) &&
                    (rparams->search_scope != 2)) {
                    retval = EINVAL;
-                   com_err(argv[0], retval,
+                   com_err(progname, retval,
                            "specified for search scope while modifying information of realm '%s'",
                            global_params.realm);
                    goto err_nomsg;
@@ -1529,7 +1529,7 @@ void kdb5_ldap_modify(argc, argv)
                                                                LDAP_KDC_SERVICE, oldkdcdns[i],
                                                                rparams->realm_name, oldsubtrees, rightsmask)) != 0) {
                        printf("failed\n");
-                       com_err(argv[0], retval, "while assigning rights '%s'",
+                       com_err(progname, retval, "while assigning rights '%s'",
                                rparams->realm_name);
                        goto err_nomsg;
                    }
@@ -1546,7 +1546,7 @@ void kdb5_ldap_modify(argc, argv)
                                                             LDAP_KDC_SERVICE, newkdcdns[i], rparams->realm_name,
                                                             rparams->subtree, rightsmask)) != 0) {
                        printf("failed\n");
-                       com_err(argv[0], retval, "while assigning rights to '%s'",
+                       com_err(progname, retval, "while assigning rights to '%s'",
                                rparams->realm_name);
                        goto err_nomsg;
                    }
@@ -1608,7 +1608,7 @@ void kdb5_ldap_modify(argc, argv)
                                                                LDAP_ADMIN_SERVICE, oldadmindns[i],
                                                                rparams->realm_name, oldsubtrees, rightsmask)) != 0) {
                        printf("failed\n");
-                       com_err(argv[0], retval, "while assigning rights '%s'",
+                       com_err(progname, retval, "while assigning rights '%s'",
                                rparams->realm_name);
                        goto err_nomsg;
                    }
@@ -1626,7 +1626,7 @@ void kdb5_ldap_modify(argc, argv)
                                                             LDAP_ADMIN_SERVICE, newadmindns[i],
                                                             rparams->realm_name, rparams->subtree, rightsmask)) != 0) {
                        printf("failed\n");
-                       com_err(argv[0], retval, "while assigning rights to '%s'",
+                       com_err(progname, retval, "while assigning rights to '%s'",
                                rparams->realm_name);
                        goto err_nomsg;
                    }
@@ -1688,7 +1688,7 @@ void kdb5_ldap_modify(argc, argv)
                                                                  LDAP_PASSWD_SERVICE, oldpwddns[i],
                                                                  rparams->realm_name, oldsubtrees, rightsmask))) {
                        printf("failed\n");
-                       com_err(argv[0], retval, "while assigning rights '%s'",
+                       com_err(progname, retval, "while assigning rights '%s'",
                                rparams->realm_name);
                        goto err_nomsg;
                    }
@@ -1705,7 +1705,7 @@ void kdb5_ldap_modify(argc, argv)
                                                               LDAP_PASSWD_SERVICE, newpwddns[i],
                                                               rparams->realm_name, rparams->subtree, rightsmask))) {
                        printf("failed\n");
-                       com_err(argv[0], retval, "while assigning rights to '%s'",
+                       com_err(progname, retval, "while assigning rights to '%s'",
                                rparams->realm_name);
                        goto err_nomsg;
                    }
@@ -1777,7 +1777,7 @@ cleanup:
 
     if (retval) {
        if (!no_msg)
-           com_err(argv[0], retval, "while modifying information of realm '%s'",
+           com_err(progname, retval, "while modifying information of realm '%s'",
                    global_params.realm);
        exit_status++;
     }
@@ -1804,7 +1804,7 @@ void kdb5_ldap_view(argc, argv)
     ldap_context = (krb5_ldap_context *) dal_handle->db_context;
     if (!(ldap_context)) {
        retval = EINVAL;
-       com_err(argv[0], retval, "while initializing database");
+       com_err(progname, retval, "while initializing database");
        exit_status++;
        return;
     }
@@ -1812,14 +1812,14 @@ void kdb5_ldap_view(argc, argv)
     /* Read the kerberos container information */
     if ((retval = krb5_ldap_read_krbcontainer_params(util_context,
                                                     &(ldap_context->krbcontainer))) != 0) {
-       com_err(argv[0], retval, "while reading kerberos container information");
+       com_err(progname, retval, "while reading kerberos container information");
        exit_status++;
        return;
     }
 
     if ((retval = krb5_ldap_read_realm_params(util_context,
                                              global_params.realm, &rparams, &mask)) || (!rparams)) {
-       com_err(argv[0], retval, "while reading information of realm '%s'",
+       com_err(progname, retval, "while reading information of realm '%s'",
                global_params.realm);
        exit_status++;
        return;
@@ -2009,7 +2009,7 @@ void kdb5_ldap_list(argc, argv)
     /* Read the kerberos container information */
     if ((retval = krb5_ldap_read_krbcontainer_params(util_context,
                                                     &(ldap_context->krbcontainer))) != 0) {
-       com_err(argv[0], retval, "while reading kerberos container information");
+       com_err(progname, retval, "while reading kerberos container information");
        exit_status++;
        return;
     }
@@ -2018,7 +2018,7 @@ void kdb5_ldap_list(argc, argv)
     if (retval != 0) {
        krb5_ldap_free_krbcontainer_params(ldap_context->krbcontainer);
        ldap_context->krbcontainer = NULL;
-       com_err (argv[0], retval, "while listing realms");
+       com_err (progname, retval, "while listing realms");
        exit_status++;
        return;
     }
@@ -2434,7 +2434,7 @@ kdb5_ldap_destroy(argc, argv)
     dal_handle = (kdb5_dal_handle *)util_context->db_context;
     ldap_context = (krb5_ldap_context *) dal_handle->db_context;
     if (!(ldap_context)) {
-       com_err(argv[0], EINVAL, "while initializing database");
+       com_err(progname, EINVAL, "while initializing database");
        exit_status++;
        return;
     }
@@ -2442,7 +2442,7 @@ kdb5_ldap_destroy(argc, argv)
     /* Read the kerberos container from the LDAP Server */
     if ((retval = krb5_ldap_read_krbcontainer_params(util_context,
                                                     &(ldap_context->krbcontainer))) != 0) {
-       com_err(argv[0], retval, "while reading kerberos container information");
+       com_err(progname, retval, "while reading kerberos container information");
        exit_status++;
        return;
     }
@@ -2450,7 +2450,7 @@ kdb5_ldap_destroy(argc, argv)
     /* Read the Realm information from the LDAP Server */
     if ((retval = krb5_ldap_read_realm_params(util_context, global_params.realm,
                                              &(ldap_context->lrparams), &mask)) != 0) {
-       com_err(argv[0], retval, "while reading realm information");
+       com_err(progname, retval, "while reading realm information");
        exit_status++;
        return;
     }
@@ -2472,7 +2472,7 @@ kdb5_ldap_destroy(argc, argv)
                                                              LDAP_KDC_SERVICE, rparams->kdcservers[i],
                                                              rparams->realm_name, rparams->subtree, rightsmask)) != 0) {
                    printf("failed\n");
-                   com_err(argv[0], retval, "while assigning rights to '%s'",
+                   com_err(progname, retval, "while assigning rights to '%s'",
                            rparams->realm_name);
                    return;
                }
@@ -2487,7 +2487,7 @@ kdb5_ldap_destroy(argc, argv)
                                                              LDAP_ADMIN_SERVICE, rparams->adminservers[i],
                                                              rparams->realm_name, rparams->subtree, rightsmask)) != 0) {
                    printf("failed\n");
-                   com_err(argv[0], retval, "while assigning rights to '%s'",
+                   com_err(progname, retval, "while assigning rights to '%s'",
                            rparams->realm_name);
                    return;
                }
@@ -2502,7 +2502,7 @@ kdb5_ldap_destroy(argc, argv)
                                                              LDAP_PASSWD_SERVICE, rparams->passwdservers[i],
                                                              rparams->realm_name, rparams->subtree, rightsmask)) != 0) {
                    printf("failed\n");
-                   com_err(argv[0], retval, "while assigning rights to '%s'",
+                   com_err(progname, retval, "while assigning rights to '%s'",
                            rparams->realm_name);
                    return;
                }
@@ -2514,7 +2514,7 @@ kdb5_ldap_destroy(argc, argv)
     /* Delete the realm container and all the associated principals */
     retval = krb5_ldap_delete_realm(util_context, global_params.realm);
     if (retval) {
-       com_err(argv[0], retval, "deleting database of '%s'", global_params.realm);
+       com_err(progname, retval, "deleting database of '%s'", global_params.realm);
        exit_status++;
        return;
     }
index 80793b7ac9d1dc2a234e44cd071184a6fd847f2a..0028ae5b6672a3aa9b46b4e5fce6d88dcf9ed90c 100644 (file)
@@ -198,7 +198,7 @@ void kdb5_ldap_create_service(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname;
     krb5_error_code retval = 0;
     krb5_ldap_service_params *srvparams = NULL;
     krb5_boolean print_usage = FALSE;
@@ -496,7 +496,7 @@ void kdb5_ldap_modify_service(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname; 
     krb5_error_code retval = 0;
     krb5_ldap_service_params *srvparams = NULL;
     krb5_boolean print_usage = FALSE;
@@ -569,7 +569,7 @@ void kdb5_ldap_modify_service(argc, argv)
 
     retval = krb5_ldap_read_service(util_context, servicedn, &srvparams, &in_mask);
     if (retval) {
-       com_err(argv[0], retval, "while reading information of service '%s'",
+       com_err(me, retval, "while reading information of service '%s'",
                servicedn);
        goto err_nomsg;
     }
@@ -1061,7 +1061,7 @@ rem_service_entry_from_file(argc, argv, file_name, service_object)
     char *service_object;
 {
     int     st        = EINVAL;
-    char    *me       = argv[0];
+    char    *me       = progname;
     char    *tmp_file = NULL;
     int     tmpfd     = -1;
     FILE    *pfile    = NULL;
@@ -1175,7 +1175,7 @@ kdb5_ldap_destroy_service(argc, argv)
            if (argv[i+1]) {
                stashfilename=strdup(argv[i+1]);
                if (stashfilename == NULL) {
-                   com_err(argv[0], ENOMEM, "while destroying service");
+                   com_err(progname, ENOMEM, "while destroying service");
                    exit_status++;
                    goto cleanup;
                }
@@ -1188,7 +1188,7 @@ kdb5_ldap_destroy_service(argc, argv)
            if ((argv[i]) && (servicedn == NULL)) {
                servicedn=strdup(argv[i]);
                if (servicedn == NULL) {
-                   com_err(argv[0], ENOMEM, "while destroying service");
+                   com_err(progname, ENOMEM, "while destroying service");
                    exit_status++;
                    goto cleanup;
                }
@@ -1219,7 +1219,7 @@ kdb5_ldap_destroy_service(argc, argv)
 
     if ((retval = krb5_ldap_read_service(util_context, servicedn,
                                         &lserparams, &mask))) {
-       com_err(argv[0], retval, "while destroying service '%s'",servicedn);
+       com_err(progname, retval, "while destroying service '%s'",servicedn);
        exit_status++;
        goto cleanup;
     }
@@ -1227,7 +1227,7 @@ kdb5_ldap_destroy_service(argc, argv)
     retval = krb5_ldap_delete_service(util_context, lserparams, servicedn);
 
     if (retval) {
-       com_err(argv[0], retval, "while destroying service '%s'", servicedn);
+       com_err(progname, retval, "while destroying service '%s'", servicedn);
        exit_status++;
        goto cleanup;
     }
@@ -1235,7 +1235,7 @@ kdb5_ldap_destroy_service(argc, argv)
     if (stashfilename == NULL) {
        stashfilename = strdup(DEF_SERVICE_PASSWD_FILE);
        if (stashfilename == NULL) {
-           com_err(argv[0], ENOMEM, "while destroying service");
+           com_err(progname, ENOMEM, "while destroying service");
            exit_status++;
            goto cleanup;
        }
@@ -1295,13 +1295,13 @@ void kdb5_ldap_view_service(argc, argv)
 
     servicedn=strdup(argv[1]);
     if (servicedn == NULL) {
-       com_err(argv[0], ENOMEM, "while viewing service");
+       com_err(progname, ENOMEM, "while viewing service");
        exit_status++;
        goto cleanup;
     }
 
     if ((retval = krb5_ldap_read_service(util_context, servicedn, &lserparams, &mask))) {
-       com_err(argv[0], retval, "while viewing service '%s'",servicedn);
+       com_err(progname, retval, "while viewing service '%s'",servicedn);
        exit_status++;
        goto cleanup;
     }
@@ -1338,7 +1338,7 @@ void kdb5_ldap_list_services(argc, argv)
     int argc;
     char *argv[];
 {
-    char *me = argv[0];
+    char *me = progname;
     krb5_error_code retval = 0;
     char *basedn = NULL;
     char **list = NULL;
@@ -1519,7 +1519,7 @@ kdb5_ldap_set_service_password(argc, argv)
     krb5_ldap_context *lparams = NULL;
     char *file_name = NULL;
     char *tmp_file = NULL;
-    char *me = argv[0];
+    char *me = progname;
     int filelen = 0;
     int random_passwd = 0;
     int set_dir_pwd = 1;
@@ -1902,7 +1902,7 @@ kdb5_ldap_stash_service_password(argc, argv)
 {
     int ret = 0;
     unsigned int passwd_len = 0;
-    char *me = argv[0];
+    char *me = progname;
     char *service_object = NULL;
     char *file_name = NULL, *tmp_file = NULL;
     char passwd[MAX_SERVICE_PASSWD_LEN];
index d7a05a3d81719b74b54c4cff635308be63df336d..86cab3c906789821aad6b5339959409f6411304d 100644 (file)
@@ -347,7 +347,7 @@ int main(argc, argv)
            }
        } else if (strcmp(*argv, "-k") == 0 && ARG_VAL) {
            if (krb5_string_to_enctype(koptarg, &global_params.enctype))
-               com_err(argv[0], 0, "%s is an invalid enctype", koptarg);
+               com_err(progname, 0, "%s is an invalid enctype", koptarg);
            else
                global_params.mask |= KADM5_CONFIG_ENCTYPE;
        } else if (strcmp(*argv, "-M") == 0 && ARG_VAL) {
@@ -469,7 +469,7 @@ int main(argc, argv)
        retval = kadm5_get_config_params(util_context, 1,
                                         &global_params, &global_params);
        if (retval) {
-           com_err(argv[0], retval, "while retreiving configuration parameters");
+           com_err(progname, retval, "while retreiving configuration parameters");
            exit_status++;
            goto cleanup;
        }
@@ -477,7 +477,7 @@ int main(argc, argv)
     }
 
     if ((retval = krb5_ldap_lib_init()) != 0) {
-       com_err(argv[0], retval, "while initializing error handling");
+       com_err(progname, retval, "while initializing error handling");
        exit_status++;
        goto cleanup;
     }
@@ -485,7 +485,7 @@ int main(argc, argv)
     /* Initialize the ldap context */
     ldap_context = calloc(sizeof(krb5_ldap_context), 1);
     if (ldap_context == NULL) {
-       com_err(argv[0], ENOMEM, "while initializing ldap handle");
+       com_err(progname, ENOMEM, "while initializing ldap handle");
        exit_status++;
        goto cleanup;
     }
@@ -498,7 +498,7 @@ int main(argc, argv)
        if (passwd == NULL) {
            passwd = (char *)malloc(MAX_PASSWD_LEN);
            if (passwd == NULL) {
-               com_err(argv[0], ENOMEM, "while retrieving ldap configuration");
+               com_err(progname, ENOMEM, "while retrieving ldap configuration");
                exit_status++;
                goto cleanup;
            }
@@ -506,7 +506,7 @@ int main(argc, argv)
            if (prompt == NULL) {
                free(passwd);
                passwd = NULL;
-               com_err(argv[0], ENOMEM, "while retrieving ldap configuration");
+               com_err(progname, ENOMEM, "while retrieving ldap configuration");
                exit_status++;
                goto cleanup;
            }
@@ -517,7 +517,7 @@ int main(argc, argv)
            db_retval = krb5_read_password(util_context, prompt, NULL, passwd, &passwd_len);
 
            if ((db_retval) || (passwd_len == 0)) {
-               com_err(argv[0], ENOMEM, "while retrieving ldap configuration");
+               com_err(progname, ENOMEM, "while retrieving ldap configuration");
                free(passwd);
                passwd = NULL;
                exit_status++;
@@ -533,14 +533,14 @@ int main(argc, argv)
 
        ldap_context->server_info_list = (krb5_ldap_server_info **) calloc (2, sizeof (krb5_ldap_server_info *)) ;
        if (ldap_context->server_info_list == NULL) {
-           com_err(argv[0], ENOMEM, "while initializing server list");
+           com_err(progname, ENOMEM, "while initializing server list");
            exit_status++;
            goto cleanup;
        }
 
        ldap_context->server_info_list[0] = (krb5_ldap_server_info *) calloc (1, sizeof (krb5_ldap_server_info));
        if (ldap_context->server_info_list[0] == NULL) {
-           com_err(argv[0], ENOMEM, "while initializing server list");
+           com_err(progname, ENOMEM, "while initializing server list");
            exit_status++;
            goto cleanup;
        }
@@ -549,7 +549,7 @@ int main(argc, argv)
 
        ldap_context->server_info_list[0]->server_name = strdup(ldap_server);
        if (ldap_context->server_info_list[0]->server_name == NULL) {
-           com_err(argv[0], ENOMEM, "while initializing server list");
+           com_err(progname, ENOMEM, "while initializing server list");
            exit_status++;
            goto cleanup;
        }
@@ -557,7 +557,7 @@ int main(argc, argv)
     if (bind_dn) {
        ldap_context->bind_dn = strdup(bind_dn);
        if (ldap_context->bind_dn == NULL) {
-           com_err(argv[0], ENOMEM, "while retrieving ldap configuration");
+           com_err(progname, ENOMEM, "while retrieving ldap configuration");
            exit_status++;
            goto cleanup;
        }
@@ -569,7 +569,7 @@ int main(argc, argv)
     if (realm_name_required) {
        if ((global_params.enctype != ENCTYPE_UNKNOWN) &&
            (!krb5_c_valid_enctype(global_params.enctype))) {
-           com_err(argv[0], KRB5_PROG_KEYTYPE_NOSUPP,
+           com_err(progname, KRB5_PROG_KEYTYPE_NOSUPP,
                    "while setting up enctype %d", global_params.enctype);
        }
     }
@@ -586,7 +586,7 @@ int main(argc, argv)
 
     db_retval = krb5_ldap_read_server_params(util_context, conf_section, KRB5_KDB_SRV_TYPE_OTHER);
     if (db_retval) {
-       com_err(argv[0], db_retval, "while reading ldap configuration");
+       com_err(progname, db_retval, "while reading ldap configuration");
        exit_status++;
        goto cleanup;
     }
index f2c49a57eed5c3215d502078cdc7f99bb64a9406..a2b3bb802a8509098f547354cb8e90030fb78950 100644 (file)
@@ -58,6 +58,8 @@
 #define DESTROY_POLICY        14
 #define LIST_POLICY           15
 
+extern char *progname;
+
 extern int exit_status;
 extern krb5_context util_context;