shadow-maint / shadow

Upstream shadow tree
Other
290 stars 228 forks source link

useradd --system writes non-existent dir into passwd #983

Closed stsp closed 3 months ago

stsp commented 3 months ago

useradd --system doesn't create the home dir, but it nevertheless writes the regular home dir name into /etc/passwd. IMO you are not supposed to write the non-existent dir as a home dir.

So what can be the fix? Some * or -? An empty field? Or maybe /var/run/user/<uid>?

hallyn commented 3 months ago

The manpage says:


       -d, --home-dir HOME_DIR
           The new user will be created using HOME_DIR as the value for the user's login directory. The default is
           to append the LOGIN name to BASE_DIR and use that as the login directory name. The directory HOME_DIR
           does not have to exist but will not be created if it is missing.

I don't think this is a problem.

hallyn commented 3 months ago

Now, mind you, Debian policy says to use '/nonexistent' as the homedir in these cases. I don't think anything would break if we made that the default in upstream.

Well, maybe it would: there may be sites which, for whatever reason, first create an account without specifying to create the homedir, then later create the homedir (or have it created on a remote filesystem automatically, perhaps). So yeah, I think it's best to let the user specify the value they want.

stsp commented 3 months ago

Now, mind you, Debian policy says to use '/nonexistent' as the homedir in these cases.

I think /nonexistent is chosen only because currently there is no way to create an empty field.

So yeah, I think it's best to let the user specify the value they want.

Certainly, but currently the user has to specify crap line /nonexistent as there is no way to specify empty field. And the default values must be sane. Be they sane from the beginning, there would probably be no adduser right now with completely different defaults.