summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-kpasswd/ipa_kpasswd.c
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-02-06 11:02:05 -0500
committerRob Crittenden <rcritten@redhat.com>2008-02-06 11:02:05 -0500
commit217019e9de5b72f661c091cc57bc6752c7dc7d14 (patch)
treee48fb3356ea15115df836886ec084d7af9be2a5f /ipa-server/ipa-kpasswd/ipa_kpasswd.c
parentef5b4391debe6b053ea8bea60b0caa7721a09122 (diff)
downloadfreeipa-217019e9de5b72f661c091cc57bc6752c7dc7d14.tar.gz
freeipa-217019e9de5b72f661c091cc57bc6752c7dc7d14.tar.xz
freeipa-217019e9de5b72f661c091cc57bc6752c7dc7d14.zip
Create /var/run/<process>.pid to play nicers with the start scripts
Need to start ipa_webgui as root and drop privs in order to write in /var/run
Diffstat (limited to 'ipa-server/ipa-kpasswd/ipa_kpasswd.c')
-rw-r--r--ipa-server/ipa-kpasswd/ipa_kpasswd.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/ipa-server/ipa-kpasswd/ipa_kpasswd.c b/ipa-server/ipa-kpasswd/ipa_kpasswd.c
index ccd17c1f0..0bca8cf35 100644
--- a/ipa-server/ipa-kpasswd/ipa_kpasswd.c
+++ b/ipa-server/ipa-kpasswd/ipa_kpasswd.c
@@ -1110,7 +1110,7 @@ int main(int argc, char *argv[])
/* do not keep any fs busy */
ret = chdir("/");
if (ret == -1) {
- syslog(LOG_ERR, "Unable to chage dir to '/'");
+ syslog(LOG_ERR, "Unable to change dir to '/'");
exit(-1);
}
@@ -1126,8 +1126,8 @@ int main(int argc, char *argv[])
/* new session */
setsid();
- /* close std* descriptors */
+ /* close std* descriptors */
close(0);
close(1);
close(2);
@@ -1142,7 +1142,7 @@ int main(int argc, char *argv[])
exit(0);
}
- /* source evn vars */
+ /* source env vars */
env = getenv("KRB5_KTNAME");
if (!env) {
env = DEFAULT_KEYTAB;
@@ -1167,6 +1167,16 @@ int main(int argc, char *argv[])
exit(1);
}
+ /* Write out the pid file after the sigterm handler */
+ FILE *f = fopen("/var/run/ipa_kpasswd.pid", "w");
+ if (f == NULL) {
+ syslog(LOG_ERR,"Couldn't create pid file /var/run/ipa_kpasswd.pid: %s", strerror(errno));
+ exit(1);
+ } else {
+ fprintf(f, "%ld\n", (long) getpid());
+ fclose(f);
+ }
+
tai = ai;
nfds = 0;
/* we can have a maximum of 4 sockets (IPv4/IPv6(TCP/UDP)) */