ControlPersist.
David Woodhouse
dwmw2 at infradead.org
Thu Jun 23 21:30:45 EST 2005
This is a better approach to persistent control masters than my previous
attempt. Instead of forking before we make the connection, do so only
when the original session has closed -- much like the code for '~&'
backgrounding already does.
My earlier patch for 'ControlPath none' still applies and is required, btw.
--- openssh/clientloop.c~ 2005-06-17 03:59:35.000000000 +0100
+++ openssh/clientloop.c 2005-06-23 11:05:11.000000000 +0100
@@ -1271,8 +1271,28 @@ static void
client_channel_closed(int id, void *arg)
{
channel_cancel_cleanup(id);
- session_closed = 1;
leave_raw_mode();
+ if (options.control_persist && options.control_path != NULL && control_fd != -1) {
+ int pid = fork();
+
+ if (pid < 0) {
+ error("fork: %.100s", strerror(errno));
+ /* Just exit */
+ session_closed = 1;
+ return;
+ }
+ if (pid != 0) {
+ /* We are the parent. Exit, leaving the child to continue serving */
+ exit(exit_status);
+ }
+ session_ident = -1;
+ /* We _must_ lose our controlling tty, else subsequent control_client
+ invocations from the same tty will cause us to get -EIO when reading
+ from the tty */
+ setsid();
+ return;
+ }
+ session_closed = 1;
}
/*
--- openssh/readconf.c~ 2005-06-16 04:19:42.000000000 +0100
+++ openssh/readconf.c 2005-06-23 11:05:11.000000000 +0100
@@ -106,7 +106,7 @@ typedef enum {
oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
oAddressFamily, oGssAuthentication, oGssDelegateCreds,
oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
- oSendEnv, oControlPath, oControlMaster, oHashKnownHosts,
+ oSendEnv, oControlPath, oControlMaster, oControlPersist, oHashKnownHosts,
oDeprecated, oUnsupported
} OpCodes;
@@ -197,6 +197,7 @@ static struct {
{ "sendenv", oSendEnv },
{ "controlpath", oControlPath },
{ "controlmaster", oControlMaster },
+ { "controlpersist", oControlPersist },
{ "hashknownhosts", oHashKnownHosts },
{ NULL, oBadOption }
};
@@ -818,6 +819,10 @@ parse_int:
*intptr = value;
break;
+ case oControlPersist:
+ intptr = &options->control_persist;
+ goto parse_flag;
+
case oHashKnownHosts:
intptr = &options->hash_known_hosts;
goto parse_flag;
--- openssh/readconf.h~ 2005-06-16 04:19:42.000000000 +0100
+++ openssh/readconf.h 2005-06-23 11:02:01.000000000 +0100
@@ -112,6 +112,7 @@ typedef struct {
char *control_path;
int control_master;
+ int control_persist;
int hash_known_hosts;
} Options;
--
dwmw2
More information about the openssh-unix-dev
mailing list