- 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@
This commit is contained in:
parent
f451e22e21
commit
6e1057c2d7
|
@ -16,6 +16,10 @@
|
||||||
- djm@cvs.openbsd.org 2001/12/21 08:53:45
|
- djm@cvs.openbsd.org 2001/12/21 08:53:45
|
||||||
[readpass.c]
|
[readpass.c]
|
||||||
Avoid interruptable passphrase read; ok markus@
|
Avoid interruptable passphrase read; ok markus@
|
||||||
|
- 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@
|
||||||
|
|
||||||
20020121
|
20020121
|
||||||
- (djm) Rework ssh-rand-helper:
|
- (djm) Rework ssh-rand-helper:
|
||||||
|
@ -7163,4 +7167,4 @@
|
||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1726 2002/01/22 12:05:31 djm Exp $
|
$Id: ChangeLog,v 1.1727 2002/01/22 12:05:59 djm Exp $
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $OpenBSD: ssh-add.1,v 1.27 2001/08/23 18:08:59 stevesk Exp $
|
.\" $OpenBSD: ssh-add.1,v 1.28 2001/12/21 10:06:43 djm Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" -*- nroff -*-
|
.\" -*- nroff -*-
|
||||||
.\"
|
.\"
|
||||||
|
@ -55,7 +55,10 @@
|
||||||
.Nm
|
.Nm
|
||||||
adds RSA or DSA identities to the authentication agent,
|
adds RSA or DSA identities to the authentication agent,
|
||||||
.Xr ssh-agent 1 .
|
.Xr ssh-agent 1 .
|
||||||
When run without arguments, it adds the file
|
When run without arguments, it adds the files
|
||||||
|
.Pa $HOME/.ssh/id_rsa ,
|
||||||
|
.Pa $HOME/.ssh/id_dsa
|
||||||
|
and
|
||||||
.Pa $HOME/.ssh/identity .
|
.Pa $HOME/.ssh/identity .
|
||||||
Alternative file names can be given on the command line.
|
Alternative file names can be given on the command line.
|
||||||
If any file requires a passphrase,
|
If any file requires a passphrase,
|
||||||
|
|
54
ssh-add.c
54
ssh-add.c
|
@ -35,7 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: ssh-add.c,v 1.47 2001/12/19 07:18:56 deraadt Exp $");
|
RCSID("$OpenBSD: ssh-add.c,v 1.48 2001/12/21 10:06:43 djm Exp $");
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
|
@ -58,6 +58,15 @@ char *__progname;
|
||||||
/* argv0 */
|
/* argv0 */
|
||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
|
|
||||||
|
/* Default files to add */
|
||||||
|
static char *default_files[] = {
|
||||||
|
_PATH_SSH_CLIENT_ID_RSA,
|
||||||
|
_PATH_SSH_CLIENT_ID_DSA,
|
||||||
|
_PATH_SSH_CLIENT_IDENTITY,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* we keep a cache of one passphrases */
|
/* we keep a cache of one passphrases */
|
||||||
static char *pass = NULL;
|
static char *pass = NULL;
|
||||||
static void
|
static void
|
||||||
|
@ -210,6 +219,19 @@ list_identities(AuthenticationConnection *ac, int do_fp)
|
||||||
printf("The agent has no identities.\n");
|
printf("The agent has no identities.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
do_file(AuthenticationConnection *ac, int deleting, char *file)
|
||||||
|
{
|
||||||
|
if (deleting) {
|
||||||
|
if (delete_file(ac, file) == -1)
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
if (add_file(ac, file) == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
@ -231,8 +253,6 @@ main(int argc, char **argv)
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
AuthenticationConnection *ac = NULL;
|
AuthenticationConnection *ac = NULL;
|
||||||
struct passwd *pw;
|
|
||||||
char buf[1024];
|
|
||||||
char *sc_reader_id = NULL;
|
char *sc_reader_id = NULL;
|
||||||
int i, ch, deleting = 0, ret = 0;
|
int i, ch, deleting = 0, ret = 0;
|
||||||
|
|
||||||
|
@ -284,30 +304,26 @@ main(int argc, char **argv)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
pw = getpwuid(getuid());
|
char buf[MAXPATHLEN];
|
||||||
if (!pw) {
|
struct passwd *pw;
|
||||||
|
|
||||||
|
if ((pw = getpwuid(getuid())) == NULL) {
|
||||||
fprintf(stderr, "No user found with uid %u\n",
|
fprintf(stderr, "No user found with uid %u\n",
|
||||||
(u_int)getuid());
|
(u_int)getuid());
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, _PATH_SSH_CLIENT_IDENTITY);
|
|
||||||
if (deleting) {
|
for(i = 0; default_files[i]; i++) {
|
||||||
if (delete_file(ac, buf) == -1)
|
snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir,
|
||||||
ret = 1;
|
default_files[i]);
|
||||||
} else {
|
if (do_file(ac, deleting, buf) == -1)
|
||||||
if (add_file(ac, buf) == -1)
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < argc; i++) {
|
for(i = 0; i < argc; i++) {
|
||||||
if (deleting) {
|
if (do_file(ac, deleting, argv[1]) == -1)
|
||||||
if (delete_file(ac, argv[i]) == -1)
|
ret = 1;
|
||||||
ret = 1;
|
|
||||||
} else {
|
|
||||||
if (add_file(ac, argv[i]) == -1)
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clear_pass();
|
clear_pass();
|
||||||
|
|
Loading…
Reference in New Issue