summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh-add.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-06-26 05:00:00 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-06-26 05:00:00 +0000
commite7badc12a8fd48358a2fd9740d50db697b1880b7 (patch)
treeffb9c9c6a2f503469b53782189b37dce2b077c76 /usr.bin/ssh/ssh-add.c
parent5dd90aa4527c92a41b35cb213e76451fc5598a2e (diff)
initial support for smartcards in the agent
Diffstat (limited to 'usr.bin/ssh/ssh-add.c')
-rw-r--r--usr.bin/ssh/ssh-add.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c
index c168d906386..0cf7031d95b 100644
--- a/usr.bin/ssh/ssh-add.c
+++ b/usr.bin/ssh/ssh-add.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-add.c,v 1.41 2001/06/25 08:25:40 markus Exp $");
+RCSID("$OpenBSD: ssh-add.c,v 1.42 2001/06/26 04:59:59 markus Exp $");
#include <openssl/evp.h>
@@ -144,6 +144,17 @@ add_file(AuthenticationConnection *ac, const char *filename)
}
static void
+update_card(AuthenticationConnection *ac, int add, int id)
+{
+ if (ssh_update_card(ac, add, id))
+ fprintf(stderr, "Card %s: %d\n",
+ add ? "added" : "removed", id);
+ else
+ fprintf(stderr, "Could not %s card: %d\n",
+ add ? "add" : "remove", id);
+}
+
+static void
list_identities(AuthenticationConnection *ac, int do_fp)
{
Key *key;
@@ -175,6 +186,18 @@ list_identities(AuthenticationConnection *ac, int do_fp)
printf("The agent has no identities.\n");
}
+static void
+usage(void)
+{
+ printf("Usage: ssh-add [options]\n");
+ printf(" -l, -L : list identities\n");
+ printf(" -d : delete identity\n");
+ printf(" -D : delete all identities\n");
+ printf(" -s reader_num : add key in the smartcard in reader_num.\n");
+ printf(" -e reader_num : remove key in the smartcard in reader_num.\n");
+ exit (1);
+}
+
int
main(int argc, char **argv)
{
@@ -184,6 +207,8 @@ main(int argc, char **argv)
int no_files = 1;
int i;
int deleting = 0;
+ int sc_mode = 0;
+ int sc_reader_num = 0;
SSLeay_add_all_algorithms();
@@ -210,12 +235,37 @@ main(int argc, char **argv)
no_files = 0;
continue;
}
+ if (strcmp(argv[i], "-s") == 0) {
+ sc_mode = 1;
+ deleting = 0;
+ i++;
+ if (i >= argc)
+ usage();
+ sc_reader_num = atoi(argv[i]);
+ continue;
+ }
+ if (strcmp(argv[i], "-e") == 0) {
+ sc_mode = 1;
+ deleting = 1;
+ i++;
+ if (i >= argc)
+ usage();
+ sc_reader_num = atoi(argv[i]);
+ continue;
+ }
+ if (sc_mode == 1)
+ update_card(ac, !deleting, sc_reader_num);
no_files = 0;
if (deleting)
delete_file(ac, argv[i]);
else
add_file(ac, argv[i]);
}
+ if (sc_mode == 1) {
+ update_card(ac, !deleting, sc_reader_num);
+ ssh_close_authentication_connection(ac);
+ exit(0);
+ }
if (no_files) {
pw = getpwuid(getuid());
if (!pw) {