* hlfsd/homedir.c: made some global vars static
authorIon Badulescu <ib42@cs.columbia.edu>
Sun, 20 Jan 2002 22:30:46 +0000 (22:30 +0000)
committerIon Badulescu <ib42@cs.columbia.edu>
Sun, 20 Jan 2002 22:30:46 +0000 (22:30 +0000)
(plt_init): remove all trailing '/' chars from root's home

ChangeLog
hlfsd/homedir.c

index 9bb02bd581bc7fc0f6b9348282c474fbb8ddfb13..616946a2cc872ec3831e92cd3f8d8f344bd72a0d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-01-20  Ion Badulescu  <lionut@gonzales.badula.org>
+
+       * hlfsd/homedir.c: made some global vars static
+       (plt_init): remove all trailing '/' chars from root's home
+
 2002-01-20  Ion Badulescu  <lionut@gonzales.badula.org>
 
        * hlfsd/homedir.c (homedir): don't special case uid 0 as having /
index 4311f96fcf9065814d11db64397b5be6e474446f..e6677a04619efd4ed3d57bc9a02e3cc7879f4389 100644 (file)
@@ -38,7 +38,7 @@
  *
  *      %W% (Berkeley) %G%
  *
- * $Id: homedir.c,v 1.5.2.4 2002/01/20 22:15:03 ib42 Exp $
+ * $Id: homedir.c,v 1.5.2.5 2002/01/20 22:30:47 ib42 Exp $
  *
  * HLFSD was written at Columbia University Computer Science Department, by
  * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
@@ -67,17 +67,16 @@ static uid2home_t *lastchild;
 static uid2home_t *pwtab;
 static void delay(uid2home_t *, int);
 static void table_add(int, const char *, const char *);
+static char mboxfile[MAXPATHLEN];
+static char *root_home;                /* root's home directory */
 
 /* GLOBAL FUNCTIONS */
 char *homeof(char *username);
 int uidof(char *username);
 
 /* GLOBALS VARIABLES */
-char mboxfile[MAXPATHLEN];
 username2uid_t *untab;         /* user name table */
 
-char *root_home;               /* root's home directory */
-
 /*
  * Return the home directory pathname for the user with uid "userid".
  */
@@ -570,9 +569,16 @@ plt_init(void)
   while ((pent_p = hlfsd_getpwent()) != (struct passwd *) NULL) {
     table_add(pent_p->pw_uid, pent_p->pw_dir, pent_p->pw_name);
     if (STREQ("root", pent_p->pw_name)) {
+      int len;
       if (root_home)
        XFREE(root_home);
       root_home = strdup(pent_p->pw_name);
+      len = strlen(root_home);
+      /* remove any trailing '/' chars from root's home (even if just one) */
+      while (len > 0 && root_home[len - 1] == '/') {
+       len--;
+       root_home[len] = '\0';
+      }
     }
   }
   hlfsd_endpwent();