7648 useradd/mod commands operate on /home special filesystem

Review Request #286 — Created Dec. 6, 2016 and updated

alp
illumos-gate
general

user* commands use hardcoded values from userdefs.h. This patch allows override them at compile time.

Built illumos-gate with following variables added in illumos.sh:

export DEFSHL=/usr/bin/bash
export DEFROLESHL=/usr/bin/pfbash
export DEFPARENT=/export/home
.

Added users using compiled useradd, generated defaults file.

diff -u /usr/include/userdefs.h ./proto/root_i386/usr/include/userdefs.h
--- /usr/include/userdefs.h 2013-08-06 22:38:41.876564000 +0400
+++ ./proto/root_i386/usr/include/userdefs.h 2016-12-06 14:39:27.447626560 +0300
@@ -31,8 +31,6 @@
#ifndef _USERDEFS_H
#define _USERDEFS_H

-#pragma ident "%Z%%M% %I% %E% SMI" / SVr4.0 1.7.1.1 /

#include <project.h>

#ifdef __cplusplus
@@ -51,10 +49,10 @@
#define DEFPROJNAME "default"
#define DEFGROUP 1
#define DEFGNAME "other"
-#define DEFPARENT "/home"
+#define DEFPARENT "/export/home"
#define DEFSKL "/etc/skel"
-#define DEFSHL "/bin/sh"
-#define DEFROLESHL "/bin/pfsh"
+#define DEFSHL "/usr/bin/bash"
+#define DEFROLESHL "/usr/bin/pfbash"
#define DEFINACT 0
#define DEFEXPIRE ""
#define DEFAUTH ""

Rebuilt illumos-gate without setting DEF* variables.
Checked that useradd -m is faulty (tries to create directories under /home) and generated defaults file matches one produced by non-patched version.
diff -u /usr/include/userdefs.h ~/srcs/illumos-gate/proto/root_i386/usr/include/userdefs.h
--- /usr/include/userdefs.h 2013-08-06 22:38:41.876564000 +0400
+++ /export/home/alp/srcs/illumos-gate/proto/root_i386/usr/include/userdefs.h 2016-12-06 16:29:56.888292115 +0300
@@ -31,8 +31,6 @@
#ifndef _USERDEFS_H
#define _USERDEFS_H

-#pragma ident "%Z%%M% %I% %E% SMI" / SVr4.0 1.7.1.1 /

#include <project.h>

#ifdef __cplusplus

  • 2
  • 0
  • 3
  • 0
  • 5
Description From Last Updated
Makefile.master is included in just about every make job in the whole system. Does it really make sense for these ... gwr gwr
If these are not really constants, would it make more sense do something like what was done for limits.h and ... gwr gwr
igork
  1. Ship It!
  2. 
      
alp
alp
alp
alp
tsoome
  1. 
      
  2. usr/src/head/Makefile (Diff revision 4)
     
     

    ending space on this and next line

  3. 
      
alp
alp
tsoome
  1. 
      
  2. usr/src/Makefile.master (Diff revision 6)
     
     

    trailing whitespaces on lines 935-937,939,942

  3. usr/src/cmd/oamuser/user/userdefs.c (Diff revision 6)
     
     

    whitespace issue on lines 149-150, it seems to be tab versus space problem:)

  4. 
      
alp
alp
tsoome
  1. Ship It!
  2. 
      
gwr
  1. 
      
  2. usr/src/Makefile.master (Diff revision 7)
     
     

    Makefile.master is included in just about every make job in the whole system. Does it really make sense for these to be in Makefile.master? Or could they be somewhere more localized?

    Perhaps: usr/src/cmd/oamuser/user/Makefile?

    1. These defines are used both in usr/src/head/Makefile and usr/src/man/man1m/Makefile. Do we have any other Makefile, ? Of course, I could rename defines, so that they have less general names, for example, prefix them with "USERDEFS_*". Or should I put these defines in some new Makefile and include it in these two?

  3. 
      
gwr
  1. 
      
  2. usr/src/head/userdefs.x (Diff revision 7)
     
     

    If these are not really constants, would it make more sense do something like what was done for limits.h and _sysconf() (Not suggesting literally sysconf, but some internal function to go get the configured values).

    1. I don't understand. sysconfig() returns values of predefined constants from other files. Why do we need one more indirection level? These are really constants, just different distributions want to set them to different values.

    2. Or do you suggest the following? If we create new function and then use #define DEFLOCK_AFTER_RETRIES userdefs(DEFLOCK_AFTER_RETRIES) in userdefs.h, we can use compile-time variables (-DDEFLOCK_AFTER_RETRIES=$(DEFLOCK_AFTER_RETRIES)) while compiling source code of this function to avoid using sed? But what about man files?

    3. Well it's quite possible I'm the one who is confused :) so let me ask:
      Are the values provided by these userdefs.h macros really constants?
      Or are these macros the mechanism by which consumer programs get the
      "current setting for homedir" etc?

    4. And a related question: How should this work?
      Perhaps DEFPARENT should be the currently configured default (from /etc/default/something?)
      and then userdefs.h might have something like:

      extern const char *_userdefs(const char *);
      #define DEFPARENT   (_userdefs("DEFPARENT"))
      

      Or maybe the _userdefs() arg is an int. whatever.

    5. These values, provided by userdefs.h now, are constants. What we do is just introducing a easy way to redefine them at compile time (like we do for PYTHON_VERSION). Initial idea was to allow redefining base_dir at runtime - http://buildzone.oi-build.r61.net/webrev-7648/ . But Peter saw inconsistency in fact that they could be redefined in several places (/usr/sadm/defadduser and /etc/default/useradd).

    6. I guess some of what is troubling me is that the issue has no details about:
      What's there now and how that was meant to work; what's wrong with what's there now, and how the proposed fix makes that better.

    7. I've updated the issue. Can we have the first part of the issue (compile time customization) fixed? If so, how this particular patchset should be updated? I consider that run-time customization is good, but can be a separate issue. I'm not especially interested in fixing second part. What I want is to make 'useradd -m test' work out of the box without impact on other distributions and without hacky sollutions. I prefer if it continued working with self-compiled illumos-gate. As I see, DEF constants, defined in userdefs.h, are used only in user-utilities.

      If we proceed with this review... 1) Should I rename constants in Makefile.master so that they use less generic names? 2) Should I move these definitions outside Makefile.master? If yes, then where? 3) Should I remove this header from files where it's not used?

    8. I realize you have probably lost interest in this issue, but I finally put up an alternative.
      See: https://www.illumos.org/rb/r/420/

  3. 
      
alp
Review request changed
tsoome
  1. Ship It!
  2. 
      
kmays
  1. Ship It!
  2. 
      
Loading...