*** kpropd.c.orig 2017-03-02 16:06:02.000000000 -0600 --- kpropd.c 2017-08-22 11:49:05.457023391 -0500 *************** *** 91,96 **** --- 91,97 ---- #define SYSLOG_CLASS LOG_DAEMON int runonce = 0; + static char * pid_file = NULL; /* * This struct simulates the use of _kadm5_server_handle_t *************** *** 141,146 **** --- 142,148 ---- static char **db_args = NULL; static int db_args_size = 0; + static krb5_error_code write_pid_file(const char *path); static void parse_args(char **argv); static void do_standalone(void); static void doit(int fd); *************** *** 169,176 **** fprintf(stderr, _("\nUsage: %s [-r realm] [-s srvtab] [-dS] [-f slave_file]\n"), progname); ! fprintf(stderr, _("\t[-F kerberos_db_file ] [-p kdb5_util_pathname]\n")); ! fprintf(stderr, _("\t[-x db_args]* [-P port] [-a acl_file]\n")); fprintf(stderr, _("\t[-A admin_server]\n")); exit(1); } --- 171,179 ---- fprintf(stderr, _("\nUsage: %s [-r realm] [-s srvtab] [-dS] [-f slave_file]\n"), progname); ! fprintf(stderr, _("\t[-F kerberos_db_file ] [-u kdb5_util_pathname]\n")); ! fprintf(stderr, _("\t[-x db_args]* [-p port] [-a acl_file]\n")); ! fprintf(stderr, _("\t[-P pid_file] (standalone mode only)\n")); fprintf(stderr, _("\t[-A admin_server]\n")); exit(1); } *************** *** 258,263 **** --- 261,273 ---- /* "ready" is a sentinel for the test framework. */ if (!debug && !nodaemon) { daemon(0, 0); + if (pid_file != NULL) { + retval = write_pid_file(pid_file); + if (retval) { + com_err(progname, retval, _("while creating PID file.\n")); + return 1; + } + } } else { printf(_("ready\n")); fflush(stdout); *************** *** 332,337 **** --- 342,362 ---- exit(1); } + static krb5_error_code + write_pid_file(const char *path) + { + FILE *pidfile; + unsigned long pid; + + pidfile = fopen(path, "w"); + if (pidfile == NULL) + return errno; + pid = (unsigned long) getpid(); + if (fprintf(pidfile, "%ld\n", pid) < 0 || fclose(pidfile) == EOF) + return errno; + return 0; + } + /* Use getaddrinfo to determine a wildcard listener address, preferring * IPv6 if available. */ static int *************** *** 1060,1077 **** usage(); word = NULL; break; ! case 'p': kdb5_util = (*word != '\0') ? word : *argv++; if (kdb5_util == NULL) usage(); word = NULL; break; ! case 'P': port = (*word != '\0') ? word : *argv++; if (port == NULL) usage(); word = NULL; break; case 'r': realm = (*word != '\0') ? word : *argv++; if (realm == NULL) --- 1085,1108 ---- usage(); word = NULL; break; ! case 'u': /* was -p, bleech */ kdb5_util = (*word != '\0') ? word : *argv++; if (kdb5_util == NULL) usage(); word = NULL; break; ! case 'p': /* was -P, bleech */ port = (*word != '\0') ? word : *argv++; if (port == NULL) usage(); word = NULL; break; + case 'P': /* now consistent with other pgms */ + pid_file = (*word != '\0') ? word : *argv++; + if (pid_file == NULL) + usage(); + word = NULL; + break; case 'r': realm = (*word != '\0') ? word : *argv++; if (realm == NULL)