From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 22 22:03:01 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D52916A41B for ; Wed, 22 Aug 2007 22:03:01 +0000 (UTC) (envelope-from freebsd-hackers@m.gmane.org) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.freebsd.org (Postfix) with ESMTP id BEF2E13C458 for ; Wed, 22 Aug 2007 22:03:00 +0000 (UTC) (envelope-from freebsd-hackers@m.gmane.org) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1INyHz-000820-8S for freebsd-hackers@freebsd.org; Thu, 23 Aug 2007 00:02:59 +0200 Received: from 89-172-36-165.adsl.net.t-com.hr ([89.172.36.165]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 Aug 2007 00:02:59 +0200 Received: from ivoras by 89-172-36-165.adsl.net.t-com.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 Aug 2007 00:02:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-hackers@freebsd.org From: Ivan Voras Date: Wed, 22 Aug 2007 04:17:01 +0200 Lines: 32 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 89-172-36-165.adsl.net.t-com.hr User-Agent: Thunderbird 2.0.0.4 (X11/20070714) Sender: news Subject: pw not creating home directories with -V +patch X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Aug 2007 22:03:01 -0000 Hi, I've just found out that pw(8) isn't creating home directories when -V (alternate /etc directory) is specified. I realize this was probably made to avoid foot-shooting but I also think there should be a way to enable this feature. I've created the following patch: --- pw_user.c.old 2007-08-22 04:00:24.000000000 +0200 +++ pw_user.c 2007-08-22 04:10:30.000000000 +0200 @@ -775,7 +775,7 @@ * that this also `works' for editing users if -m is used, but * existing files will *not* be overwritten. */ - if (!PWALTDIR() && getarg(args, 'm') != NULL && pwd->pw_dir && *pwd->pw_dir == '/' && pwd->pw_dir[1]) { + if ((!PWALTDIR() | (PWALTDIR() && getarg(args, 'd') != NULL)) && getarg(args, 'm') != NULL && pwd->pw_dir && *pwd->pw_dir == '/' && pwd->pw_dir[1]) { copymkdir(pwd->pw_dir, cnf->dotdir, cnf->homemode, pwd->pw_uid, pwd->pw_gid); pw_log(cnf, mode, W_USER, "%s(%ld) home %s made", pwd->pw_name, (long) pwd->pw_uid, pwd->pw_dir); This will enable pw to create user's home directory only if the directory name was explicitly specified on the command line (the -d switch), which I think is in the spirit of the -V switch. If someone's available, I'd like this to get committed as soon as possible. (If you need an example of why this behavior is useful, think of creating users for a jail from outside the jail, installers, etc.)