|
Lines 1-4
Link Here
|
| 1 |
/* $OpenBSD: readconf.c,v 1.194 2011/09/23 07:45:05 markus Exp $ */ |
1 |
/* $OpenBSD: readconf.c,v 1.196 2013/02/22 04:45:08 dtucker Exp $ */ |
| 2 |
/* |
2 |
/* |
| 3 |
* Author: Tatu Ylonen <ylo@cs.hut.fi> |
3 |
* Author: Tatu Ylonen <ylo@cs.hut.fi> |
| 4 |
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 |
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
|
Lines 326-331
clear_forwardings(Options *options)
Link Here
|
| 326 |
options->tun_open = SSH_TUNMODE_NO; |
326 |
options->tun_open = SSH_TUNMODE_NO; |
| 327 |
} |
327 |
} |
| 328 |
|
328 |
|
|
|
329 |
void |
| 330 |
add_identity_file(Options *options, const char *dir, const char *filename, |
| 331 |
int userprovided) |
| 332 |
{ |
| 333 |
char *path; |
| 334 |
|
| 335 |
if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES) |
| 336 |
fatal("Too many identity files specified (max %d)", |
| 337 |
SSH_MAX_IDENTITY_FILES); |
| 338 |
|
| 339 |
if (dir == NULL) /* no dir, filename is absolute */ |
| 340 |
path = xstrdup(filename); |
| 341 |
else |
| 342 |
(void)xasprintf(&path, "%.100s%.100s", dir, filename); |
| 343 |
|
| 344 |
options->identity_file_userprovided[options->num_identity_files] = |
| 345 |
userprovided; |
| 346 |
options->identity_files[options->num_identity_files++] = path; |
| 347 |
} |
| 348 |
|
| 329 |
/* |
349 |
/* |
| 330 |
* Returns the number of the token pointed to by cp or oBadOption. |
350 |
* Returns the number of the token pointed to by cp or oBadOption. |
| 331 |
*/ |
351 |
*/ |
|
Lines 353-359
parse_token(const char *cp, const char *
Link Here
|
| 353 |
int |
373 |
int |
| 354 |
process_config_line(Options *options, const char *host, |
374 |
process_config_line(Options *options, const char *host, |
| 355 |
char *line, const char *filename, int linenum, |
375 |
char *line, const char *filename, int linenum, |
| 356 |
int *activep) |
376 |
int *activep, int userconfig) |
| 357 |
{ |
377 |
{ |
| 358 |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
378 |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
| 359 |
char **cpptr, fwdarg[256]; |
379 |
char **cpptr, fwdarg[256]; |
|
Lines 586-594
parse_yesnoask:
Link Here
|
| 586 |
if (*intptr >= SSH_MAX_IDENTITY_FILES) |
606 |
if (*intptr >= SSH_MAX_IDENTITY_FILES) |
| 587 |
fatal("%.200s line %d: Too many identity files specified (max %d).", |
607 |
fatal("%.200s line %d: Too many identity files specified (max %d).", |
| 588 |
filename, linenum, SSH_MAX_IDENTITY_FILES); |
608 |
filename, linenum, SSH_MAX_IDENTITY_FILES); |
| 589 |
charptr = &options->identity_files[*intptr]; |
609 |
add_identity_file(options, NULL, arg, userconfig); |
| 590 |
*charptr = xstrdup(arg); |
|
|
| 591 |
*intptr = *intptr + 1; |
| 592 |
} |
610 |
} |
| 593 |
break; |
611 |
break; |
| 594 |
|
612 |
|
|
Lines 1075-1081
parse_int:
Link Here
|
| 1075 |
|
1093 |
|
| 1076 |
int |
1094 |
int |
| 1077 |
read_config_file(const char *filename, const char *host, Options *options, |
1095 |
read_config_file(const char *filename, const char *host, Options *options, |
| 1078 |
int checkperm) |
1096 |
int flags) |
| 1079 |
{ |
1097 |
{ |
| 1080 |
FILE *f; |
1098 |
FILE *f; |
| 1081 |
char line[1024]; |
1099 |
char line[1024]; |
|
Lines 1085-1091
read_config_file(const char *filename, c
Link Here
|
| 1085 |
if ((f = fopen(filename, "r")) == NULL) |
1103 |
if ((f = fopen(filename, "r")) == NULL) |
| 1086 |
return 0; |
1104 |
return 0; |
| 1087 |
|
1105 |
|
| 1088 |
if (checkperm) { |
1106 |
if (flags & SSHCONF_CHECKPERM) { |
| 1089 |
struct stat sb; |
1107 |
struct stat sb; |
| 1090 |
|
1108 |
|
| 1091 |
if (fstat(fileno(f), &sb) == -1) |
1109 |
if (fstat(fileno(f), &sb) == -1) |
|
Lines 1106-1112
read_config_file(const char *filename, c
Link Here
|
| 1106 |
while (fgets(line, sizeof(line), f)) { |
1124 |
while (fgets(line, sizeof(line), f)) { |
| 1107 |
/* Update line number counter. */ |
1125 |
/* Update line number counter. */ |
| 1108 |
linenum++; |
1126 |
linenum++; |
| 1109 |
if (process_config_line(options, host, line, filename, linenum, &active) != 0) |
1127 |
if (process_config_line(options, host, line, filename, linenum, |
|
|
1128 |
&active, flags & SSHCONF_USERCONF) != 0) |
| 1110 |
bad_options++; |
1129 |
bad_options++; |
| 1111 |
} |
1130 |
} |
| 1112 |
fclose(f); |
1131 |
fclose(f); |
|
Lines 1280-1309
fill_default_options(Options * options)
Link Here
|
| 1280 |
options->protocol = SSH_PROTO_2; |
1299 |
options->protocol = SSH_PROTO_2; |
| 1281 |
if (options->num_identity_files == 0) { |
1300 |
if (options->num_identity_files == 0) { |
| 1282 |
if (options->protocol & SSH_PROTO_1) { |
1301 |
if (options->protocol & SSH_PROTO_1) { |
| 1283 |
len = 2 + strlen(_PATH_SSH_CLIENT_IDENTITY) + 1; |
1302 |
add_identity_file(options, "~/", |
| 1284 |
options->identity_files[options->num_identity_files] = |
1303 |
_PATH_SSH_CLIENT_IDENTITY, 0); |
| 1285 |
xmalloc(len); |
|
|
| 1286 |
snprintf(options->identity_files[options->num_identity_files++], |
| 1287 |
len, "~/%.100s", _PATH_SSH_CLIENT_IDENTITY); |
| 1288 |
} |
1304 |
} |
| 1289 |
if (options->protocol & SSH_PROTO_2) { |
1305 |
if (options->protocol & SSH_PROTO_2) { |
| 1290 |
len = 2 + strlen(_PATH_SSH_CLIENT_ID_RSA) + 1; |
1306 |
add_identity_file(options, "~/", |
| 1291 |
options->identity_files[options->num_identity_files] = |
1307 |
_PATH_SSH_CLIENT_ID_RSA, 0); |
| 1292 |
xmalloc(len); |
1308 |
add_identity_file(options, "~/", |
| 1293 |
snprintf(options->identity_files[options->num_identity_files++], |
1309 |
_PATH_SSH_CLIENT_ID_DSA, 0); |
| 1294 |
len, "~/%.100s", _PATH_SSH_CLIENT_ID_RSA); |
|
|
| 1295 |
|
| 1296 |
len = 2 + strlen(_PATH_SSH_CLIENT_ID_DSA) + 1; |
| 1297 |
options->identity_files[options->num_identity_files] = |
| 1298 |
xmalloc(len); |
| 1299 |
snprintf(options->identity_files[options->num_identity_files++], |
| 1300 |
len, "~/%.100s", _PATH_SSH_CLIENT_ID_DSA); |
| 1301 |
#ifdef OPENSSL_HAS_ECC |
1310 |
#ifdef OPENSSL_HAS_ECC |
| 1302 |
len = 2 + strlen(_PATH_SSH_CLIENT_ID_ECDSA) + 1; |
1311 |
add_identity_file(options, "~/", |
| 1303 |
options->identity_files[options->num_identity_files] = |
1312 |
_PATH_SSH_CLIENT_ID_ECDSA, 0); |
| 1304 |
xmalloc(len); |
|
|
| 1305 |
snprintf(options->identity_files[options->num_identity_files++], |
| 1306 |
len, "~/%.100s", _PATH_SSH_CLIENT_ID_ECDSA); |
| 1307 |
#endif |
1313 |
#endif |
| 1308 |
} |
1314 |
} |
| 1309 |
} |
1315 |
} |