summaryrefslogtreecommitdiffstats
path: root/pw/pw_user.c
diff options
context:
space:
mode:
authorDavid Nugent <davidn@FreeBSD.org>1997-01-03 04:42:18 +0000
committerDavid Nugent <davidn@FreeBSD.org>1997-01-03 04:42:18 +0000
commit91cc63d0c0bd148b5a03490dc0b4781979e16d08 (patch)
tree7a6310ddcba46a936d5e59b4fc711b10d2d9f03e /pw/pw_user.c
parentfd44fb4b2b7932e01292d983f3e3b64f3b04279c (diff)
downloadpw-darwin-91cc63d0c0bd148b5a03490dc0b4781979e16d08.tar.gz
pw-darwin-91cc63d0c0bd148b5a03490dc0b4781979e16d08.tar.zst
pw-darwin-91cc63d0c0bd148b5a03490dc0b4781979e16d08.zip
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 'pw/pw_user.c')
-rw-r--r--pw/pw_user.c39
1 files changed, 28 insertions, 11 deletions
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 <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));
}