forked from pool/openssh
27 lines
893 B
Diff
27 lines
893 B
Diff
|
# HG changeset patch
|
||
|
# Parent bad0c8b3b8d72abb6960ed85b57ee42352371738
|
||
|
Do not write a PID file when not daemonizing (e.g. when running from systemd)
|
||
|
|
||
|
diff --git a/openssh-7.7p1/sshd.c b/openssh-7.7p1/sshd.c
|
||
|
--- openssh-7.7p1/sshd.c
|
||
|
+++ openssh-7.7p1/sshd.c
|
||
|
@@ -1996,17 +1996,17 @@ main(int ac, char **av)
|
||
|
signal(SIGCHLD, main_sigchld_handler);
|
||
|
signal(SIGTERM, sigterm_handler);
|
||
|
signal(SIGQUIT, sigterm_handler);
|
||
|
|
||
|
/*
|
||
|
* Write out the pid file after the sigterm handler
|
||
|
* is setup and the listen sockets are bound
|
||
|
*/
|
||
|
- if (options.pid_file != NULL && !debug_flag) {
|
||
|
+ if (!no_daemon_flag && options.pid_file != NULL && !debug_flag) {
|
||
|
FILE *f = fopen(options.pid_file, "w");
|
||
|
|
||
|
if (f == NULL) {
|
||
|
error("Couldn't create pid file \"%s\": %s",
|
||
|
options.pid_file, strerror(errno));
|
||
|
} else {
|
||
|
fprintf(f, "%ld\n", (long) getpid());
|
||
|
fclose(f);
|