chiark / gitweb /
server/keyexch.c: Check that all of the algorithms match when setting up.
[tripe] / common / util.c
index 92b9853d2cb789e3e7fdd0ace0ec2adef7d0a190..3de554d72a35d1530f09bc86b7af0b54604ac79f 100644 (file)
@@ -70,6 +70,7 @@ void u_quotify(dstr *d, const char *p)
     }
     dstr_putc(d, '\"');
   }
     }
     dstr_putc(d, '\"');
   }
+  dstr_putz(d);
 }
 
 /* --- @u_getuser@ --- *
 }
 
 /* --- @u_getuser@ --- *
@@ -137,7 +138,9 @@ gid_t u_getgroup(const char *name)
 
 void u_setugid(uid_t u, gid_t g)
 {
 
 void u_setugid(uid_t u, gid_t g)
 {
-  if (g != (gid_t)-1) {
+  uid_t cu = geteuid();
+
+  if (cu == 0 && g != (gid_t)-1) {
     if (setgid(g) || (getuid() == 0 && setgroups(1, &g))) {
       die(EXIT_FAILURE, "couldn't setgid to %u: %s",
          (unsigned)g, strerror(errno));
     if (setgid(g) || (getuid() == 0 && setgroups(1, &g))) {
       die(EXIT_FAILURE, "couldn't setgid to %u: %s",
          (unsigned)g, strerror(errno));