summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2009-04-01 23:28:23 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2009-04-01 23:28:23 -0400
commit982ac3633f70287774eef35e5e6025de7dff4728 (patch)
tree1c7d0278629e31645594cedc5182287e7053b777
parentfbd30db62f00fb7cf9af523549499961d4bb9d2d (diff)
downloadcredmonger-982ac3633f70287774eef35e5e6025de7dff4728.tar.gz
credmonger-982ac3633f70287774eef35e5e6025de7dff4728.tar.xz
credmonger-982ac3633f70287774eef35e5e6025de7dff4728.zip
- tweak some error messages
-rw-r--r--src/credmonger.c75
1 files changed, 40 insertions, 35 deletions
diff --git a/src/credmonger.c b/src/credmonger.c
index 05ca150..bbd05e8 100644
--- a/src/credmonger.c
+++ b/src/credmonger.c
@@ -91,7 +91,7 @@ entries_read(void)
keytab = strchr(uids, ':');
if (keytab == NULL) {
fprintf(stderr,
- "No keytab name field.\n");
+ "no keytab name field\n");
continue;
}
*keytab++ = '\0';
@@ -100,7 +100,7 @@ entries_read(void)
principal = strchr(keytab, ':');
if (principal == NULL) {
fprintf(stderr,
- "No principal name field.\n");
+ "no principal name field\n");
continue;
}
*principal++ = '\0';
@@ -126,8 +126,8 @@ entries_read(void)
gid = pwd->pw_gid;
} else {
fprintf(stderr,
- "Unknown user "
- "\"%s\".\n", uids);
+ "unknown user "
+ "\"%s\"\n", uids);
continue;
}
} else {
@@ -137,7 +137,7 @@ entries_read(void)
gid = pwd->pw_gid;
} else {
fprintf(stderr,
- "Unknown user %lu.\n",
+ "unknown user %lu\n",
(unsigned long) uid);
continue;
}
@@ -173,14 +173,14 @@ entries_read(void)
tmp = realloc(list,
sizeof(*list) * (n_entries + 2));
if (tmp == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ fprintf(stderr, "out of memory\n");
break;
}
list = tmp;
/* Allocate this entry. */
list[n_entries] = malloc(sizeof(**list));
if (list[n_entries] == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ fprintf(stderr, "out of memory\n");
break;
}
entry = list[n_entries];
@@ -193,18 +193,18 @@ entries_read(void)
entry->gid = gid;
entry->keytab = strdup(keytab);
if (entry->keytab == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ fprintf(stderr, "out of memory\n");
break;
}
entry->principal_name = strdup(principal);
if (entry->principal_name == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ fprintf(stderr, "out of memory\n");
break;
}
entry->fccache_pattern =
strdup(fccache_pattern);
if (entry->fccache_pattern == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ fprintf(stderr, "out of memory\n");
break;
}
}
@@ -232,14 +232,16 @@ entries_poll(void)
/* Figure out the client hostname. */
memset(host, '\0', sizeof(host));
if (gethostname(host, sizeof(host) - 1) != 0) {
- fprintf(stderr, "Error determining hostname.\n");
+ fprintf(stderr, "error determining hostname: %s\n",
+ strerror(errno));
snprintf(host, sizeof(host), "localhost");
}
ctx = NULL;
gic_opts = NULL;
- if (krb5_init_context(&ctx) != 0) {
- fprintf(stderr, "Error initializing Kerberos.\n");
+ if ((i = krb5_init_context(&ctx)) != 0) {
+ fprintf(stderr, "error initializing Kerberos: %s\n",
+ error_message(i));
} else {
/* Initialize the get_init_creds options. */
if (krb5_get_init_creds_opt_alloc(ctx, &gic_opts) != 0) {
@@ -251,9 +253,11 @@ entries_poll(void)
/* Walk the list of entries. */
for (i = 0; (entries != NULL) && (entries[i] != NULL); i++) {
fprintf(stderr,
- "uid=%ld,keytab=%s,client=%s,ccache=%s\n",
+ "[uid=%ld, keytab=%s, client=%s, ccache=%s]\n",
(unsigned long) entries[i]->uid,
- entries[i]->keytab,
+ entries[i]->keytab &&
+ strlen(entries[i]->keytab) ?
+ entries[i]->keytab : "<default>",
entries[i]->principal_name,
entries[i]->fccache_pattern);
/* Open the keytab. */
@@ -266,7 +270,7 @@ entries_poll(void)
&keytab);
}
if (ret != 0) {
- fprintf(stderr, "Error resolving keytab: %s.\n",
+ fprintf(stderr, "error resolving keytab: %s\n",
error_message(ret));
continue;
}
@@ -278,7 +282,7 @@ entries_poll(void)
(entries[i]->principal_name[len - 1] == '/')) {
principal_name = malloc(len + strlen(host) + 1);
if (principal_name == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ fprintf(stderr, "out of memory\n");
krb5_kt_close(ctx, keytab);
continue;
}
@@ -288,15 +292,15 @@ entries_poll(void)
} else {
principal_name = strdup(entries[i]->principal_name);
if (principal_name == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ fprintf(stderr, "out of memory\n");
krb5_kt_close(ctx, keytab);
continue;
}
}
ret = krb5_parse_name(ctx, principal_name, &client);
if (ret != 0) {
- fprintf(stderr, "Error parsing client \"%s\": "
- "%s.\n", principal_name,
+ fprintf(stderr, "error parsing client \"%s\": "
+ "%s\n", principal_name,
error_message(ret));
free(principal_name);
krb5_kt_close(ctx, keytab);
@@ -307,7 +311,7 @@ entries_poll(void)
principal_name = NULL;
ret = krb5_unparse_name(ctx, client, &principal_name);
if (ret != 0) {
- fprintf(stderr, "Error unparsing name: %s.\n",
+ fprintf(stderr, "error unparsing name: %s\n",
error_message(ret));
krb5_kt_close(ctx, keytab);
krb5_free_principal(ctx, client);
@@ -319,8 +323,8 @@ entries_poll(void)
keytab, 0, NULL,
gic_opts);
if (ret != 0) {
- fprintf(stderr, "Error getting creds for %s: "
- "%s.\n", principal_name,
+ fprintf(stderr, "error getting creds for %s: "
+ "%s\n", principal_name,
error_message(ret));
krb5_kt_close(ctx, keytab);
krb5_free_unparsed_name(ctx, principal_name);
@@ -343,8 +347,8 @@ entries_poll(void)
fd = mkstemp(fccache + strlen(FCC_PREFIX));
}
if (fd == -1) {
- fprintf(stderr, "Error creating temporary "
- "ccache.\n");
+ fprintf(stderr, "error creating temporary "
+ "ccache\n");
krb5_free_cred_contents(ctx, &creds);
krb5_kt_close(ctx, keytab);
krb5_free_unparsed_name(ctx, principal_name);
@@ -356,8 +360,8 @@ entries_poll(void)
ccache = NULL;
ret = krb5_cc_resolve(ctx, fccache, &ccache);
if (ret != 0) {
- fprintf(stderr, "Error opening temporary "
- "ccache: %s.\n", error_message(ret));
+ fprintf(stderr, "error opening temporary "
+ "ccache: %s\n", error_message(ret));
unlink(fccache + strlen(FCC_PREFIX));
krb5_free_cred_contents(ctx, &creds);
krb5_kt_close(ctx, keytab);
@@ -368,8 +372,8 @@ entries_poll(void)
/* Write the client's name to the ccache. */
ret = krb5_cc_initialize(ctx, ccache, client);
if (ret != 0) {
- fprintf(stderr, "Error initializing temporary "
- "ccache: %s.\n", error_message(ret));
+ fprintf(stderr, "error initializing temporary "
+ "ccache: %s\n", error_message(ret));
krb5_cc_close(ctx, ccache);
unlink(fccache + strlen(FCC_PREFIX));
krb5_free_cred_contents(ctx, &creds);
@@ -381,7 +385,7 @@ entries_poll(void)
/* Store the TGT. */
ret = krb5_cc_store_cred(ctx, ccache, &creds);
if (ret != 0) {
- fprintf(stderr, "Error storing creds: %s.\n",
+ fprintf(stderr, "error storing creds: %s\n",
error_message(ret));
krb5_cc_close(ctx, ccache);
unlink(fccache + strlen(FCC_PREFIX));
@@ -427,7 +431,7 @@ entries_poll(void)
entries[i]->when = creds.times.endtime;
}
}
- fprintf(stderr, "Saved creds for \"%s\" to \"%s\".\n",
+ fprintf(stderr, "saved creds for \"%s\" to \"%s\"\n",
principal_name, entries[i]->fccache);
krb5_free_cred_contents(ctx, &creds);
krb5_kt_close(ctx, keytab);
@@ -453,7 +457,7 @@ entries_poll(void)
}
}
if ((entries == NULL) || (entries[j] == NULL)) {
- fprintf(stderr, "Removing \"%s\".\n",
+ fprintf(stderr, "removing \"%s\"\n",
cleanup[i]->fccache);
unlink(cleanup[i]->fccache +
strlen(FCC_PREFIX));
@@ -550,7 +554,7 @@ main(int argc, char **argv)
entries = entries_read();
if (entries == NULL) {
- fprintf(stderr, "Nothing configured.\n");
+ fprintf(stderr, "nothing configured\n");
}
if (!nofork) {
@@ -583,13 +587,14 @@ main(int argc, char **argv)
}
/* Figure out how long to wait. */
howlong = entries_waittime();
- fprintf(stderr, "Waiting for %ld seconds.\n", (long) howlong);
+ fprintf(stderr, "= waiting for %ld seconds =\n",
+ (long) howlong);
howlong = sleep(howlong);
};
/* Clean up. */
entries_unload();
if (pidfile != NULL) {
- fprintf(stderr, "Removing \"%s\".\n", pidfile);
+ fprintf(stderr, "removing \"%s\"\n", pidfile);
unlink(pidfile);
}
return 0;