Bugzilla – Attachment 2097 Details for
Bug 1942
mounting home directory with sshfs -o reconnect requires patch for ssh
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to add the option "-H path_to_per-user_configdir" to ssh
openssh_option-H.patch (text/plain), 6.21 KB, created by
e.kuemmerle
on 2011-10-11 21:40:49 AEDT
(
hide
)
Description:
Patch to add the option "-H path_to_per-user_configdir" to ssh
Filename:
MIME Type:
Creator:
e.kuemmerle
Created:
2011-10-11 21:40:49 AEDT
Size:
6.21 KB
patch
obsolete
>diff -rupN openssh-5.8p1/pathnames.h openssh-5.8p1_mod/pathnames.h >--- openssh-5.8p1/pathnames.h 2010-08-31 14:41:14.000000000 +0200 >+++ openssh-5.8p1_mod/pathnames.h 2011-10-10 16:08:20.322792320 +0200 >@@ -65,8 +65,10 @@ > * readable by anyone except the user him/herself, though this does not > * contain anything particularly secret. > */ >+#define _PA_SSH_USER_HOSTFILE ".ssh/known_hosts" > #define _PATH_SSH_USER_HOSTFILE "~/.ssh/known_hosts" > /* backward compat for protocol 2 */ >+#define _PA_SSH_USER_HOSTFILE2 ".ssh/known_hosts2" > #define _PATH_SSH_USER_HOSTFILE2 "~/.ssh/known_hosts2" > > /* >diff -rupN openssh-5.8p1/readconf.c openssh-5.8p1_mod/readconf.c >--- openssh-5.8p1/readconf.c 2010-11-20 05:19:38.000000000 +0100 >+++ openssh-5.8p1_mod/readconf.c 2011-10-11 11:14:14.430288988 +0200 >@@ -249,6 +249,11 @@ static struct { > { NULL, oBadOption } > }; > >+/* optional path to be used instead of user's HOME directory >+ * to search for the per-user configuration directory .ssh >+*/ >+char *path_instead_pwdir = NULL; >+ > /* > * Adds a local TCP/IP port forward to options. Never returns if there is an > * error. >@@ -1232,32 +1237,34 @@ fill_default_options(Options * options) > /* options->hostkeyalgorithms, default set in myproposals.h */ > if (options->protocol == SSH_PROTO_UNKNOWN) > options->protocol = SSH_PROTO_2; >+ char *home = path_instead_pwdir; >+ if (NULL == home) home = "~"; > if (options->num_identity_files == 0) { > if (options->protocol & SSH_PROTO_1) { >- len = 2 + strlen(_PATH_SSH_CLIENT_IDENTITY) + 1; >+ len = strlen(home) + 1 + strlen(_PATH_SSH_CLIENT_IDENTITY) + 1; > options->identity_files[options->num_identity_files] = > xmalloc(len); > snprintf(options->identity_files[options->num_identity_files++], >- len, "~/%.100s", _PATH_SSH_CLIENT_IDENTITY); >+ len, "%s/%.100s", home , _PATH_SSH_CLIENT_IDENTITY); > } > if (options->protocol & SSH_PROTO_2) { >- len = 2 + strlen(_PATH_SSH_CLIENT_ID_RSA) + 1; >+ len = strlen(home) + 1 + strlen(_PATH_SSH_CLIENT_ID_RSA) + 1; > options->identity_files[options->num_identity_files] = > xmalloc(len); > snprintf(options->identity_files[options->num_identity_files++], >- len, "~/%.100s", _PATH_SSH_CLIENT_ID_RSA); >+ len, "%s/%.100s", home , _PATH_SSH_CLIENT_ID_RSA); > >- len = 2 + strlen(_PATH_SSH_CLIENT_ID_DSA) + 1; >+ len = strlen(home) + 1 + strlen(_PATH_SSH_CLIENT_ID_DSA) + 1; > options->identity_files[options->num_identity_files] = > xmalloc(len); > snprintf(options->identity_files[options->num_identity_files++], >- len, "~/%.100s", _PATH_SSH_CLIENT_ID_DSA); >+ len, "%s/%.100s", home , _PATH_SSH_CLIENT_ID_DSA); > #ifdef OPENSSL_HAS_ECC >- len = 2 + strlen(_PATH_SSH_CLIENT_ID_ECDSA) + 1; >+ len = strlen(home) + 1 + strlen(_PATH_SSH_CLIENT_ID_ECDSA) + 1; > options->identity_files[options->num_identity_files] = > xmalloc(len); > snprintf(options->identity_files[options->num_identity_files++], >- len, "~/%.100s", _PATH_SSH_CLIENT_ID_ECDSA); >+ len, "%s/%.100s", home , _PATH_SSH_CLIENT_ID_ECDSA); > #endif > } > } >@@ -1265,12 +1272,20 @@ fill_default_options(Options * options) > options->escape_char = '~'; > if (options->system_hostfile == NULL) > options->system_hostfile = _PATH_SSH_SYSTEM_HOSTFILE; >- if (options->user_hostfile == NULL) >- options->user_hostfile = _PATH_SSH_USER_HOSTFILE; >+ if (options->user_hostfile == NULL) { >+ len = strlen(home) + 1 + strlen(_PA_SSH_USER_HOSTFILE) + 1; >+ options->user_hostfile = xmalloc(len); >+ snprintf(options->user_hostfile, >+ len, "%s/%.100s", home , _PA_SSH_USER_HOSTFILE); >+ } > if (options->system_hostfile2 == NULL) > options->system_hostfile2 = _PATH_SSH_SYSTEM_HOSTFILE2; >- if (options->user_hostfile2 == NULL) >- options->user_hostfile2 = _PATH_SSH_USER_HOSTFILE2; >+ if (options->user_hostfile2 == NULL) { >+ len = strlen(home) + 1 + strlen(_PA_SSH_USER_HOSTFILE2) + 1; >+ options->user_hostfile2 = xmalloc(len); >+ snprintf(options->user_hostfile2, >+ len, "%s/%.100s", home , _PA_SSH_USER_HOSTFILE2); >+ } > if (options->log_level == SYSLOG_LEVEL_NOT_SET) > options->log_level = SYSLOG_LEVEL_INFO; > if (options->clear_forwardings == 1) >diff -rupN openssh-5.8p1/ssh.c openssh-5.8p1_mod/ssh.c >--- openssh-5.8p1/ssh.c 2011-02-04 01:42:15.000000000 +0100 >+++ openssh-5.8p1_mod/ssh.c 2011-10-11 11:17:48.438465410 +0200 >@@ -157,6 +157,11 @@ Options options; > /* optional user configfile */ > char *config = NULL; > >+/* optional path to be used instead of user's HOME directory >+ * to search for the per-user configuration directory .ssh >+*/ >+extern char *path_instead_pwdir; >+ > /* > * Name of the host we are connecting to. This is the name given on the > * command line, or the HostName specified for the user-supplied name in a >@@ -196,6 +201,7 @@ usage(void) > "usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]\n" > " [-D [bind_address:]port] [-e escape_char] [-F configfile]\n" > " [-I pkcs11] [-i identity_file]\n" >+" [-H path_to_per-user_configdir]\n" > " [-L [bind_address:]port:host:hostport]\n" > " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" > " [-R [bind_address:]port:host:hostport] [-S ctl_path]\n" >@@ -296,7 +302,7 @@ main(int ac, char **av) > argv0 = av[0]; > > again: >- while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" >+ while ((opt = getopt(ac, av, "1246ab:c:e:fgH:i:kl:m:no:p:qstvx" > "ACD:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) { > switch (opt) { > case '1': >@@ -568,11 +574,19 @@ main(int ac, char **av) > case 'F': > config = optarg; > break; >+ case 'H': >+ path_instead_pwdir = optarg; >+ break; > default: > usage(); > } > } > >+ if (path_instead_pwdir) { >+ xfree(pw->pw_dir); >+ pw->pw_dir = xstrdup(path_instead_pwdir); >+ } >+ > ac -= optind; > av += optind; > >@@ -1484,7 +1498,11 @@ load_public_identity_files(void) > if ((pw = getpwuid(original_real_uid)) == NULL) > fatal("load_public_identity_files: getpwuid failed"); > pwname = xstrdup(pw->pw_name); >- pwdir = xstrdup(pw->pw_dir); >+ if (path_instead_pwdir) { >+ pwdir = xstrdup(path_instead_pwdir); >+ } else { >+ pwdir = xstrdup(pw->pw_dir); >+ } > if (gethostname(thishost, sizeof(thishost)) == -1) > fatal("load_public_identity_files: gethostname: %s", > strerror(errno));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1942
: 2097 |
2099