Subject: Re: vipw creating homes
To: Emmanuel Dreyfus <>
From: Chris G. Demetriou <>
List: tech-userlevel
Date: 03/06/2001 13:56:00 (Emmanuel Dreyfus) writes:
> I've added a -h flag to my local vipw. vipw -h creates home directories
> for all users that do not have a home.=20
> What is your opinion about committing this change? There is one
> drawback: we should not use /nonexistent home directories in
> /etc/passwd, because vipw -h would create /nonexistent

This seems ill-advised.

* vipw edits the password file.  I doesn't really try to do much with
the contents, other than make sure they're in basically the correct
sytax.  If you want something that generally takes care of adding
users, use a (different) tool to do that.

* how big a general problem is this?  I suspect "not very".  In
general, either users' home dirs will be created by the tool that
created them, or will come in over NFS, or whatever.  The number of
times that you have a user in /etc/passwd that you suddenly decide you
want to create a home dir for ... should be small, and the number of
times that should happen for _all_ users in the pw file should be
vanishingly small.

* this can be done manually for those times which are the exception to
that.  If you happen to have a weird enough situation where you want
to do this often, it's trivial to create a script that'll do it.

awk -F: '
$6 != "" {
	printf "if [ ! -d %s ]; then\n", $6
	printf "    mkdir -p %s\n", $6
	printf "    chown %s:%s %s\n", $3, $4, $6
	printf "fi\n"
' < /etc/passwd | sh

> For now, I just create the directories, and give them away to their
> owners. I think about also copying the files from /usr/share/skel, and
> for this, I would need to define a _PATH_SKEL in paths.h. Any problem
> here?

What you want is a tool to add users.  NetBSD has a tool to add users.
vipw isn't it.

It may make sense to add the ability to 'reinit' a user's home dir to
that tool -- if it doesn't already support that -- but not to add that
support to vipw.