|
Lines 134-140
typedef enum {
Link Here
|
| 134 |
oAddressFamily, oGssAuthentication, oGssDelegateCreds, |
134 |
oAddressFamily, oGssAuthentication, oGssDelegateCreds, |
| 135 |
oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, |
135 |
oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, |
| 136 |
oSendEnv, oControlPath, oControlMaster, oControlPersist, |
136 |
oSendEnv, oControlPath, oControlMaster, oControlPersist, |
| 137 |
oHashKnownHosts, |
137 |
oHashKnownHosts, oInclude, |
| 138 |
oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, |
138 |
oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, |
| 139 |
oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication, |
139 |
oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication, |
| 140 |
oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, |
140 |
oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, |
|
Lines 234-239
static struct {
Link Here
|
| 234 |
{ "controlmaster", oControlMaster }, |
234 |
{ "controlmaster", oControlMaster }, |
| 235 |
{ "controlpersist", oControlPersist }, |
235 |
{ "controlpersist", oControlPersist }, |
| 236 |
{ "hashknownhosts", oHashKnownHosts }, |
236 |
{ "hashknownhosts", oHashKnownHosts }, |
|
|
237 |
{ "include", oInclude }, |
| 237 |
{ "tunnel", oTunnel }, |
238 |
{ "tunnel", oTunnel }, |
| 238 |
{ "tunneldevice", oTunnelDevice }, |
239 |
{ "tunneldevice", oTunnelDevice }, |
| 239 |
{ "localcommand", oLocalCommand }, |
240 |
{ "localcommand", oLocalCommand }, |
|
Lines 1029-1034
parse_int:
Link Here
|
| 1029 |
intptr = &options->visual_host_key; |
1030 |
intptr = &options->visual_host_key; |
| 1030 |
goto parse_flag; |
1031 |
goto parse_flag; |
| 1031 |
|
1032 |
|
|
|
1033 |
case oInclude: |
| 1034 |
arg = strdelim(&s); |
| 1035 |
if (!arg || *arg == '\0') |
| 1036 |
fatal("%.200s line %d: Missing argument.", filename, linenum); |
| 1037 |
char *newfile = NULL; |
| 1038 |
/* |
| 1039 |
* expand "~/some/file" into "$HOME/some/file" |
| 1040 |
* expand "~username/some/file" into "$HOME/some/file" for |
| 1041 |
* username's $HOME. "~" on its own will not expand |
| 1042 |
*/ |
| 1043 |
if (*arg == '~') { |
| 1044 |
if (arg[1] == '/') { |
| 1045 |
/* ~/some/file or ~/ case: */ |
| 1046 |
|
| 1047 |
/* |
| 1048 |
* get passwd entry for uid |
| 1049 |
*/ |
| 1050 |
const uid_t uid = getuid(); |
| 1051 |
struct passwd *pwd = getpwuid(uid); |
| 1052 |
if (!pwd) |
| 1053 |
fatal("%.200s line %d: Couldn't get user info for uid \"%ld\": %s", |
| 1054 |
filename, linenum, (const long)(uid), strerror(errno)); |
| 1055 |
|
| 1056 |
if (!pwd->pw_dir) |
| 1057 |
fatal("%.200s line %d: Couldn't expand home directory for \"%s\"", |
| 1058 |
filename, linenum, arg); |
| 1059 |
|
| 1060 |
/* |
| 1061 |
* construct expanded string |
| 1062 |
*/ |
| 1063 |
const size_t pwddirlen = strlen(pwd->pw_dir); |
| 1064 |
newfile = (char *)(malloc(pwddirlen + 1 + strlen(arg))); |
| 1065 |
if (!newfile) |
| 1066 |
abort(); |
| 1067 |
strcpy(newfile, pwd->pw_dir); |
| 1068 |
strcpy(newfile + pwddirlen, arg+1); |
| 1069 |
} else if (arg[1] != '\0') { |
| 1070 |
/* ~username/ or ~username case: */ |
| 1071 |
|
| 1072 |
/* |
| 1073 |
* parse username portion |
| 1074 |
*/ |
| 1075 |
unsigned int i; |
| 1076 |
for (i = 1; arg[i] != '/' && arg[i] != '\0'; ++i) {} |
| 1077 |
/* allocate for i-1 chars and 1 '\0' terminator */ |
| 1078 |
char *username = (char *)(malloc(i)); |
| 1079 |
if (!username) |
| 1080 |
abort(); |
| 1081 |
memset(username, 0, i); |
| 1082 |
strncpy(username, arg+1, i-1); |
| 1083 |
|
| 1084 |
/* |
| 1085 |
* get passwd entry |
| 1086 |
*/ |
| 1087 |
struct passwd *pwd = getpwnam(username); |
| 1088 |
if (!pwd) |
| 1089 |
fatal("%.200s line %d: Couldn't get user info for username \"%s\": %s", |
| 1090 |
filename, linenum, username, strerror(errno)); |
| 1091 |
free(username); |
| 1092 |
|
| 1093 |
if (!pwd->pw_dir) |
| 1094 |
fatal("%.200s line %d: Couldn't expand home directory for \"%s\"", |
| 1095 |
filename, linenum, arg); |
| 1096 |
|
| 1097 |
/* |
| 1098 |
* construct expanded string |
| 1099 |
*/ |
| 1100 |
const size_t pwddirlen = strlen(pwd->pw_dir); |
| 1101 |
newfile = (char *)(malloc(pwddirlen + 1 + strlen(arg))); |
| 1102 |
if (!newfile) |
| 1103 |
abort(); |
| 1104 |
strcpy(newfile, pwd->pw_dir); |
| 1105 |
strcpy(newfile + pwddirlen, arg+i); |
| 1106 |
} |
| 1107 |
} |
| 1108 |
int ret; |
| 1109 |
char *readfile = newfile ? newfile : arg; |
| 1110 |
if ((ret = (read_config_file(readfile, host, options, 1) ? 0 : -1)) != 0) |
| 1111 |
error("%s line %d: Error reading Include file \"%s\".", |
| 1112 |
filename, linenum, readfile); |
| 1113 |
if (newfile) |
| 1114 |
free(newfile); |
| 1115 |
if (ret) |
| 1116 |
return ret; |
| 1117 |
break; |
| 1118 |
|
| 1032 |
case oIPQoS: |
1119 |
case oIPQoS: |
| 1033 |
arg = strdelim(&s); |
1120 |
arg = strdelim(&s); |
| 1034 |
if ((value = parse_ipqos(arg)) == -1) |
1121 |
if ((value = parse_ipqos(arg)) == -1) |