|
Lines 193-199
usage(void)
Link Here
|
| 193 |
" [-O ctl_cmd] [-o option] [-p port]\n" |
193 |
" [-O ctl_cmd] [-o option] [-p port]\n" |
| 194 |
" [-Q cipher | cipher-auth | mac | kex | key]\n" |
194 |
" [-Q cipher | cipher-auth | mac | kex | key]\n" |
| 195 |
" [-R address] [-S ctl_path] [-W host:port]\n" |
195 |
" [-R address] [-S ctl_path] [-W host:port]\n" |
| 196 |
" [-w local_tun[:remote_tun]] [user@]hostname [command]\n" |
196 |
" [-w local_tun[:remote_tun]] [-z certificate_file]\n" |
|
|
197 |
" [user@]hostname [command]\n" |
| 197 |
); |
198 |
); |
| 198 |
exit(255); |
199 |
exit(255); |
| 199 |
} |
200 |
} |
|
Lines 565-571
main(int ac, char **av)
Link Here
|
| 565 |
|
566 |
|
| 566 |
again: |
567 |
again: |
| 567 |
while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" |
568 |
while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" |
| 568 |
"ACD:E:F:GI:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) { |
569 |
"ACD:E:F:GI:KL:MNO:PQ:R:S:TVw:W:XYyz:")) != -1) { |
| 569 |
switch (opt) { |
570 |
switch (opt) { |
| 570 |
case '1': |
571 |
case '1': |
| 571 |
options.protocol = SSH_PROTO_1; |
572 |
options.protocol = SSH_PROTO_1; |
|
Lines 879-884
main(int ac, char **av)
Link Here
|
| 879 |
case 'F': |
880 |
case 'F': |
| 880 |
config = optarg; |
881 |
config = optarg; |
| 881 |
break; |
882 |
break; |
|
|
883 |
case 'z': |
| 884 |
add_certificate_file(&options, optarg, 1); |
| 885 |
break; |
| 882 |
default: |
886 |
default: |
| 883 |
usage(); |
887 |
usage(); |
| 884 |
} |
888 |
} |
|
Lines 1306-1311
main(int ac, char **av)
Link Here
|
| 1306 |
options.identity_keys[i] = NULL; |
1310 |
options.identity_keys[i] = NULL; |
| 1307 |
} |
1311 |
} |
| 1308 |
} |
1312 |
} |
|
|
1313 |
for (i = 0; i < options.num_certificate_files; i++) { |
| 1314 |
free(options.certificate_files[i]); |
| 1315 |
options.certificate_files[i] = NULL; |
| 1316 |
} |
| 1309 |
|
1317 |
|
| 1310 |
exit_status = compat20 ? ssh_session2() : ssh_session(); |
1318 |
exit_status = compat20 ? ssh_session2() : ssh_session(); |
| 1311 |
packet_close(); |
1319 |
packet_close(); |
|
Lines 1892-1916
ssh_session2(void)
Link Here
|
| 1892 |
options.escape_char : SSH_ESCAPECHAR_NONE, id); |
1900 |
options.escape_char : SSH_ESCAPECHAR_NONE, id); |
| 1893 |
} |
1901 |
} |
| 1894 |
|
1902 |
|
|
|
1903 |
/* Loads all IdentityFile and CertificateFile keys */ |
| 1895 |
static void |
1904 |
static void |
| 1896 |
load_public_identity_files(void) |
1905 |
load_public_identity_files(void) |
| 1897 |
{ |
1906 |
{ |
| 1898 |
char *filename, *cp, thishost[NI_MAXHOST]; |
1907 |
char *filename, *cp, thishost[NI_MAXHOST]; |
| 1899 |
char *pwdir = NULL, *pwname = NULL; |
1908 |
char *pwdir = NULL, *pwname = NULL; |
| 1900 |
int i = 0; |
|
|
| 1901 |
Key *public; |
1909 |
Key *public; |
| 1902 |
struct passwd *pw; |
1910 |
struct passwd *pw; |
| 1903 |
u_int n_ids; |
1911 |
int i; |
|
|
1912 |
u_int n_ids, n_certs; |
| 1904 |
char *identity_files[SSH_MAX_IDENTITY_FILES]; |
1913 |
char *identity_files[SSH_MAX_IDENTITY_FILES]; |
| 1905 |
Key *identity_keys[SSH_MAX_IDENTITY_FILES]; |
1914 |
Key *identity_keys[SSH_MAX_IDENTITY_FILES]; |
|
|
1915 |
char *certificate_files[SSH_MAX_CERTIFICATE_FILES]; |
| 1916 |
struct sshkey *certificates[SSH_MAX_CERTIFICATE_FILES]; |
| 1906 |
#ifdef ENABLE_PKCS11 |
1917 |
#ifdef ENABLE_PKCS11 |
| 1907 |
Key **keys; |
1918 |
Key **keys; |
| 1908 |
int nkeys; |
1919 |
int nkeys; |
| 1909 |
#endif /* PKCS11 */ |
1920 |
#endif /* PKCS11 */ |
| 1910 |
|
1921 |
|
| 1911 |
n_ids = 0; |
1922 |
n_ids = n_certs = 0; |
| 1912 |
memset(identity_files, 0, sizeof(identity_files)); |
1923 |
memset(identity_files, 0, sizeof(identity_files)); |
| 1913 |
memset(identity_keys, 0, sizeof(identity_keys)); |
1924 |
memset(identity_keys, 0, sizeof(identity_keys)); |
|
|
1925 |
memset(certificate_files, 0, sizeof(certificate_files)); |
| 1926 |
memset(certificates, 0, sizeof(certificates)); |
| 1914 |
|
1927 |
|
| 1915 |
#ifdef ENABLE_PKCS11 |
1928 |
#ifdef ENABLE_PKCS11 |
| 1916 |
if (options.pkcs11_provider != NULL && |
1929 |
if (options.pkcs11_provider != NULL && |
|
Lines 1942-1947
load_public_identity_files(void)
Link Here
|
| 1942 |
if (n_ids >= SSH_MAX_IDENTITY_FILES || |
1955 |
if (n_ids >= SSH_MAX_IDENTITY_FILES || |
| 1943 |
strcasecmp(options.identity_files[i], "none") == 0) { |
1956 |
strcasecmp(options.identity_files[i], "none") == 0) { |
| 1944 |
free(options.identity_files[i]); |
1957 |
free(options.identity_files[i]); |
|
|
1958 |
options.identity_files[i] = NULL; |
| 1945 |
continue; |
1959 |
continue; |
| 1946 |
} |
1960 |
} |
| 1947 |
cp = tilde_expand_filename(options.identity_files[i], |
1961 |
cp = tilde_expand_filename(options.identity_files[i], |
|
Lines 1960-1966
load_public_identity_files(void)
Link Here
|
| 1960 |
if (++n_ids >= SSH_MAX_IDENTITY_FILES) |
1974 |
if (++n_ids >= SSH_MAX_IDENTITY_FILES) |
| 1961 |
continue; |
1975 |
continue; |
| 1962 |
|
1976 |
|
| 1963 |
/* Try to add the certificate variant too */ |
1977 |
/* |
|
|
1978 |
* If no certificates have been explicitly listed then try |
| 1979 |
* to add the default certificate variant too. |
| 1980 |
*/ |
| 1981 |
if (options.num_certificate_files != 0) |
| 1982 |
continue; |
| 1964 |
xasprintf(&cp, "%s-cert", filename); |
1983 |
xasprintf(&cp, "%s-cert", filename); |
| 1965 |
public = key_load_public(cp, NULL); |
1984 |
public = key_load_public(cp, NULL); |
| 1966 |
debug("identity file %s type %d", cp, |
1985 |
debug("identity file %s type %d", cp, |
|
Lines 1977-1990
load_public_identity_files(void)
Link Here
|
| 1977 |
continue; |
1996 |
continue; |
| 1978 |
} |
1997 |
} |
| 1979 |
identity_keys[n_ids] = public; |
1998 |
identity_keys[n_ids] = public; |
| 1980 |
/* point to the original path, most likely the private key */ |
1999 |
identity_files[n_ids] = cp; |
| 1981 |
identity_files[n_ids] = xstrdup(filename); |
|
|
| 1982 |
n_ids++; |
2000 |
n_ids++; |
| 1983 |
} |
2001 |
} |
|
|
2002 |
|
| 2003 |
if (options.num_certificate_files > SSH_MAX_CERTIFICATE_FILES) |
| 2004 |
fatal("%s: too many certificates", __func__); |
| 2005 |
for (i = 0; i < options.num_certificate_files; i++) { |
| 2006 |
cp = tilde_expand_filename(options.certificate_files[i], |
| 2007 |
original_real_uid); |
| 2008 |
filename = percent_expand(cp, "d", pwdir, |
| 2009 |
"u", pwname, "l", thishost, "h", host, |
| 2010 |
"r", options.user, (char *)NULL); |
| 2011 |
free(cp); |
| 2012 |
|
| 2013 |
public = key_load_public(filename, NULL); |
| 2014 |
debug("certificate file %s type %d", filename, |
| 2015 |
public ? public->type : -1); |
| 2016 |
free(options.certificate_files[i]); |
| 2017 |
options.certificate_files[i] = NULL; |
| 2018 |
if (public == NULL) { |
| 2019 |
free(filename); |
| 2020 |
continue; |
| 2021 |
} |
| 2022 |
if (!key_is_cert(public)) { |
| 2023 |
debug("%s: key %s type %s is not a certificate", |
| 2024 |
__func__, filename, key_type(public)); |
| 2025 |
key_free(public); |
| 2026 |
free(filename); |
| 2027 |
continue; |
| 2028 |
} |
| 2029 |
certificate_files[n_certs] = filename; |
| 2030 |
certificates[n_certs] = public; |
| 2031 |
++n_certs; |
| 2032 |
} |
| 2033 |
|
| 1984 |
options.num_identity_files = n_ids; |
2034 |
options.num_identity_files = n_ids; |
| 1985 |
memcpy(options.identity_files, identity_files, sizeof(identity_files)); |
2035 |
memcpy(options.identity_files, identity_files, sizeof(identity_files)); |
| 1986 |
memcpy(options.identity_keys, identity_keys, sizeof(identity_keys)); |
2036 |
memcpy(options.identity_keys, identity_keys, sizeof(identity_keys)); |
| 1987 |
|
2037 |
|
|
|
2038 |
options.num_certificate_files = n_certs; |
| 2039 |
memcpy(options.certificate_files, |
| 2040 |
certificate_files, sizeof(certificate_files)); |
| 2041 |
memcpy(options.certificates, certificates, sizeof(certificates)); |
| 2042 |
|
| 1988 |
explicit_bzero(pwname, strlen(pwname)); |
2043 |
explicit_bzero(pwname, strlen(pwname)); |
| 1989 |
free(pwname); |
2044 |
free(pwname); |
| 1990 |
explicit_bzero(pwdir, strlen(pwdir)); |
2045 |
explicit_bzero(pwdir, strlen(pwdir)); |