]> andersk Git - gssapi-openssh.git/blobdiff - openssh/ssh-keysign.c
Merge from OPENSSH_3_8_1P1_GSSAPI_20040713 to OPENSSH_3_9P1_GSSAPI_20040818.
[gssapi-openssh.git] / openssh / ssh-keysign.c
index 0a4e203f9b490b19a6cd6d690cbd0df931a026cb..633ba7557cb3ffd6fbd98de41e23fc2d9ed76a49 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.15 2004/01/19 21:25:15 markus Exp $");
+RCSID("$OpenBSD: ssh-keysign.c,v 1.16 2004/04/18 23:10:26 djm Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/rand.h>
@@ -41,15 +41,12 @@ RCSID("$OpenBSD: ssh-keysign.c,v 1.15 2004/01/19 21:25:15 markus Exp $");
 #include "canohost.h"
 #include "pathnames.h"
 #include "readconf.h"
+#include "uidswap.h"
 
 /* XXX readconf.c needs these */
 uid_t original_real_uid;
 
-#ifdef HAVE___PROGNAME
 extern char *__progname;
-#else
-char *__progname;
-#endif
 
 static int
 valid_request(struct passwd *pw, char *host, Key **ret, u_char *data,
@@ -156,8 +153,11 @@ 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());
+       if ((pw = getpwuid(getuid())) == NULL)
+               fatal("getpwuid failed");
+       pw = pwcopy(pw);
+
+       permanently_set_uid(pw);
 
        init_rng();
        seed_rng();
@@ -170,7 +170,7 @@ main(int argc, char **argv)
        /* 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);
+       (void)read_config_file(_PATH_HOST_CONFIG_FILE, "", &options, 0);
        fill_default_options(&options);
        if (options.enable_ssh_keysign != 1)
                fatal("ssh-keysign not enabled in %s",
@@ -179,10 +179,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.115481 seconds and 4 git commands to generate.