{
FILE *f;
struct dump_args arglist;
- char *programname;
char *ofile;
krb5_error_code kret, retval;
dump_version *dump;
/*
* 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;
* 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;
}
(char *) NULL, 0,
&master_keyblock);
if (retval) {
- com_err(argv[0], retval,
+ com_err(progname, retval,
"while reading master key");
exit(1);
}
master_princ,
&master_keyblock);
if (retval) {
- com_err(argv[0], retval,
+ com_err(progname, retval,
"while verifying master key");
exit(1);
}
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);
}
}
unlink(ofile);
if (!(f = fopen(ofile, "w"))) {
fprintf(stderr, ofopen_error,
- programname, ofile, error_message(errno));
+ progname, ofile, error_message(errno));
exit_status++;
return;
}
fileno(f),
KRB5_LOCKMODE_EXCLUSIVE))) {
fprintf(stderr, oflock_error,
- programname, ofile, error_message(kret));
+ progname, ofile, error_message(kret));
exit_status++;
}
else
f = stdout;
}
if (f && !(kret)) {
- arglist.programname = programname;
+ arglist.programname = progname;
arglist.ofile = f;
arglist.kcontext = util_context;
fprintf(arglist.ofile, "%s", dump->header);
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;
}
*/
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;
}
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);
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++;
}
FILE *f;
extern char *optarg;
extern int optind;
- char *programname;
char *dumpfile;
char *dbname;
char *dbname_tmp;
/*
* 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;
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;
}
* 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;
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;
*/
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;
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;
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;
}
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;
}
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;
*/
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);
*/
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;
*/
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;
}
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;
}
}
}
- 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++;
}
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
*/
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++;
}
}
*/
if (kret != 0 && kret != KRB5_PLUGIN_OP_NOTSUPP) {
fprintf(stderr, dbdelerr_fmt,
- programname, dbname, error_message(kret));
+ progname, dbname, error_message(kret));
exit_status++;
}
}
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':
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;
}
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;
}
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;
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;
}
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;
}
/*
&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 */
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;
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;
}
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);
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
}
} 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) {
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);
}
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);
}
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;
}
dbactive = FALSE;
}
- (void) set_dbname_help(argv[0], argv[1]);
+ (void) set_dbname_help(progname, argv[1]);
return;
}
#endif
retval = krb5_principal2salt(util_context, master_princ, &scratch);
if (retval) {
com_err(progname, retval, "while calculated master key salt");
+ exit_status++;
return(1);
}
if (retval) {
com_err(progname, retval,
"while transforming master key from password");
+ exit_status++;
return(1);
}
free(scratch.data);
krb5_int32 num_keysalts = 0;
int free_keysalts;
- char *me = argv[0];
+ char *me = progname;
char *ks_str = NULL;
char *pr_str;
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;
}
}
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;
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;
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;
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;
int argc;
char *argv[];
{
- char *me = argv[0];
+ char *me = progname;
krb5_error_code retval = 0;
krb5_boolean print_usage = FALSE;
char *basedn = NULL;
krb5_boolean no_msg = FALSE;
krb5_boolean print_usage = FALSE;
- char *me = argv[0];
+ char *me = progname;
time(&now);
if (!strcmp(argv[*i], "-maxtktlife")) {
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;
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;
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
/* 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);
/* 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;
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);
/* 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;
}
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;
}
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);
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;
}
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;
}
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;
}
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");
}
}
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++;
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;
}
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;
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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++;
}
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;
}
/* 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;
/* 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 != 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;
}
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;
}
/* 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;
}
/* 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;
}
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;
}
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;
}
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;
}
/* 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;
}
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;
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;
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;
}
char *service_object;
{
int st = EINVAL;
- char *me = argv[0];
+ char *me = progname;
char *tmp_file = NULL;
int tmpfd = -1;
FILE *pfile = NULL;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
int argc;
char *argv[];
{
- char *me = argv[0];
+ char *me = progname;
krb5_error_code retval = 0;
char *basedn = NULL;
char **list = NULL;
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;
{
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];
}
} 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) {
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;
}
}
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;
}
/* 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;
}
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;
}
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;
}
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++;
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;
}
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;
}
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;
}
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);
}
}
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;
}
#define DESTROY_POLICY 14
#define LIST_POLICY 15
+extern char *progname;
+
extern int exit_status;
extern krb5_context util_context;