From 2e4c764eeb97fc6a61e2e8dabe36560dc4a9750d Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Thu, 17 Jul 2008 15:44:43 +0000 Subject: [PATCH] Apply patch from Mark Phalan to correctly use progname instead of argv[0]. ticket: 6030 tags: pullup target_version: 1.6.4 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20532 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/dbutil/dump.c | 72 ++++++------ src/kadmin/dbutil/kdb5_create.c | 25 ++--- src/kadmin/dbutil/kdb5_destroy.c | 9 +- src/kadmin/dbutil/kdb5_stash.c | 23 ++-- src/kadmin/dbutil/kdb5_util.c | 16 +-- .../kdb/ldap/ldap_util/kdb5_ldap_policy.c | 12 +- .../kdb/ldap/ldap_util/kdb5_ldap_realm.c | 104 +++++++++--------- .../kdb/ldap/ldap_util/kdb5_ldap_services.c | 28 ++--- .../kdb/ldap/ldap_util/kdb5_ldap_util.c | 26 ++--- .../kdb/ldap/ldap_util/kdb5_ldap_util.h | 2 + 10 files changed, 152 insertions(+), 165 deletions(-) diff --git a/src/kadmin/dbutil/dump.c b/src/kadmin/dbutil/dump.c index 8fcb56e5a..ee45464b6 100644 --- a/src/kadmin/dbutil/dump.c +++ b/src/kadmin/dbutil/dump.c @@ -1091,7 +1091,6 @@ dump_db(argc, argv) { FILE *f; struct dump_args arglist; - char *programname; char *ofile; krb5_error_code kret, retval; dump_version *dump; @@ -1105,9 +1104,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; @@ -1175,7 +1171,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; } @@ -1193,7 +1189,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); } @@ -1201,7 +1197,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); } @@ -1218,7 +1214,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); } } @@ -1244,7 +1240,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; } @@ -1252,7 +1248,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 @@ -1261,7 +1257,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); @@ -1270,7 +1266,7 @@ dump_db(argc, argv) if (ulog_map(util_context, global_params.iprop_logfile, global_params.iprop_ulogsize, FKCOMMAND, db_args)) { fprintf(stderr, - _("%s: Could not map log\n"), programname); + _("%s: Could not map log\n"), progname); exit_status++; goto unlock_and_return; } @@ -1281,7 +1277,7 @@ dump_db(argc, argv) */ if (krb5_db_lock(util_context, KRB5_LOCKMODE_SHARED)) { fprintf(stderr, - _("%s: Couldn't grab lock\n"), programname); + _("%s: Couldn't grab lock\n"), progname); exit_status++; goto unlock_and_return; } @@ -1299,7 +1295,7 @@ 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_sno) (void) krb5_db_unlock(util_context); @@ -1307,7 +1303,7 @@ dump_db(argc, argv) 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++; } @@ -2249,7 +2245,6 @@ load_db(argc, argv) FILE *f; extern char *optarg; extern int optind; - char *programname; char *dumpfile; char *dbname; char *dbname_tmp; @@ -2267,9 +2262,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; @@ -2318,7 +2310,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; } @@ -2329,7 +2321,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; @@ -2337,7 +2329,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; @@ -2351,14 +2343,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; @@ -2374,7 +2366,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; @@ -2393,7 +2385,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; @@ -2401,7 +2393,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; } @@ -2418,7 +2410,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; @@ -2442,11 +2434,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); @@ -2467,11 +2459,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; @@ -2490,7 +2482,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; } @@ -2507,7 +2499,7 @@ load_db(argc, argv) if (ulog_map(kcontext, global_params.iprop_logfile, global_params.iprop_ulogsize, caller, db5util_db_args)) { fprintf(stderr, _("%s: Could not map log\n"), - programname); + progname); exit_status++; goto error; } @@ -2545,10 +2537,10 @@ load_db(argc, argv) } } - 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++; } @@ -2561,14 +2553,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 @@ -2583,7 +2575,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++; } } @@ -2604,7 +2596,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++; } } diff --git a/src/kadmin/dbutil/kdb5_create.c b/src/kadmin/dbutil/kdb5_create.c index b8959e102..eaeade163 100644 --- a/src/kadmin/dbutil/kdb5_create.c +++ b/src/kadmin/dbutil/kdb5_create.c @@ -167,9 +167,6 @@ void kdb5_create(argc, argv) krb5_data pwd, seed; kdb_log_context *log_ctx; - if (strrchr(argv[0], '/')) - argv[0] = strrchr(argv[0], '/')+1; - while ((optchar = getopt(argc, argv, "s")) != -1) { switch(optchar) { case 's': @@ -200,7 +197,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; } @@ -210,7 +207,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; } @@ -236,7 +233,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; @@ -246,14 +243,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; } @@ -263,21 +260,21 @@ 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; */ /* } */ @@ -314,7 +311,7 @@ master key name '%s'\n", 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; } /* @@ -328,7 +325,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 */ diff --git a/src/kadmin/dbutil/kdb5_destroy.c b/src/kadmin/dbutil/kdb5_destroy.c index 160268f24..9640286ae 100644 --- a/src/kadmin/dbutil/kdb5_destroy.c +++ b/src/kadmin/dbutil/kdb5_destroy.c @@ -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; } diff --git a/src/kadmin/dbutil/kdb5_stash.c b/src/kadmin/dbutil/kdb5_stash.c index 7e8fd3e8b..a34aa132a 100644 --- a/src/kadmin/dbutil/kdb5_stash.c +++ b/src/kadmin/dbutil/kdb5_stash.c @@ -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; } diff --git a/src/kadmin/dbutil/kdb5_util.c b/src/kadmin/dbutil/kdb5_util.c index 7da89c8f5..cfc3d0821 100644 --- a/src/kadmin/dbutil/kdb5_util.c +++ b/src/kadmin/dbutil/kdb5_util.c @@ -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); } @@ -341,13 +341,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; } @@ -360,7 +360,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 @@ -432,6 +432,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); } @@ -449,6 +450,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); @@ -526,7 +528,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; diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c index f75819a14..972176cf2 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c @@ -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; diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c index 4a64143de..eb20a28ed 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c @@ -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/' ... */ 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 = util_context->dal_handle; 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; } diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c index f892e9659..e2c799a89 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c @@ -204,7 +204,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; @@ -502,7 +502,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; @@ -575,7 +575,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; } @@ -1067,7 +1067,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; @@ -1182,7 +1182,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; } @@ -1195,7 +1195,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; } @@ -1226,7 +1226,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; } @@ -1234,7 +1234,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; } @@ -1242,7 +1242,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; } @@ -1302,13 +1302,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; } @@ -1345,7 +1345,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; @@ -1526,7 +1526,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; @@ -1910,7 +1910,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]; diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c index e2776b985..704bb163e 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c @@ -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; } diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.h b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.h index f2c49a57e..a2b3bb802 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.h +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.h @@ -58,6 +58,8 @@ #define DESTROY_POLICY 14 #define LIST_POLICY 15 +extern char *progname; + extern int exit_status; extern krb5_context util_context; -- 2.26.2