From 91cc63d0c0bd148b5a03490dc0b4781979e16d08 Mon Sep 17 00:00:00 2001 From: David Nugent Date: Fri, 3 Jan 1997 04:42:18 +0000 Subject: Implemented /home -> /usr/home symlink kludge. If home basedir would be created in the root partition, create it under /usr instead, and symlink /basedir -> /usr/basedir. --- pw/pw_user.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'pw') diff --git a/pw/pw_user.c b/pw/pw_user.c index 049321d..14b618f 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pw_user.c,v 1.9 1996/12/23 02:27:29 davidn Exp $ + * $Id: pw_user.c,v 1.10 1996/12/30 11:52:34 davidn Exp $ */ #include @@ -148,19 +148,36 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if (stat(cnf->home, &st) == -1) { char dbuf[MAXPATHLEN]; + /* + * This is a kludge especially for Joerg :) + * If the home directory would be created in the root partition, then + * we really create it under /usr which is likely to have more space. + * But we create a symlink from cnf->home -> "/usr" -> cnf->home + */ + if (strchr(cnf->home+1, '/') == NULL) { + strcpy(dbuf, "/usr"); + strncat(dbuf, cnf->home, MAXPATHLEN-5); + if (mkdir(dbuf, 0755) != -1 || errno == EEXIST) { + chown(dbuf, 0, 0); + symlink(dbuf, cnf->home); + } + /* If this falls, fall back to old method */ + } p = strncpy(dbuf, cnf->home, sizeof dbuf); dbuf[MAXPATHLEN-1] = '\0'; - while ((p = strchr(++p, '/')) != NULL) { - *p = '\0'; - if (stat(dbuf, &st) == -1) { - if (mkdir(dbuf, 0755) == -1) - goto direrr; - chown(dbuf, 0, 0); - } else if (!S_ISDIR(st.st_mode)) - cmderr(EX_OSFILE, "'%s' (root home parent) is not a directory\n", dbuf); - *p = '/'; + if (stat(dbuf, &st) == -1) { + while ((p = strchr(++p, '/')) != NULL) { + *p = '\0'; + if (stat(dbuf, &st) == -1) { + if (mkdir(dbuf, 0755) == -1) + goto direrr; + chown(dbuf, 0, 0); + } else if (!S_ISDIR(st.st_mode)) + cmderr(EX_OSFILE, "'%s' (root home parent) is not a directory\n", dbuf); + *p = '/'; + } } - if (stat(dbuf, &st) == -1) { /* Should not be strictly necessary */ + if (stat(dbuf, &st) == -1) { if (mkdir(dbuf, 0755) == -1) { direrr: cmderr(EX_OSFILE, "mkdir '%s': %s\n", dbuf, strerror(errno)); } -- cgit v1.2.3-56-ge451