Bugzilla – Attachment 16 Details for
Bug 93
Added ability for ssh-add to parse config files to retrieve a list of valid IdentityFiles.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
ssh-add.c patch to search ssh_config for IdentityFile(s)
ssh-add.patch (text/plain), 4.15 KB, created by
Jason Prondak
on 2002-02-02 08:45:40 AEDT
(
hide
)
Description:
ssh-add.c patch to search ssh_config for IdentityFile(s)
Filename:
MIME Type:
Creator:
Jason Prondak
Created:
2002-02-02 08:45:40 AEDT
Size:
4.15 KB
patch
obsolete
>Index: 3_0_2p1.1/ssh-add.c >--- 3_0_2p1.1/ssh-add.c Wed, 21 Nov 2001 10:38:46 -0500 jd (OpenSSH/h/50_ssh-add.c 1.1.1.1 644) >+++ 3_0_2p1_ssh_add_conf.1(w)/ssh-add.c Fri, 01 Feb 2002 16:16:53 -0500 prondaja (OpenSSH/h/50_ssh-add.c 1.1.1.1.1.1 644) >@@ -48,6 +48,7 @@ > #include "authfile.h" > #include "pathnames.h" > #include "readpass.h" >+#include "readconf.h" > > #ifdef HAVE___PROGNAME > extern char *__progname; >@@ -58,8 +59,14 @@ > /* argv0 */ > extern char *__progname; > >+/* Original real UID. */ >+uid_t original_real_uid; >+ > /* we keep a cache of one passphrases */ > static char *pass = NULL; >+static char *passphrases[SSH_MAX_IDENTITY_FILES]; >+static int num_passphrases = 0; >+ > static void > clear_pass(void) > { >@@ -120,7 +127,7 @@ > Key *private; > char *comment = NULL; > char msg[1024]; >- int ret = -1; >+ int i, ret = -1; > > if (stat(filename, &st) < 0) { > perror(filename); >@@ -131,8 +138,13 @@ > if (comment == NULL) > comment = xstrdup(filename); > /* try last */ >- if (private == NULL && pass != NULL) >- private = key_load_private(filename, pass, NULL); >+ if (private == NULL && *passphrases != NULL) >+ for (i = 0; i < num_passphrases; i++) { >+ private = key_load_private(filename, passphrases[i], NULL); >+ if (private != NULL) >+ break; >+ } >+ > if (private == NULL) { > /* clear passphrase since it did not work */ > clear_pass(); >@@ -155,6 +167,13 @@ > if (ssh_add_identity(ac, private, comment)) { > fprintf(stderr, "Identity added: %s (%s)\n", filename, comment); > ret = 0; >+ if ( pass != NULL ) >+ passphrases[num_passphrases++] = xstrdup(pass); >+ if (num_passphrases >= SSH_MAX_IDENTITY_FILES) { >+ fprintf(stderr,"Too many identity files specified (max %d).", >+ SSH_MAX_IDENTITY_FILES); >+ exit(1); >+ } > } else > fprintf(stderr, "Could not add identity: %s\n", filename); > >@@ -232,14 +251,20 @@ > extern int optind; > AuthenticationConnection *ac = NULL; > struct passwd *pw; >+ struct stat st; >+ Options options; > char buf[1024]; > char *sc_reader_id = NULL; >+ char *host = "nullhost"; >+ char *filename; > int i, ch, deleting = 0, ret = 0; > > __progname = get_progname(argv[0]); >+ *passphrases = NULL; > init_rng(); > seed_rng(); > >+ original_real_uid = getuid(); > SSLeay_add_all_algorithms(); > > /* At first, get a connection to the authentication agent. */ >@@ -291,13 +316,30 @@ > ret = 1; > goto done; > } >- snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, _PATH_SSH_CLIENT_IDENTITY); >- if (deleting) { >- if (delete_file(ac, buf) == -1) >- ret = 1; >- } else { >- if (add_file(ac, buf) == -1) >- ret = 1; >+ >+ /* Read per-user configuration file. */ >+ snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, >+ _PATH_SSH_USER_CONFFILE); >+ >+ initialize_options(&options); >+ read_config_file(buf, host, &options); >+ >+ /* Read systemwide configuration file. */ >+ read_config_file(_PATH_HOST_CONFIG_FILE, host, &options); >+ >+ for (i = 0; i < options.num_identity_files; i++) { >+ filename = tilde_expand_filename(options.identity_files[i], >+ getuid()); >+ if (stat(filename,&st) != 0) { >+ xfree(options.identity_files[i]); >+ continue; >+ } >+ >+ if (deleting) >+ delete_file(ac, filename); >+ else >+ add_file(ac, filename); >+ xfree(options.identity_files[i]); > } > } else { > for (i = 0; i < argc; i++) { >@@ -314,5 +356,8 @@ > > done: > ssh_close_authentication_connection(ac); >+ for(i = 0; i < num_passphrases; i++) >+ if (passphrases[i]) >+ xfree(passphrases[i]); > return ret; > } >Index: 3_0_2p1.1/Makefile.in >--- 3_0_2p1.1/Makefile.in Wed, 21 Nov 2001 10:38:46 -0500 jd (OpenSSH/l/19_Makefile.i 1.1.1.1 644) >+++ 3_0_2p1_ssh_add_conf.1(w)/Makefile.in Fri, 01 Feb 2002 13:48:32 -0500 prondaja (OpenSSH/l/19_Makefile.i 1.1.1.1.1.1 644) >@@ -103,8 +103,8 @@ > scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o > $(LD) -o $@ scp.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) > >-ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o >- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) >+ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o readconf.o >+ $(LD) -o $@ ssh-add.o readconf.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) > > ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o > $(LD) -o $@ ssh-agent.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 93
: 16