diff options
author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2009-04-02 16:27:47 -0400 |
---|---|---|
committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2009-04-02 16:27:47 -0400 |
commit | d35c014630633a3548d3ebc9a4dd3ea6993ec265 (patch) | |
tree | 0936c65fa3809c54d5377ac5fb8bfa7a89ccd4b3 | |
parent | 318d43b46c3546bc9dac7be343ec4858ce0007ad (diff) | |
download | credmonger-d35c014630633a3548d3ebc9a4dd3ea6993ec265.tar.gz credmonger-d35c014630633a3548d3ebc9a4dd3ea6993ec265.tar.xz credmonger-d35c014630633a3548d3ebc9a4dd3ea6993ec265.zip |
- add an autogen script
- catch SIGHUP for reload correctly
- use killproc correctly for reloading
-rwxr-xr-x | autogen.maint | 7 | ||||
-rw-r--r-- | src/credmonger.c | 38 | ||||
-rwxr-xr-x | src/credmonger.init | 2 |
3 files changed, 33 insertions, 14 deletions
diff --git a/autogen.maint b/autogen.maint new file mode 100755 index 0000000..4700714 --- /dev/null +++ b/autogen.maint @@ -0,0 +1,7 @@ +#!/bin/bash +autoreconf -i -f +case `uname -i` in +x86_64|sparc64|s390x) lib=lib64;; +*) lib=lib;; +esac +eval "`rpm --eval '%configure'`" diff --git a/src/credmonger.c b/src/credmonger.c index 4bef2ca..aff8c40 100644 --- a/src/credmonger.c +++ b/src/credmonger.c @@ -59,6 +59,8 @@ static struct monger_entry { krb5_timestamp when; /* When the creds in the ccache expire. */ } **entries, **cleanup; +/* Time to reload. */ +static int reload = 0; /* Time to exit. */ static int quit = 0; @@ -568,6 +570,12 @@ entries_waittime(void) } static void +setreload(int signum) +{ + reload++; +} + +static void setquit(int signum) { quit++; @@ -604,12 +612,14 @@ main(int argc, char **argv) } } + /* Load the configuration. */ entries = entries_read(); if (entries == NULL) { log_err(LOG_ERR, "nothing configured\n"); return 1; } + /* Go background. */ if (!nofork) { if (daemon(0, 0) != 0) { log_err(LOG_ERR, "error going to background: %s\n", @@ -618,34 +628,36 @@ main(int argc, char **argv) } } + /* Write the pidfile. */ fp = fopen(pidfile, "w"); if (fp != NULL) { fprintf(fp, "%lu\n", (long unsigned) (getpid())); fclose(fp); } - signal(SIGINT, setquit); - signal(SIGQUIT, setquit); - - /* Make sure we initialize the first time through. */ - howlong = 0; + /* Make sure we don't reinitialize the first time through. */ + reload = 0; while (quit == 0) { /* Either (re-)initialize, or don't. */ - if (howlong == 0) { - /* Normal. */ - entries_poll(); - } else { + if (reload) { /* Load or reload configuration. */ + reload = 0; entries_reload(); - } - /* If there are no entries, bail. */ - if (entries == NULL) { - break; + /* If there are no entries now, bail. */ + if (entries == NULL) { + break; + } + } else { + /* Just run through the entries. */ + entries_poll(); } /* Figure out how long to wait. */ howlong = entries_waittime(); log_err(LOG_DEBUG, "waiting for %ld seconds\n", (long) howlong); + signal(SIGHUP, setreload); + signal(SIGINT, setquit); + signal(SIGQUIT, setquit); howlong = sleep(howlong); }; /* Clean up. */ diff --git a/src/credmonger.init b/src/credmonger.init index 0dd5626..1ecba09 100755 --- a/src/credmonger.init +++ b/src/credmonger.init @@ -83,7 +83,7 @@ case "$1" in force-reload | reload) echo -n $"Reloading $prog: " RETVAL=0 - killproc -HUP /usr/sbin/$prog + killproc /usr/sbin/$prog -HUP echo ;; *) |