Bugzilla – Attachment 1125 Details for
Bug 1186
ssh tries multiple times to open unprotected keys
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Prevent retrying keys with bad permissions
openssh-key-retry.patch (text/plain), 5.37 KB, created by
Darren Tucker
on 2006-04-25 16:02:23 AEST
(
hide
)
Description:
Prevent retrying keys with bad permissions
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2006-04-25 16:02:23 AEST
Size:
5.37 KB
patch
obsolete
>Index: authfile.c >=================================================================== >RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/authfile.c,v >retrieving revision 1.65 >diff -u -p -r1.65 authfile.c >--- authfile.c 26 Mar 2006 03:24:49 -0000 1.65 >+++ authfile.c 25 Apr 2006 05:45:29 -0000 >@@ -538,7 +538,7 @@ key_perm_ok(int fd, const char *filename > > Key * > key_load_private_type(int type, const char *filename, const char *passphrase, >- char **commentp) >+ char **commentp, int *perm_ok) > { > int fd; > >@@ -546,10 +546,14 @@ key_load_private_type(int type, const ch > if (fd < 0) > return NULL; > if (!key_perm_ok(fd, filename)) { >+ if (perm_ok != NULL) >+ *perm_ok = 0; > error("bad permissions: ignore key: %s", filename); > close(fd); > return NULL; > } >+ if (perm_ok != NULL) >+ *perm_ok = 1; > switch (type) { > case KEY_RSA1: > return key_load_private_rsa1(fd, filename, passphrase, >Index: authfile.h >=================================================================== >RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/authfile.h,v >retrieving revision 1.10 >diff -u -p -r1.10 authfile.h >--- authfile.h 26 Mar 2006 03:30:01 -0000 1.10 >+++ authfile.h 25 Apr 2006 05:48:33 -0000 >@@ -19,7 +19,7 @@ int key_save_private(Key *, const char > Key *key_load_public(const char *, char **); > Key *key_load_public_type(int, const char *, char **); > Key *key_load_private(const char *, const char *, char **); >-Key *key_load_private_type(int, const char *, const char *, char **); >+Key *key_load_private_type(int, const char *, const char *, char **, int *); > Key *key_load_private_pem(int, int, const char *, char **); > int key_perm_ok(int, const char *); > >Index: ssh.c >=================================================================== >RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/ssh.c,v >retrieving revision 1.263 >diff -u -p -r1.263 ssh.c >--- ssh.c 31 Mar 2006 12:13:22 -0000 1.263 >+++ ssh.c 25 Apr 2006 05:54:32 -0000 >@@ -693,11 +693,11 @@ main(int ac, char **av) > > PRIV_START; > sensitive_data.keys[0] = key_load_private_type(KEY_RSA1, >- _PATH_HOST_KEY_FILE, "", NULL); >+ _PATH_HOST_KEY_FILE, "", NULL, NULL); > sensitive_data.keys[1] = key_load_private_type(KEY_DSA, >- _PATH_HOST_DSA_KEY_FILE, "", NULL); >+ _PATH_HOST_DSA_KEY_FILE, "", NULL, NULL); > sensitive_data.keys[2] = key_load_private_type(KEY_RSA, >- _PATH_HOST_RSA_KEY_FILE, "", NULL); >+ _PATH_HOST_RSA_KEY_FILE, "", NULL, NULL); > PRIV_END; > > if (options.hostbased_authentication == 1 && >Index: sshconnect1.c >=================================================================== >RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/sshconnect1.c,v >retrieving revision 1.65 >diff -u -p -r1.65 sshconnect1.c >--- sshconnect1.c 26 Mar 2006 03:24:50 -0000 1.65 >+++ sshconnect1.c 25 Apr 2006 05:53:09 -0000 >@@ -197,7 +197,7 @@ try_rsa_authentication(int idx) > BIGNUM *challenge; > Key *public, *private; > char buf[300], *passphrase, *comment, *authfile; >- int i, type, quit; >+ int i, perm_ok = 1, type, quit; > > public = options.identity_keys[idx]; > authfile = options.identity_files[idx]; >@@ -243,15 +243,16 @@ try_rsa_authentication(int idx) > if (public->flags & KEY_FLAG_EXT) > private = public; > else >- private = key_load_private_type(KEY_RSA1, authfile, "", NULL); >- if (private == NULL && !options.batch_mode) { >+ private = key_load_private_type(KEY_RSA1, authfile, "", NULL, >+ &perm_ok); >+ if (private == NULL && !options.batch_mode && perm_ok) { > snprintf(buf, sizeof(buf), > "Enter passphrase for RSA key '%.100s': ", comment); > for (i = 0; i < options.number_of_password_prompts; i++) { > passphrase = read_passphrase(buf, 0); > if (strcmp(passphrase, "") != 0) { > private = key_load_private_type(KEY_RSA1, >- authfile, passphrase, NULL); >+ authfile, passphrase, NULL, NULL); > quit = 0; > } else { > debug2("no passphrase given, try next key"); >@@ -268,7 +269,7 @@ try_rsa_authentication(int idx) > xfree(comment); > > if (private == NULL) { >- if (!options.batch_mode) >+ if (!options.batch_mode && perm_ok) > error("Bad passphrase."); > > /* Send a dummy response packet to avoid protocol error. */ >Index: sshconnect2.c >=================================================================== >RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/sshconnect2.c,v >retrieving revision 1.141 >diff -u -p -r1.141 sshconnect2.c >--- sshconnect2.c 26 Mar 2006 03:24:50 -0000 1.141 >+++ sshconnect2.c 25 Apr 2006 05:55:55 -0000 >@@ -970,14 +970,16 @@ load_identity_file(char *filename) > { > Key *private; > char prompt[300], *passphrase; >- int quit, i; >+ int perm_ok, quit, i; > struct stat st; > > if (stat(filename, &st) < 0) { > debug3("no such identity: %s", filename); > return NULL; > } >- private = key_load_private_type(KEY_UNSPEC, filename, "", NULL); >+ private = key_load_private_type(KEY_UNSPEC, filename, "", NULL, &perm_ok); >+ if (!perm_ok) >+ return NULL; > if (private == NULL) { > if (options.batch_mode) > return NULL; >@@ -986,8 +988,8 @@ load_identity_file(char *filename) > for (i = 0; i < options.number_of_password_prompts; i++) { > passphrase = read_passphrase(prompt, 0); > if (strcmp(passphrase, "") != 0) { >- private = key_load_private_type(KEY_UNSPEC, filename, >- passphrase, NULL); >+ private = key_load_private_type(KEY_UNSPEC, >+ filename, passphrase, NULL, NULL); > quit = 0; > } else { > debug2("no passphrase given, try next key");
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
Flags:
djm
:
ok+
Actions:
View
|
Diff
Attachments on
bug 1186
: 1125