diff options
author | Damien Miller <djm@mindrot.org> | 2002-01-22 23:05:59 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2002-01-22 23:05:59 +1100 |
commit | 6e1057c2d79de5382efc53ceb3e1213cc273ca12 (patch) | |
tree | a176ee5ebb45c5382672f1958368e10494352e66 | |
parent | f451e22e2134463062f7134f3e3556ab78ea0661 (diff) |
- djm@cvs.openbsd.org 2001/12/21 10:06:43
[ssh-add.1 ssh-add.c]
Try all standard key files (id_rsa, id_dsa, identity) when invoked with
no arguments; ok markus@
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ssh-add.1 | 7 | ||||
-rw-r--r-- | ssh-add.c | 54 |
3 files changed, 45 insertions, 22 deletions
@@ -16,6 +16,10 @@ | |||
16 | - djm@cvs.openbsd.org 2001/12/21 08:53:45 | 16 | - djm@cvs.openbsd.org 2001/12/21 08:53:45 |
17 | [readpass.c] | 17 | [readpass.c] |
18 | Avoid interruptable passphrase read; ok markus@ | 18 | Avoid interruptable passphrase read; ok markus@ |
19 | - djm@cvs.openbsd.org 2001/12/21 10:06:43 | ||
20 | [ssh-add.1 ssh-add.c] | ||
21 | Try all standard key files (id_rsa, id_dsa, identity) when invoked with | ||
22 | no arguments; ok markus@ | ||
19 | 23 | ||
20 | 20020121 | 24 | 20020121 |
21 | - (djm) Rework ssh-rand-helper: | 25 | - (djm) Rework ssh-rand-helper: |
@@ -7163,4 +7167,4 @@ | |||
7163 | - Wrote replacements for strlcpy and mkdtemp | 7167 | - Wrote replacements for strlcpy and mkdtemp |
7164 | - Released 1.0pre1 | 7168 | - Released 1.0pre1 |
7165 | 7169 | ||
7166 | $Id: ChangeLog,v 1.1726 2002/01/22 12:05:31 djm Exp $ | 7170 | $Id: ChangeLog,v 1.1727 2002/01/22 12:05:59 djm Exp $ |
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: ssh-add.1,v 1.27 2001/08/23 18:08:59 stevesk Exp $ | 1 | .\" $OpenBSD: ssh-add.1,v 1.28 2001/12/21 10:06:43 djm Exp $ |
2 | .\" | 2 | .\" |
3 | .\" -*- nroff -*- | 3 | .\" -*- nroff -*- |
4 | .\" | 4 | .\" |
@@ -55,7 +55,10 @@ | |||
55 | .Nm | 55 | .Nm |
56 | adds RSA or DSA identities to the authentication agent, | 56 | adds RSA or DSA identities to the authentication agent, |
57 | .Xr ssh-agent 1 . | 57 | .Xr ssh-agent 1 . |
58 | When run without arguments, it adds the file | 58 | When run without arguments, it adds the files |
59 | .Pa $HOME/.ssh/id_rsa , | ||
60 | .Pa $HOME/.ssh/id_dsa | ||
61 | and | ||
59 | .Pa $HOME/.ssh/identity . | 62 | .Pa $HOME/.ssh/identity . |
60 | Alternative file names can be given on the command line. | 63 | Alternative file names can be given on the command line. |
61 | If any file requires a passphrase, | 64 | If any file requires a passphrase, |
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "includes.h" | 37 | #include "includes.h" |
38 | RCSID("$OpenBSD: ssh-add.c,v 1.47 2001/12/19 07:18:56 deraadt Exp $"); | 38 | RCSID("$OpenBSD: ssh-add.c,v 1.48 2001/12/21 10:06:43 djm Exp $"); |
39 | 39 | ||
40 | #include <openssl/evp.h> | 40 | #include <openssl/evp.h> |
41 | 41 | ||
@@ -58,6 +58,15 @@ char *__progname; | |||
58 | /* argv0 */ | 58 | /* argv0 */ |
59 | extern char *__progname; | 59 | extern char *__progname; |
60 | 60 | ||
61 | /* Default files to add */ | ||
62 | static char *default_files[] = { | ||
63 | _PATH_SSH_CLIENT_ID_RSA, | ||
64 | _PATH_SSH_CLIENT_ID_DSA, | ||
65 | _PATH_SSH_CLIENT_IDENTITY, | ||
66 | NULL | ||
67 | }; | ||
68 | |||
69 | |||
61 | /* we keep a cache of one passphrases */ | 70 | /* we keep a cache of one passphrases */ |
62 | static char *pass = NULL; | 71 | static char *pass = NULL; |
63 | static void | 72 | static void |
@@ -210,6 +219,19 @@ list_identities(AuthenticationConnection *ac, int do_fp) | |||
210 | printf("The agent has no identities.\n"); | 219 | printf("The agent has no identities.\n"); |
211 | } | 220 | } |
212 | 221 | ||
222 | static int | ||
223 | do_file(AuthenticationConnection *ac, int deleting, char *file) | ||
224 | { | ||
225 | if (deleting) { | ||
226 | if (delete_file(ac, file) == -1) | ||
227 | return -1; | ||
228 | } else { | ||
229 | if (add_file(ac, file) == -1) | ||
230 | return -1; | ||
231 | } | ||
232 | return 0; | ||
233 | } | ||
234 | |||
213 | static void | 235 | static void |
214 | usage(void) | 236 | usage(void) |
215 | { | 237 | { |
@@ -231,8 +253,6 @@ main(int argc, char **argv) | |||
231 | extern char *optarg; | 253 | extern char *optarg; |
232 | extern int optind; | 254 | extern int optind; |
233 | AuthenticationConnection *ac = NULL; | 255 | AuthenticationConnection *ac = NULL; |
234 | struct passwd *pw; | ||
235 | char buf[1024]; | ||
236 | char *sc_reader_id = NULL; | 256 | char *sc_reader_id = NULL; |
237 | int i, ch, deleting = 0, ret = 0; | 257 | int i, ch, deleting = 0, ret = 0; |
238 | 258 | ||
@@ -284,30 +304,26 @@ main(int argc, char **argv) | |||
284 | goto done; | 304 | goto done; |
285 | } | 305 | } |
286 | if (argc == 0) { | 306 | if (argc == 0) { |
287 | pw = getpwuid(getuid()); | 307 | char buf[MAXPATHLEN]; |
288 | if (!pw) { | 308 | struct passwd *pw; |
309 | |||
310 | if ((pw = getpwuid(getuid())) == NULL) { | ||
289 | fprintf(stderr, "No user found with uid %u\n", | 311 | fprintf(stderr, "No user found with uid %u\n", |
290 | (u_int)getuid()); | 312 | (u_int)getuid()); |
291 | ret = 1; | 313 | ret = 1; |
292 | goto done; | 314 | goto done; |
293 | } | 315 | } |
294 | snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, _PATH_SSH_CLIENT_IDENTITY); | 316 | |
295 | if (deleting) { | 317 | for(i = 0; default_files[i]; i++) { |
296 | if (delete_file(ac, buf) == -1) | 318 | snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, |
297 | ret = 1; | 319 | default_files[i]); |
298 | } else { | 320 | if (do_file(ac, deleting, buf) == -1) |
299 | if (add_file(ac, buf) == -1) | ||
300 | ret = 1; | 321 | ret = 1; |
301 | } | 322 | } |
302 | } else { | 323 | } else { |
303 | for (i = 0; i < argc; i++) { | 324 | for(i = 0; i < argc; i++) { |
304 | if (deleting) { | 325 | if (do_file(ac, deleting, argv[1]) == -1) |
305 | if (delete_file(ac, argv[i]) == -1) | 326 | ret = 1; |
306 | ret = 1; | ||
307 | } else { | ||
308 | if (add_file(ac, argv[i]) == -1) | ||
309 | ret = 1; | ||
310 | } | ||
311 | } | 327 | } |
312 | } | 328 | } |
313 | clear_pass(); | 329 | clear_pass(); |