Bugzilla – Attachment 2274 Details for
Bug 1585
Allow an `Include' option which reads another config file in place and does not error out when `Include' file not readable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Include option patch for OpenSSH 6.2
openssh_1585_v6.2.diff (text/plain), 4.60 KB, created by
Christian Kujau
on 2013-05-24 15:08:22 AEST
(
hide
)
Description:
Include option patch for OpenSSH 6.2
Filename:
MIME Type:
Creator:
Christian Kujau
Created:
2013-05-24 15:08:22 AEST
Size:
4.60 KB
patch
obsolete
>--- openssh-cvs.bak/readconf.c 2013-05-22 21:55:40.000000000 -0700 >+++ openssh-cvs/readconf.c 2013-05-23 17:16:21.000000000 -0700 >@@ -134,7 +134,7 @@ typedef enum { > oAddressFamily, oGssAuthentication, oGssDelegateCreds, > oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, > oSendEnv, oControlPath, oControlMaster, oControlPersist, >- oHashKnownHosts, >+ oHashKnownHosts, oInclude, > oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, > oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication, > oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, >@@ -234,6 +234,7 @@ static struct { > { "controlmaster", oControlMaster }, > { "controlpersist", oControlPersist }, > { "hashknownhosts", oHashKnownHosts }, >+ { "include", oInclude }, > { "tunnel", oTunnel }, > { "tunneldevice", oTunnelDevice }, > { "localcommand", oLocalCommand }, >@@ -1029,6 +1030,92 @@ parse_int: > intptr = &options->visual_host_key; > goto parse_flag; > >+ case oInclude: >+ arg = strdelim(&s); >+ if (!arg || *arg == '\0') >+ fatal("%.200s line %d: Missing argument.", filename, linenum); >+ char *newfile = NULL; >+ /* >+ * expand "~/some/file" into "$HOME/some/file" >+ * expand "~username/some/file" into "$HOME/some/file" for >+ * username's $HOME. "~" on its own will not expand >+ */ >+ if (*arg == '~') { >+ if (arg[1] == '/') { >+ /* ~/some/file or ~/ case: */ >+ >+ /* >+ * get passwd entry for uid >+ */ >+ const uid_t uid = getuid(); >+ struct passwd *pwd = getpwuid(uid); >+ if (!pwd) >+ fatal("%.200s line %d: Couldn't get user info for uid \"%ld\": %s", >+ filename, linenum, (const long)(uid), strerror(errno)); >+ >+ if (!pwd->pw_dir) >+ fatal("%.200s line %d: Couldn't expand home directory for \"%s\"", >+ filename, linenum, arg); >+ >+ /* >+ * construct expanded string >+ */ >+ const size_t pwddirlen = strlen(pwd->pw_dir); >+ newfile = (char *)(malloc(pwddirlen + 1 + strlen(arg))); >+ if (!newfile) >+ abort(); >+ strcpy(newfile, pwd->pw_dir); >+ strcpy(newfile + pwddirlen, arg+1); >+ } else if (arg[1] != '\0') { >+ /* ~username/ or ~username case: */ >+ >+ /* >+ * parse username portion >+ */ >+ unsigned int i; >+ for (i = 1; arg[i] != '/' && arg[i] != '\0'; ++i) {} >+ /* allocate for i-1 chars and 1 '\0' terminator */ >+ char *username = (char *)(malloc(i)); >+ if (!username) >+ abort(); >+ memset(username, 0, i); >+ strncpy(username, arg+1, i-1); >+ >+ /* >+ * get passwd entry >+ */ >+ struct passwd *pwd = getpwnam(username); >+ if (!pwd) >+ fatal("%.200s line %d: Couldn't get user info for username \"%s\": %s", >+ filename, linenum, username, strerror(errno)); >+ free(username); >+ >+ if (!pwd->pw_dir) >+ fatal("%.200s line %d: Couldn't expand home directory for \"%s\"", >+ filename, linenum, arg); >+ >+ /* >+ * construct expanded string >+ */ >+ const size_t pwddirlen = strlen(pwd->pw_dir); >+ newfile = (char *)(malloc(pwddirlen + 1 + strlen(arg))); >+ if (!newfile) >+ abort(); >+ strcpy(newfile, pwd->pw_dir); >+ strcpy(newfile + pwddirlen, arg+i); >+ } >+ } >+ int ret; >+ char *readfile = newfile ? newfile : arg; >+ if ((ret = (read_config_file(readfile, host, options, 1) ? 0 : -1)) != 0) >+ error("%s line %d: Error reading Include file \"%s\".", >+ filename, linenum, readfile); >+ if (newfile) >+ free(newfile); >+ if (ret) >+ return ret; >+ break; >+ > case oIPQoS: > arg = strdelim(&s); > if ((value = parse_ipqos(arg)) == -1) >--- openssh-cvs.bak/ssh_config.5 2013-05-22 21:55:45.000000000 -0700 >+++ openssh-cvs/ssh_config.5 2013-05-22 22:46:12.000000000 -0700 >@@ -668,6 +668,28 @@ It is recommended that > .Cm IgnoreUnknown > be listed early in the configuration file as it will not be applied > to unknown options that appear before it. >+.It Cm Include >+Read the specified file as if its contents were pasted here. >+Files of the form >+.Dq ~/path/to/config >+will expand to >+.Dq $HOME/path/to/config >+where >+.Dq $HOME >+is the user's home directoy. >+Files of the form >+.Dq ~username/path/to/config >+will expand to >+.Dq $HOME/path/to/config >+where >+.Dq $HOME >+is >+.Dq username >+\'s home directory. >+A single >+.Dq ~ >+will not expand at all. >+Bad error counts are unique to each configuration file. > .It Cm IPQoS > Specifies the IPv4 type-of-service or DSCP class for connections. > Accepted values are >--- openssh-cvs.bak/ssh.1 2013-05-22 21:55:45.000000000 -0700 >+++ openssh-cvs/ssh.1 2013-05-22 23:00:01.000000000 -0700 >@@ -448,6 +448,7 @@ For full details of the options listed b > .It HostName > .It IdentityFile > .It IdentitiesOnly >+.It Include > .It IPQoS > .It KbdInteractiveAuthentication > .It KbdInteractiveDevices
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 1585
:
1623
|
2274
|
2647
|
2790
|
2859