#12 Read HOME_MODE and UMASK from /etc/login.defs
Merged 3 years ago by abbra. Opened 3 years ago by abbra.
abbra/oddjob support-home-mode  into  master

file modified
+9 -4
@@ -264,12 +264,13 @@ 

  }

  

  static mode_t

- get_umask(int *configured)

+ get_umask(int *configured, const char *variable)

  {

  	FILE *fp;

  	char buf[BUFSIZ], *p, *end;

  	mode_t mask = umask(0777);

  	long tmp;

+ 	size_t vlen = strlen(variable);

  

  	fp = fopen("/etc/login.defs", "r");

  	if (fp != NULL) {
@@ -279,10 +280,10 @@ 

  			}

  			buf[strcspn(buf, "\r\n")] = '\0';

  			p = buf + strspn(buf, " \t");

- 			if (strncmp(p, "UMASK", 5) != 0) {

+ 			if (strncmp(p, variable, vlen) != 0) {

  				continue;

  			}

- 			p += 5;

+ 			p += vlen;

  			if (strspn(p, " \t") == 0) {

  				continue;

  			}
@@ -308,7 +309,11 @@ 

  	int i, configured_umask = 0, flags = FLAG_POPULATE;

  

  	openlog(PACKAGE "-mkhomedir", LOG_PID, LOG_DAEMON);

- 	override_umask = get_umask(&configured_umask);

+ 	/* Unlike UMASK, HOME_MODE is the file mode, so needs to be reverted */

+ 	override_umask = 0777 & ~get_umask(&configured_umask, "HOME_MODE");

+ 	if (configured_umask == 0) {

+ 		override_umask = get_umask(&configured_umask, "UMASK");

+ 	}

  	umask(override_umask);

  	skel_dir = "/etc/skel";

  

@@ -24,7 +24,8 @@ 

  -u

  Specify a umask whose bits are masked off of contents of the skeleton directory

  while they are copied to the user's new home directory.  The default is read

- from \fB/etc/login.defs\fR.

+ from \fB/etc/login.defs\fR by taking \fBHOME_MODE\fR and \fBUMASK\fR values, in

+ this order.  First found value persists.

  

  .SH SEE ALSO

  \fBoddjob.conf\fR(5)

@@ -14,8 +14,9 @@ 

  \fImkmyhomedir\fR method.

  

  The location of the skeleton directory and the default umask are determined by

- the configuration for the corresponding service in \fBoddjobd-mkhomedir.conf\fR,

- so they can not be specified as arguments to this module.

+ the values of \fBHOME_MODE\fR or \fBUMASK\fR (as a fallback) variables in

+ \fI/etc/login.defs\fR, so they can not be specified as arguments to this

+ module.

  

  If \fID-Bus\fR has not been configured to allow the calling application to

  invoke these methods provided as part of the \fI@NAMESPACE@.oddjob_mkhomedir\fR

shadow-utils changed behavior of UMASK to only apply to runtime
processes. For home directories, HOME_MODE variable was introduced
instead.

Read HOME_MODE and fall back to UMASK if that does not exist.

Signed-off-by: Alexander Bokovoy abokovoy@redhat.com

rebased onto 594c64f

3 years ago

pretty please pagure-ci rebuild

3 years ago

rebased onto 78a4935

3 years ago

rebased onto c51b28a

3 years ago

Pull-Request has been merged by abbra

3 years ago