]> andersk Git - openssh.git/blobdiff - authfile.c
- (djm) [sshd.c] Drop supplemental groups if started as root
[openssh.git] / authfile.c
index 24ae6abd3e2357e2ff6d4e29a5c2db10b1875d5b..83ddd635f380ff4320a7691fc530da6813722f47 100644 (file)
@@ -36,7 +36,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: authfile.c,v 1.51 2002/11/15 10:03:09 fgsch Exp $");
+RCSID("$OpenBSD: authfile.c,v 1.55 2003/09/18 07:56:05 markus Exp $");
 
 #include <openssl/err.h>
 #include <openssl/evp.h>
@@ -143,6 +143,7 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
        fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600);
        if (fd < 0) {
                error("open %s failed: %s.", filename, strerror(errno));
+               buffer_free(&encrypted);
                return 0;
        }
        if (write(fd, buffer_ptr(&encrypted), buffer_len(&encrypted)) !=
@@ -421,6 +422,12 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
        rsa_generate_additional_parameters(prv->rsa);
 
        buffer_free(&decrypted);
+
+       /* enable blinding */
+       if (RSA_blinding_on(prv->rsa, NULL) != 1) {
+               error("key_load_private_rsa1: RSA_blinding_on failed");
+               goto fail;
+       }
        close(fd);
        return prv;
 
@@ -460,6 +467,11 @@ key_load_private_pem(int fd, int type, const char *passphrase,
 #ifdef DEBUG_PK
                RSA_print_fp(stderr, prv->rsa, 8);
 #endif
+               if (RSA_blinding_on(prv->rsa, NULL) != 1) {
+                       error("key_load_private_pem: RSA_blinding_on failed");
+                       key_free(prv);
+                       prv = NULL;
+               }
        } else if (pk->type == EVP_PKEY_DSA &&
            (type == KEY_UNSPEC||type==KEY_DSA)) {
                prv = key_new(KEY_UNSPEC);
@@ -503,7 +515,7 @@ key_perm_ok(int fd, const char *filename)
                error("@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @");
                error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
                error("Permissions 0%3.3o for '%s' are too open.",
-                   st.st_mode & 0777, filename);
+                   (u_int)st.st_mode & 0777, filename);
                error("It is recommended that your private key files are NOT accessible by others.");
                error("This private key will be ignored.");
                return 0;
@@ -618,9 +630,18 @@ key_load_public(const char *filename, char **commentp)
        Key *pub;
        char file[MAXPATHLEN];
 
+       /* try rsa1 private key */
        pub = key_load_public_type(KEY_RSA1, filename, commentp);
        if (pub != NULL)
                return pub;
+
+       /* try rsa1 public key */
+       pub = key_new(KEY_RSA1);
+       if (key_try_load_public(pub, filename, commentp) == 1)
+               return pub;
+       key_free(pub);
+
+       /* try ssh2 public key */
        pub = key_new(KEY_UNSPEC);
        if (key_try_load_public(pub, filename, commentp) == 1)
                return pub;
This page took 0.143339 seconds and 4 git commands to generate.