]> andersk Git - openssh.git/blobdiff - ssh-keysign.c
- (tim) [configure.ac] Bug 1078. Fix --without-kerberos5. Reported by
[openssh.git] / ssh-keysign.c
index cf8b0c2d2b2918bef5f48ff3b7c82e3d2aeacdb8..04597a91d4d45eb2f4ed6ca8b897bd920d2aae6d 100644 (file)
@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "includes.h"
-RCSID("$OpenBSD: ssh-keysign.c,v 1.16 2004/04/18 23:10:26 djm Exp $");
+RCSID("$OpenBSD: ssh-keysign.c,v 1.18 2004/08/23 14:29:23 dtucker Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/rand.h>
@@ -41,6 +41,7 @@ RCSID("$OpenBSD: ssh-keysign.c,v 1.16 2004/04/18 23:10:26 djm Exp $");
 #include "canohost.h"
 #include "pathnames.h"
 #include "readconf.h"
+#include "uidswap.h"
 
 /* XXX readconf.c needs these */
 uid_t original_real_uid;
@@ -150,8 +151,12 @@ main(int argc, char **argv)
        key_fd[0] = open(_PATH_HOST_RSA_KEY_FILE, O_RDONLY);
        key_fd[1] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY);
 
-       seteuid(getuid());
-       setuid(getuid());
+       original_real_uid = getuid();   /* XXX readconf.c needs this */
+       if ((pw = getpwuid(original_real_uid)) == NULL)
+               fatal("getpwuid failed");
+       pw = pwcopy(pw);
+
+       permanently_set_uid(pw);
 
        init_rng();
        seed_rng();
@@ -162,7 +167,6 @@ main(int argc, char **argv)
 #endif
 
        /* verify that ssh-keysign is enabled by the admin */
-       original_real_uid = getuid();   /* XXX readconf.c needs this */
        initialize_options(&options);
        (void)read_config_file(_PATH_HOST_CONFIG_FILE, "", &options, 0);
        fill_default_options(&options);
@@ -173,10 +177,6 @@ main(int argc, char **argv)
        if (key_fd[0] == -1 && key_fd[1] == -1)
                fatal("could not open any host key");
 
-       if ((pw = getpwuid(getuid())) == NULL)
-               fatal("getpwuid failed");
-       pw = pwcopy(pw);
-
        SSLeay_add_all_algorithms();
        for (i = 0; i < 256; i++)
                rnd[i] = arc4random();
This page took 0.032992 seconds and 4 git commands to generate.