diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-08-06 21:35:51 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-08-06 21:35:51 +0000 |
commit | f7db3bb64caf8d7822a18d6fd4c0480df7d0086d (patch) | |
tree | 3167ed1f115185df591dc1c28c8aa33476194cbb | |
parent | 3ab1dfa2a654b6764eaa121f7111e94c35175894 (diff) |
- markus@cvs.openbsd.org 2001/08/01 22:03:33
[authfd.c authfd.h readconf.c readconf.h scard.c scard.h ssh-add.c
ssh-agent.c ssh.c]
use strings instead of ints for smartcard reader ids
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | authfd.c | 6 | ||||
-rw-r--r-- | authfd.h | 6 | ||||
-rw-r--r-- | readconf.c | 8 | ||||
-rw-r--r-- | readconf.h | 4 | ||||
-rw-r--r-- | scard.c | 17 | ||||
-rw-r--r-- | scard.h | 4 | ||||
-rw-r--r-- | ssh-add.c | 19 | ||||
-rw-r--r-- | ssh-agent.c | 19 | ||||
-rw-r--r-- | ssh.c | 6 |
10 files changed, 53 insertions, 42 deletions
@@ -87,6 +87,10 @@ | |||
87 | - jakob@cvs.openbsd.org 2001/07/31 12:53:34 | 87 | - jakob@cvs.openbsd.org 2001/07/31 12:53:34 |
88 | [scard.c] | 88 | [scard.c] |
89 | close smartcard connection if card is missing | 89 | close smartcard connection if card is missing |
90 | - markus@cvs.openbsd.org 2001/08/01 22:03:33 | ||
91 | [authfd.c authfd.h readconf.c readconf.h scard.c scard.h ssh-add.c | ||
92 | ssh-agent.c ssh.c] | ||
93 | use strings instead of ints for smartcard reader ids | ||
90 | 94 | ||
91 | 20010803 | 95 | 20010803 |
92 | - (djm) Fix interrupted read in entropy gatherer. Spotted by markus@ on | 96 | - (djm) Fix interrupted read in entropy gatherer. Spotted by markus@ on |
@@ -6197,4 +6201,4 @@ | |||
6197 | - Wrote replacements for strlcpy and mkdtemp | 6201 | - Wrote replacements for strlcpy and mkdtemp |
6198 | - Released 1.0pre1 | 6202 | - Released 1.0pre1 |
6199 | 6203 | ||
6200 | $Id: ChangeLog,v 1.1448 2001/08/06 21:33:44 mouring Exp $ | 6204 | $Id: ChangeLog,v 1.1449 2001/08/06 21:35:51 mouring Exp $ |
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "includes.h" | 37 | #include "includes.h" |
38 | RCSID("$OpenBSD: authfd.c,v 1.42 2001/06/26 04:59:59 markus Exp $"); | 38 | RCSID("$OpenBSD: authfd.c,v 1.43 2001/08/01 22:03:33 markus Exp $"); |
39 | 39 | ||
40 | #include <openssl/evp.h> | 40 | #include <openssl/evp.h> |
41 | 41 | ||
@@ -535,7 +535,7 @@ ssh_remove_identity(AuthenticationConnection *auth, Key *key) | |||
535 | } | 535 | } |
536 | 536 | ||
537 | int | 537 | int |
538 | ssh_update_card(AuthenticationConnection *auth, int add, int reader_id) | 538 | ssh_update_card(AuthenticationConnection *auth, int add, const char *reader_id) |
539 | { | 539 | { |
540 | Buffer msg; | 540 | Buffer msg; |
541 | int type; | 541 | int type; |
@@ -543,7 +543,7 @@ ssh_update_card(AuthenticationConnection *auth, int add, int reader_id) | |||
543 | buffer_init(&msg); | 543 | buffer_init(&msg); |
544 | buffer_put_char(&msg, add ? SSH_AGENTC_ADD_SMARTCARD_KEY : | 544 | buffer_put_char(&msg, add ? SSH_AGENTC_ADD_SMARTCARD_KEY : |
545 | SSH_AGENTC_REMOVE_SMARTCARD_KEY); | 545 | SSH_AGENTC_REMOVE_SMARTCARD_KEY); |
546 | buffer_put_int(&msg, reader_id); | 546 | buffer_put_cstring(&msg, reader_id); |
547 | if (ssh_request_reply(auth, &msg, &msg) == 0) { | 547 | if (ssh_request_reply(auth, &msg, &msg) == 0) { |
548 | buffer_free(&msg); | 548 | buffer_free(&msg); |
549 | return 0; | 549 | return 0; |
@@ -11,7 +11,7 @@ | |||
11 | * called by a name other than "ssh" or "Secure Shell". | 11 | * called by a name other than "ssh" or "Secure Shell". |
12 | */ | 12 | */ |
13 | 13 | ||
14 | /* RCSID("$OpenBSD: authfd.h,v 1.19 2001/06/26 17:27:22 markus Exp $"); */ | 14 | /* RCSID("$OpenBSD: authfd.h,v 1.20 2001/08/01 22:03:33 markus Exp $"); */ |
15 | 15 | ||
16 | #ifndef AUTHFD_H | 16 | #ifndef AUTHFD_H |
17 | #define AUTHFD_H | 17 | #define AUTHFD_H |
@@ -62,9 +62,9 @@ int ssh_get_num_identities(AuthenticationConnection *, int); | |||
62 | Key *ssh_get_first_identity(AuthenticationConnection *, char **, int); | 62 | Key *ssh_get_first_identity(AuthenticationConnection *, char **, int); |
63 | Key *ssh_get_next_identity(AuthenticationConnection *, char **, int); | 63 | Key *ssh_get_next_identity(AuthenticationConnection *, char **, int); |
64 | int ssh_add_identity(AuthenticationConnection *, Key *, const char *); | 64 | int ssh_add_identity(AuthenticationConnection *, Key *, const char *); |
65 | int ssh_remove_identity(AuthenticationConnection *, Key *); | 65 | int ssh_remove_identity(AuthenticationConnection *, Key *); |
66 | int ssh_remove_all_identities(AuthenticationConnection *, int); | 66 | int ssh_remove_all_identities(AuthenticationConnection *, int); |
67 | int ssh_update_card(AuthenticationConnection *, int, int); | 67 | int ssh_update_card(AuthenticationConnection *, int, const char *); |
68 | 68 | ||
69 | int | 69 | int |
70 | ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16], | 70 | ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16], |
diff --git a/readconf.c b/readconf.c index a4ae73333..c556b8338 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: readconf.c,v 1.85 2001/07/31 09:28:44 jakob Exp $"); | 15 | RCSID("$OpenBSD: readconf.c,v 1.86 2001/08/01 22:03:33 markus Exp $"); |
16 | 16 | ||
17 | #include "ssh.h" | 17 | #include "ssh.h" |
18 | #include "xmalloc.h" | 18 | #include "xmalloc.h" |
@@ -470,8 +470,8 @@ parse_string: | |||
470 | goto parse_string; | 470 | goto parse_string; |
471 | 471 | ||
472 | case oSmartcardDevice: | 472 | case oSmartcardDevice: |
473 | intptr = &options->smartcard_device; | 473 | charptr = &options->smartcard_device; |
474 | goto parse_int; | 474 | goto parse_string; |
475 | 475 | ||
476 | case oProxyCommand: | 476 | case oProxyCommand: |
477 | charptr = &options->proxy_command; | 477 | charptr = &options->proxy_command; |
@@ -777,7 +777,7 @@ initialize_options(Options * options) | |||
777 | options->log_level = (LogLevel) - 1; | 777 | options->log_level = (LogLevel) - 1; |
778 | options->preferred_authentications = NULL; | 778 | options->preferred_authentications = NULL; |
779 | options->bind_address = NULL; | 779 | options->bind_address = NULL; |
780 | options->smartcard_device = -1; | 780 | options->smartcard_device = NULL; |
781 | } | 781 | } |
782 | 782 | ||
783 | /* | 783 | /* |
diff --git a/readconf.h b/readconf.h index 623a44810..802fd1908 100644 --- a/readconf.h +++ b/readconf.h | |||
@@ -11,7 +11,7 @@ | |||
11 | * called by a name other than "ssh" or "Secure Shell". | 11 | * called by a name other than "ssh" or "Secure Shell". |
12 | */ | 12 | */ |
13 | 13 | ||
14 | /* RCSID("$OpenBSD: readconf.h,v 1.36 2001/07/31 09:28:44 jakob Exp $"); */ | 14 | /* RCSID("$OpenBSD: readconf.h,v 1.37 2001/08/01 22:03:33 markus Exp $"); */ |
15 | 15 | ||
16 | #ifndef READCONF_H | 16 | #ifndef READCONF_H |
17 | #define READCONF_H | 17 | #define READCONF_H |
@@ -87,7 +87,7 @@ typedef struct { | |||
87 | char *user_hostfile2; | 87 | char *user_hostfile2; |
88 | char *preferred_authentications; | 88 | char *preferred_authentications; |
89 | char *bind_address; /* local socket address for connection to sshd */ | 89 | char *bind_address; /* local socket address for connection to sshd */ |
90 | int smartcard_device; /* Smartcard reader device */ | 90 | char *smartcard_device; /* Smartcard reader device */ |
91 | 91 | ||
92 | int num_identity_files; /* Number of files for RSA/DSA identities. */ | 92 | int num_identity_files; /* Number of files for RSA/DSA identities. */ |
93 | char *identity_files[SSH_MAX_IDENTITY_FILES]; | 93 | char *identity_files[SSH_MAX_IDENTITY_FILES]; |
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #ifdef SMARTCARD | 25 | #ifdef SMARTCARD |
26 | #include "includes.h" | 26 | #include "includes.h" |
27 | RCSID("$OpenBSD: scard.c,v 1.10 2001/07/31 12:53:34 jakob Exp $"); | 27 | RCSID("$OpenBSD: scard.c,v 1.11 2001/08/01 22:03:33 markus Exp $"); |
28 | 28 | ||
29 | #include <openssl/engine.h> | 29 | #include <openssl/engine.h> |
30 | #include <sectok.h> | 30 | #include <sectok.h> |
@@ -43,7 +43,7 @@ RCSID("$OpenBSD: scard.c,v 1.10 2001/07/31 12:53:34 jakob Exp $"); | |||
43 | #define MAX_BUF_SIZE 256 | 43 | #define MAX_BUF_SIZE 256 |
44 | 44 | ||
45 | static int sc_fd = -1; | 45 | static int sc_fd = -1; |
46 | static int sc_reader_num = -1; | 46 | static char *sc_reader_id = NULL; |
47 | static int cla = 0x00; /* class */ | 47 | static int cla = 0x00; /* class */ |
48 | 48 | ||
49 | /* interface to libsectok */ | 49 | /* interface to libsectok */ |
@@ -56,14 +56,14 @@ sc_open(void) | |||
56 | if (sc_fd >= 0) | 56 | if (sc_fd >= 0) |
57 | return sc_fd; | 57 | return sc_fd; |
58 | 58 | ||
59 | sc_fd = sectok_open(sc_reader_num, STONOWAIT, &sw); | 59 | sc_fd = sectok_friendly_open(sc_reader_id, STONOWAIT, &sw); |
60 | if (sc_fd < 0) { | 60 | if (sc_fd < 0) { |
61 | error("sectok_open failed: %s", sectok_get_sw(sw)); | 61 | error("sectok_open failed: %s", sectok_get_sw(sw)); |
62 | return SCARD_ERROR_FAIL; | 62 | return SCARD_ERROR_FAIL; |
63 | } | 63 | } |
64 | if (! sectok_cardpresent(sc_fd)) { | 64 | if (! sectok_cardpresent(sc_fd)) { |
65 | debug("smartcard in reader %d not present, skipping", | 65 | debug("smartcard in reader %s not present, skipping", |
66 | sc_reader_num); | 66 | sc_reader_id); |
67 | sc_close(); | 67 | sc_close(); |
68 | return SCARD_ERROR_NOCARD; | 68 | return SCARD_ERROR_NOCARD; |
69 | } | 69 | } |
@@ -326,12 +326,15 @@ sc_close(void) | |||
326 | } | 326 | } |
327 | 327 | ||
328 | Key * | 328 | Key * |
329 | sc_get_key(int num) | 329 | sc_get_key(const char *id) |
330 | { | 330 | { |
331 | Key *k; | 331 | Key *k; |
332 | int status; | 332 | int status; |
333 | 333 | ||
334 | sc_reader_num = num; | 334 | if (sc_reader_id != NULL) |
335 | xfree(sc_reader_id); | ||
336 | sc_reader_id = xstrdup(id); | ||
337 | |||
335 | k = key_new(KEY_RSA); | 338 | k = key_new(KEY_RSA); |
336 | if (k == NULL) { | 339 | if (k == NULL) { |
337 | return NULL; | 340 | return NULL; |
@@ -22,7 +22,7 @@ | |||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* $OpenBSD: scard.h,v 1.5 2001/07/30 16:06:07 jakob Exp $ */ | 25 | /* $OpenBSD: scard.h,v 1.6 2001/08/01 22:03:33 markus Exp $ */ |
26 | 26 | ||
27 | #include <openssl/engine.h> | 27 | #include <openssl/engine.h> |
28 | 28 | ||
@@ -33,7 +33,7 @@ | |||
33 | #define SCARD_ERROR_NOCARD -2 | 33 | #define SCARD_ERROR_NOCARD -2 |
34 | #define SCARD_ERROR_APPLET -3 | 34 | #define SCARD_ERROR_APPLET -3 |
35 | 35 | ||
36 | Key *sc_get_key(int); | 36 | Key *sc_get_key(const char*); |
37 | ENGINE *sc_get_engine(void); | 37 | ENGINE *sc_get_engine(void); |
38 | void sc_close(void); | 38 | void sc_close(void); |
39 | 39 | ||
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "includes.h" | 37 | #include "includes.h" |
38 | RCSID("$OpenBSD: ssh-add.c,v 1.43 2001/06/27 06:26:36 markus Exp $"); | 38 | RCSID("$OpenBSD: ssh-add.c,v 1.44 2001/08/01 22:03:33 markus Exp $"); |
39 | 39 | ||
40 | #include <openssl/evp.h> | 40 | #include <openssl/evp.h> |
41 | 41 | ||
@@ -150,13 +150,13 @@ add_file(AuthenticationConnection *ac, const char *filename) | |||
150 | } | 150 | } |
151 | 151 | ||
152 | static void | 152 | static void |
153 | update_card(AuthenticationConnection *ac, int add, int id) | 153 | update_card(AuthenticationConnection *ac, int add, const char *id) |
154 | { | 154 | { |
155 | if (ssh_update_card(ac, add, id)) | 155 | if (ssh_update_card(ac, add, id)) |
156 | fprintf(stderr, "Card %s: %d\n", | 156 | fprintf(stderr, "Card %s: %s\n", |
157 | add ? "added" : "removed", id); | 157 | add ? "added" : "removed", id); |
158 | else | 158 | else |
159 | fprintf(stderr, "Could not %s card: %d\n", | 159 | fprintf(stderr, "Could not %s card: %s\n", |
160 | add ? "add" : "remove", id); | 160 | add ? "add" : "remove", id); |
161 | } | 161 | } |
162 | 162 | ||
@@ -211,7 +211,8 @@ main(int argc, char **argv) | |||
211 | AuthenticationConnection *ac = NULL; | 211 | AuthenticationConnection *ac = NULL; |
212 | struct passwd *pw; | 212 | struct passwd *pw; |
213 | char buf[1024]; | 213 | char buf[1024]; |
214 | int i, ch, deleting = 0, sc_reader_num = -1; | 214 | char *sc_reader_id = NULL; |
215 | int i, ch, deleting = 0; | ||
215 | 216 | ||
216 | __progname = get_progname(argv[0]); | 217 | __progname = get_progname(argv[0]); |
217 | init_rng(); | 218 | init_rng(); |
@@ -240,11 +241,11 @@ main(int argc, char **argv) | |||
240 | goto done; | 241 | goto done; |
241 | break; | 242 | break; |
242 | case 's': | 243 | case 's': |
243 | sc_reader_num = atoi(optarg); | 244 | sc_reader_id = optarg; |
244 | break; | 245 | break; |
245 | case 'e': | 246 | case 'e': |
246 | deleting = 1; | 247 | deleting = 1; |
247 | sc_reader_num = atoi(optarg); | 248 | sc_reader_id = optarg; |
248 | break; | 249 | break; |
249 | default: | 250 | default: |
250 | usage(); | 251 | usage(); |
@@ -254,8 +255,8 @@ main(int argc, char **argv) | |||
254 | } | 255 | } |
255 | argc -= optind; | 256 | argc -= optind; |
256 | argv += optind; | 257 | argv += optind; |
257 | if (sc_reader_num != -1) { | 258 | if (sc_reader_id != NULL) { |
258 | update_card(ac, !deleting, sc_reader_num); | 259 | update_card(ac, !deleting, sc_reader_id); |
259 | goto done; | 260 | goto done; |
260 | } | 261 | } |
261 | if (argc == 0) { | 262 | if (argc == 0) { |
diff --git a/ssh-agent.c b/ssh-agent.c index 46a1199b1..1df3ccd11 100644 --- a/ssh-agent.c +++ b/ssh-agent.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-agent.c,v 1.68 2001/07/20 14:46:11 markus Exp $ */ | 1 | /* $OpenBSD: ssh-agent.c,v 1.69 2001/08/01 22:03:33 markus Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -36,7 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include "includes.h" | 38 | #include "includes.h" |
39 | RCSID("$OpenBSD: ssh-agent.c,v 1.68 2001/07/20 14:46:11 markus Exp $"); | 39 | RCSID("$OpenBSD: ssh-agent.c,v 1.69 2001/08/01 22:03:33 markus Exp $"); |
40 | 40 | ||
41 | #include <openssl/evp.h> | 41 | #include <openssl/evp.h> |
42 | #include <openssl/md5.h> | 42 | #include <openssl/md5.h> |
@@ -451,12 +451,13 @@ process_add_smartcard_key (SocketEntry *e) | |||
451 | { | 451 | { |
452 | Idtab *tab; | 452 | Idtab *tab; |
453 | Key *n = NULL, *k = NULL; | 453 | Key *n = NULL, *k = NULL; |
454 | char *sc_reader_id = NULL; | ||
454 | int success = 0; | 455 | int success = 0; |
455 | int sc_reader_num = 0; | ||
456 | 456 | ||
457 | sc_reader_num = buffer_get_int(&e->input); | 457 | sc_reader_id = buffer_get_string(&e->input, NULL); |
458 | k = sc_get_key(sc_reader_id); | ||
459 | xfree(sc_reader_id); | ||
458 | 460 | ||
459 | k = sc_get_key(sc_reader_num); | ||
460 | if (k == NULL) { | 461 | if (k == NULL) { |
461 | error("sc_get_pubkey failed"); | 462 | error("sc_get_pubkey failed"); |
462 | goto send; | 463 | goto send; |
@@ -510,11 +511,13 @@ process_remove_smartcard_key(SocketEntry *e) | |||
510 | Key *k = NULL, *private; | 511 | Key *k = NULL, *private; |
511 | int idx; | 512 | int idx; |
512 | int success = 0; | 513 | int success = 0; |
513 | int sc_reader_num = 0; | 514 | char *sc_reader_id = NULL; |
514 | 515 | ||
515 | sc_reader_num = buffer_get_int(&e->input); | 516 | sc_reader_id = buffer_get_string(&e->input, NULL); |
517 | k = sc_get_key(sc_reader_id); | ||
518 | xfree(sc_reader_id); | ||
516 | 519 | ||
517 | if ((k = sc_get_key(sc_reader_num)) == NULL) { | 520 | if (k == NULL) { |
518 | error("sc_get_pubkey failed"); | 521 | error("sc_get_pubkey failed"); |
519 | } else { | 522 | } else { |
520 | k->type = KEY_RSA1; | 523 | k->type = KEY_RSA1; |
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: ssh.c,v 1.132 2001/07/31 09:28:44 jakob Exp $"); | 42 | RCSID("$OpenBSD: ssh.c,v 1.133 2001/08/01 22:03:33 markus Exp $"); |
43 | 43 | ||
44 | #include <openssl/evp.h> | 44 | #include <openssl/evp.h> |
45 | #include <openssl/err.h> | 45 | #include <openssl/err.h> |
@@ -372,7 +372,7 @@ again: | |||
372 | break; | 372 | break; |
373 | case 'I': | 373 | case 'I': |
374 | #ifdef SMARTCARD | 374 | #ifdef SMARTCARD |
375 | options.smartcard_device = atoi(optarg); | 375 | options.smartcard_device = xstrdup(optarg); |
376 | #else | 376 | #else |
377 | fprintf(stderr, "no support for smartcards.\n"); | 377 | fprintf(stderr, "no support for smartcards.\n"); |
378 | #endif | 378 | #endif |
@@ -1151,7 +1151,7 @@ load_public_identity_files(void) | |||
1151 | int i = 0; | 1151 | int i = 0; |
1152 | 1152 | ||
1153 | #ifdef SMARTCARD | 1153 | #ifdef SMARTCARD |
1154 | if (options.smartcard_device >= 0 && | 1154 | if (options.smartcard_device != NULL && |
1155 | options.num_identity_files + 1 < SSH_MAX_IDENTITY_FILES && | 1155 | options.num_identity_files + 1 < SSH_MAX_IDENTITY_FILES && |
1156 | (public = sc_get_key(options.smartcard_device)) != NULL ) { | 1156 | (public = sc_get_key(options.smartcard_device)) != NULL ) { |
1157 | Key *new; | 1157 | Key *new; |