Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2004-05-15 14:50:19 UTC

Modified files:
     ChangeLog ircd/version.c.SH tools/wrapper.c

Log message:

Fix uid bug in chroot wrapper.
Fix calculation of "generation" in version.c.SH.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.400 ircu2.10/ChangeLog:1.401
--- ircu2.10/ChangeLog:1.400    Sat May 15 07:44:56 2004
+++ ircu2.10/ChangeLog  Sat May 15 07:50:07 2004
@@ -1,3 +1,11 @@
+2004-05-15  Kevin L Mitchell  <[EMAIL PROTECTED]>
+
+       [Original ChangeLog date: 2003-11-22 -MDP]
+
+       * tools/wrapper.c: commit uid on chroot fix from ubra
+
+       * ircd/version.c.SH: fix generation generation
+
 2004-05-15  Isomer <[EMAIL PROTECTED]>
 
        [Original ChangeLog date: 2003-11-23 -MDP]
Index: ircu2.10/ircd/version.c.SH
diff -u ircu2.10/ircd/version.c.SH:1.5 ircu2.10/ircd/version.c.SH:1.6
--- ircu2.10/ircd/version.c.SH:1.5      Sun May  9 18:32:50 2004
+++ ircu2.10/ircd/version.c.SH  Sat May 15 07:50:09 2004
@@ -4,7 +4,7 @@
 
 if test -r version.c
 then
-   generation=`sed -n 's/^char \*generation = \"\(.*\)\";/\1/p' < version.c`
+   generation=`sed -n 's/^const char \*generation = \"\(.*\)\";/\1/p' < version.c`
    if test ! "$generation" ; then generation=0; fi
 else
    generation=0
Index: ircu2.10/tools/wrapper.c
diff -u ircu2.10/tools/wrapper.c:1.2 ircu2.10/tools/wrapper.c:1.3
--- ircu2.10/tools/wrapper.c:1.2        Thu Mar  7 14:52:57 2002
+++ ircu2.10/tools/wrapper.c    Sat May 15 07:50:09 2004
@@ -1,5 +1,4 @@
 /*
-** IRC - Internet Relay Chat, tools/wrapper.c
 ** Copyright (C) 2000 by Kevin L. Mitchell <[EMAIL PROTECTED]>
 **
 ** This program is free software; you can redistribute it and/or modify
@@ -16,7 +15,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 **
-** @(#)$Id: wrapper.c,v 1.2 2002/03/07 22:52:57 ghostwolf Exp $
+** @(#)$Id: wrapper.c,v 1.3 2004/05/15 14:50:09 entrope Exp $
 */
 #include <string.h>
 #include <stdlib.h>
@@ -48,6 +47,9 @@
 #endif
 #endif
 
+/*fix for change uid/gid with chroot #ubra 08/02/03*/
+int uid, gid;
+
 /*
  * Set the hard and soft limits for maximum file descriptors.
  */
@@ -79,14 +81,16 @@
 /*
  * Change the user and group ids--including supplementary groups!--as
  * appropriate.
+ *
+ * fix for change uid/gid with chroot #ubra 08/02/03
+ * old change_user() got splited into get_user() and set_user()
  */
 int
-change_user(char *user, char *group)
+get_user(char *user, char *group)
 {
   struct passwd *pwd;
   struct group *grp;
   char *tmp;
-  int uid, gid;
 
   /* Track down a struct passwd describing the desired user */
   uid = strtol(user, &tmp, 10); /* was the user given as a number? */
@@ -112,6 +116,11 @@
 
   if (initgroups(pwd->pw_name, gid)) /* initialize supplementary groups */
     return -1;
+  return 0; /* success! */
+}
+
+int
+set_user(void) {
   if (setgid(gid)) /* change our current group */
     return -1;
   if (setuid(uid)) /* change our current user */
@@ -183,6 +192,13 @@
       return 1;
     }
 
+  if(user) /* get the selected user account uid/gid*/
+   if (get_user(user, group)) {
+     perror(prog);
+     return 1;
+   }
+
+
   if (root) /* change root directories */
     if (change_root(root)) {
       perror(prog);
@@ -190,7 +206,7 @@
     }
 
   if (user) /* change to selected user account */
-    if (change_user(user, group)) {
+    if (set_user()) {
       perror(prog);
       return 1;
     }
----------------------- End of diff -----------------------

Reply via email to