* Support LDAP/AD mail usernames
sometimes usernames can be in mail form or containing special chars,
this commit will force the creation of the user and group even if it has
invalid names.
* enter: Enter at workdir through child path of '/run/host'
Despite tight integration, some host workdir paths may not exist in container.
So always drop at workdir through '/run/host' path which is bound to exist if not in $HOME (or subdirectory)
Co-authored-by: 89luca89 <luca.dimaio1@gmail.com>
* init: If user already exists in /etc/passwd set properties again rather than skip
This fixes a bug where home field in /etc/passwd diverges from value of $HOME
which then causes unexpected behaviour.
When user is pre-prepopulated due to some reason the old behaviour was to skip useradd.
So path in /etc/passwd could be different than one manually set (ex. when user asks for custom home).
Fix bug by force-setting properties with usermod if user already exists.
Added some comments to make reasoning clearer.
1caa478c52 tried to improve the writeability check to avoid false
positives, such as the one reported in a DistroWatch.com article.
However, it is still possible to break this check by having the
destination and its parent directory not exist:
$ ./install -p $HOME/tmp/directory-does-not-exist/bin
Cannot write into /home/nathan/tmp/directory-does-not-exist/bin, permission denied.
The script already uses 'install -D', which will create the target
directory if it does not exist, so trying to create dest_path
preemptively only increases the complexity of install and risks
introducing false positive errors like above.
Instead, just check the calls to install and print a message about
potential issues with permissions if they fail.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>