From: Ion Badulescu Date: Sun, 20 Jan 2002 22:30:46 +0000 (+0000) Subject: * hlfsd/homedir.c: made some global vars static X-Git-Tag: am-utils-6_0_8~34 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=5400a08394ccd479fd649044f6151f16f1d6baf9;p=am-utils-6.0.git * hlfsd/homedir.c: made some global vars static (plt_init): remove all trailing '/' chars from root's home --- diff --git a/ChangeLog b/ChangeLog index 9bb02bd..616946a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-01-20 Ion Badulescu + + * hlfsd/homedir.c: made some global vars static + (plt_init): remove all trailing '/' chars from root's home + 2002-01-20 Ion Badulescu * hlfsd/homedir.c (homedir): don't special case uid 0 as having / diff --git a/hlfsd/homedir.c b/hlfsd/homedir.c index 4311f96..e6677a0 100644 --- a/hlfsd/homedir.c +++ b/hlfsd/homedir.c @@ -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 and Alexander Dupuy @@ -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();