Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Oct 2010 09:40:11 GMT
From:      Dmitry Banshchikov <ubique@peterhost.ru>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/150988: adduser(8) problem of directory mode
Message-ID:  <201010220940.o9M9eBOk011194@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/150988; it has been noted by GNATS.

From: Dmitry Banshchikov <ubique@peterhost.ru>
To: bug-followup@FreeBSD.org, zrcvic@foxmail.com
Cc:  
Subject: Re: bin/150988: adduser(8) problem of directory mode
Date: Fri, 22 Oct 2010 13:16:57 +0400

 Hello,
 
 adduser is shell script, which runs pw utility with gathered arguments.
 There is a check for existence of a home directory in pw_user.c, and if
 homedir does not exist pw will create it with the permissions of target
 user directory (Set by example with -M option to pw). Should pw always
 create homedir with permissions 755 to be accessible by all users?
 
 
 --- pw_user.c	2010-10-22 12:53:19.000000000 +0400
 +++ pw_user.c	2010-10-22 12:56:11.000000000 +0400
 @@ -186,7 +186,10 @@
  			if (strchr(cnf->home+1, '/') == NULL) {
  				strcpy(dbuf, "/usr");
  				strncat(dbuf, cnf->home, MAXPATHLEN-5);
 -				if (mkdir(dbuf, cnf->homemode) != -1 || errno == EEXIST) {
 +				/* Home directory should be accessible by all users,
 +				 * so by default set permissions to 0755
 +				 */
 +				if (mkdir(dbuf, 0755) != -1 || errno == EEXIST) {
  					chown(dbuf, 0, 0);
  					/*
  					 * Skip first "/" and create symlink:
 @@ -202,7 +205,7 @@
  				while ((p = strchr(++p, '/')) != NULL) {
  					*p = '\0';
  					if (stat(dbuf, &st) == -1) {
 -						if (mkdir(dbuf, cnf->homemode) == -1)
 +						if (mkdir(dbuf, 0755) == -1)
  							goto direrr;
  						chown(dbuf, 0, 0);
  					} else if (!S_ISDIR(st.st_mode))
 
 
 -- 
 
 Dmitry Banshchikov



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010220940.o9M9eBOk011194>