summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw/pw_user.c
diff options
context:
space:
mode:
authordavidn <davidn@FreeBSD.org>1997-01-03 04:42:18 +0000
committerdavidn <davidn@FreeBSD.org>1997-01-03 04:42:18 +0000
commitb755851a75932ff275e1d0b9fd2283b881a80139 (patch)
treebb663e6ffb998b099a6665b6f8c99f3ed7f368f9 /usr.sbin/pw/pw_user.c
parentcfcb6afefe2118a628d11751db983b848edc3371 (diff)
downloadFreeBSD-src-b755851a75932ff275e1d0b9fd2283b881a80139.zip
FreeBSD-src-b755851a75932ff275e1d0b9fd2283b881a80139.tar.gz
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.
Diffstat (limited to 'usr.sbin/pw/pw_user.c')
-rw-r--r--usr.sbin/pw/pw_user.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 049321d..14b618f 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/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 <unistd.h>
@@ -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));
}
OpenPOWER on IntegriCloud