From fb3644dd06acdce61190ad359bf27330dff32370 Mon Sep 17 00:00:00 2001 From: Geoffrey King Date: Fri, 24 Jul 1998 23:41:43 +0000 Subject: [PATCH] Fork into the background by default, also add a -nofork command line option git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10736 dc483132-0cff-0310-8789-dd5450dbe970 --- src/krb524/ChangeLog | 5 +++++ src/krb524/krb524d.c | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/krb524/ChangeLog b/src/krb524/ChangeLog index 28f0adb80..e68edba1f 100644 --- a/src/krb524/ChangeLog +++ b/src/krb524/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 24 19:38:58 1998 Geoffrey King + + * krb524d.c (main): Fork into the background by default, also + add a -nofork command line option. + Sat Jul 18 22:10:29 1998 Geoffrey King * krb524d.c (main): Remove the variable use_other_realm. diff --git a/src/krb524/krb524d.c b/src/krb524/krb524d.c index e9ab662d1..f72726fff 100644 --- a/src/krb524/krb524d.c +++ b/src/krb524/krb524d.c @@ -57,7 +57,7 @@ krb5_error_code do_connection(), lookup_service_key(), kdc_get_server_key(); void usage(context) krb5_context context; { - fprintf(stderr, "Usage: %s [-k[eytab]] [-m[aster] [-r realm]]\n", whoami); + fprintf(stderr, "Usage: %s [-k[eytab]] [-m[aster] [-r realm]] [-nofork]\n", whoami); cleanup_and_exit(1, context); } @@ -86,7 +86,7 @@ int main(argc, argv) struct servent *serv; struct sockaddr_in saddr; struct timeval timeout; - int ret, s; + int ret, s, nofork; fd_set rfds; krb5_context context; krb5_error_code retval; @@ -101,7 +101,7 @@ int main(argc, argv) whoami = ((whoami = strrchr(argv[0], '/')) ? whoami + 1 : argv[0]); argv++; argc--; - use_master = use_keytab = 0; + use_master = use_keytab = nofork = 0; config_params.mask = 0; while (argc) { @@ -109,6 +109,8 @@ int main(argc, argv) use_keytab = 1; else if (strncmp(*argv, "-m", 2) == 0) use_master = 1; + else if (strcmp(*argv, "-nofork") == 0) + nofork = 1; else if (strcmp(*argv, "-r") == 0) { argv++; argc--; if (argc == 0 || !use_master) @@ -154,6 +156,10 @@ int main(argc, argv) com_err(whoami, errno, "binding main socket"); cleanup_and_exit(1, context); } + if (!nofork && daemon(0, 0)) { + com_err(whoami, errno, "while detaching from tty"); + cleanup_and_exit(1, context); + } while (1) { FD_ZERO(&rfds); -- 2.26.2