Bug#303452: -o PidFile patch update
I discovered that the previous patch didn't allow the option value to contain
a space. This new patch does(based on ProxyCommand).
diff -u openssh-3.9p1/readconf.c openssh-3.9p1/readconf.c
--- openssh-3.9p1/readconf.c
+++ openssh-3.9p1/readconf.c
@@ -107,7 +107,7 @@
oAddressFamily, oGssAuthentication, oGssDelegateCreds,
oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
oSendEnv, oControlPath, oControlMaster,
- oProtocolKeepAlives, oSetupTimeOut,
+ oProtocolKeepAlives, oSetupTimeOut, oPidFile,
oDeprecated, oUnsupported
} OpCodes;
@@ -200,6 +200,7 @@
{ "controlmaster", oControlMaster },
{ "protocolkeepalives", oProtocolKeepAlives },
{ "setuptimeout", oSetupTimeOut },
+ { "pidfile", oPidFile },
{ NULL, oBadOption }
};
@@ -782,6 +783,15 @@
intptr = &options->setuptimeout;
goto parse_int;
+ case oPidFile:
+ if (s == NULL)
+ fatal("%.200s line %d: Missing argument.", filename, linenum);
+ charptr = &options->pidfile;
+ len = strspn(s, WHITESPACE "=");
+ if (*activep && *charptr == NULL)
+ *charptr = xstrdup(s + len);
+ return 0;
+
case oDeprecated:
debug("%s line %d: Deprecated option \"%s\"",
filename, linenum, keyword);
@@ -926,6 +936,7 @@
options->num_send_env = 0;
options->control_path = NULL;
options->control_master = -1;
+ options->pidfile = NULL;
}
/*
diff -u openssh-3.9p1/readconf.h openssh-3.9p1/readconf.h
--- openssh-3.9p1/readconf.h
+++ openssh-3.9p1/readconf.h
@@ -112,6 +112,7 @@
char *control_path;
int control_master;
+ char *pidfile;
} Options;
diff -u openssh-3.9p1/ssh.1 openssh-3.9p1/ssh.1
--- openssh-3.9p1/ssh.1
+++ openssh-3.9p1/ssh.1
@@ -694,6 +694,7 @@
.It NoHostAuthenticationForLocalhost
.It NumberOfPasswordPrompts
.It PasswordAuthentication
+.It PidFile
.It Port
.It PreferredAuthentications
.It Protocol
diff -u openssh-3.9p1/ssh.c openssh-3.9p1/ssh.c
--- openssh-3.9p1/ssh.c
+++ openssh-3.9p1/ssh.c
@@ -870,6 +870,21 @@
}
}
+static void
+make_pidfile()
+{
+ /* Create pid file as requested. */
+ if (options.pidfile) {
+ FILE *pidfile = fopen(options.pidfile, "w");
+ if (!pidfile)
+ fatal("open pidfile failed: %.200s", strerror(errno));
+ if (fprintf(pidfile, "%i", getpid()) < 0)
+ fatal("write pidfile failed: %.200s", strerror(errno));
+ if (fclose(pidfile))
+ fatal("close pidfile failed: %.200s", strerror(errno));
+ }
+}
+
static int
ssh_session(void)
{
@@ -1002,6 +1017,8 @@
packet_write_wait();
}
+ make_pidfile();
+
/* Enter the interactive session. */
return client_loop(have_tty, tty_flag ?
options.escape_char : SSH_ESCAPECHAR_NONE, 0);
@@ -1173,6 +1190,8 @@
if (daemon(1, 1) < 0)
fatal("daemon() failed: %.200s", strerror(errno));
+ make_pidfile();
+
return client_loop(tty_flag, tty_flag ?
options.escape_char : SSH_ESCAPECHAR_NONE, id);
}
diff -u openssh-3.9p1/ssh_config.5 openssh-3.9p1/ssh_config.5
--- openssh-3.9p1/ssh_config.5
+++ openssh-3.9p1/ssh_config.5
@@ -523,6 +523,8 @@
.Dq no .
The default is
.Dq yes .
+.It Cm PidFile
+Specifies a file to write the pid of the process to.
.It Cm Port
Specifies the port number to connect on the remote host.
Default is 22.
diff -u openssh-3.9p1/debian/changelog openssh-3.9p1/debian/changelog
--- openssh-3.9p1/debian/changelog
+++ openssh-3.9p1/debian/changelog
@@ -1,3 +1,10 @@
+openssh (1:3.9p1-3.1) experimental; urgency=low
+
+ * NMU.
+ * Add PidFile option; useful when -f is given.
+
+ -- Adam Heath <doogie@debian.org> Wed, 06 Apr 2005 12:37:30 -0500
+
openssh (1:3.9p1-3) experimental; urgency=low
* Explain how to run sshd from inittab in README.Debian (closes: #147360).
Reply to: