From nobody@FreeBSD.org  Fri Nov  2 00:25:41 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CDF1616A418
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  2 Nov 2007 00:25:41 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id BADC813C4B6
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  2 Nov 2007 00:25:41 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id lA20Pbvp026424
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 2 Nov 2007 00:25:37 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id lA20PbRG026423;
	Fri, 2 Nov 2007 00:25:37 GMT
	(envelope-from nobody)
Message-Id: <200711020025.lA20PbRG026423@www.freebsd.org>
Date: Fri, 2 Nov 2007 00:25:37 GMT
From: Ivan Voras <ivoras@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Make pw(8) support "-d" argument
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         117751
>Category:       bin
>Synopsis:       [patch] [request] Make pw(8) support "-d" argument
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 02 00:30:02 UTC 2007
>Closed-Date:    Tue Nov 13 20:53:55 UTC 2012
>Last-Modified:  Tue Nov 13 20:53:55 UTC 2012
>Originator:     Ivan Voras
>Release:        RELENG_7
>Organization:
-
>Environment:
FreeBSD finstall.cosmos 7.0-BETA1 FreeBSD 7.0-BETA1 #0: Thu Nov  1 00:22:43 CET 2007     root@finstall.cosmos:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
pw(8) is a command line utility for managing the local password
database. Among its possible arguments is a "-d" argument which sets
the base directory for the password database (e.g. makes pw operate on
a jailed directory tree). Unfortunately this argument is nonuniformly
supported - some modes of operation of pw don't support it. This patch
adds support for -d argument when -m (create user's directory) is also
used while creating a user account.

This patch is used/required by finstall.

>How-To-Repeat:
Run pw useradd -d /jail -m ...

>Fix:
A patch to pw_user.c is attached.



Patch attached with submission follows:

--- 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);


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: remko 
State-Changed-When: Fri Nov 16 11:03:52 UTC 2007 
State-Changed-Why:  
As discussed in private, -d is currently being used in pw useradd for 
example to specify what the homedirectory of the user will be, the 
option you are talking about could not be found by my (quick) check of 
the manual, could you please specify this? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=117751 


From: Giorgos Keramidas <keramida@freebsd.org>
To: Ivan Voras <ivoras@freebsd.org>
Cc: remko@freebsd.org, bug-followup@freebsd.org
Subject: Re: bin/117751: Make pw(8) support "-d" argument
Date: Tue, 03 Jun 2008 15:56:38 +0300

 > Among its possible arguments is a "-d" argument which sets the base
 > directory for the password database (e.g. makes pw operate on a jailed
 > directory tree).
 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: remko
 > State-Changed-When: Fri Nov 16 11:03:52 UTC 2007
 > State-Changed-Why:
 > As discussed in private, -d is currently being used in pw useradd for
 > example to specify what the homedirectory of the user will be, the
 > option you are talking about could not be found by my (quick) check of
 > the manual, could you please specify this?
 >
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=117751
 
 Hi Ivan,
 
 This has been sitting in the Gnats queue for a few months.  I can't find
 the -d option for setting the base directory.  I can see that -V etcdir
 is supported for locating an alternative etc/pwd.db but not -d :/
 
 Jail password database can be tweaked from the `host' with the existing
 options I guess, i.e.:
 
     JROOT='/home/jail/ftp'
     pw -V "${JROOT}/etc" useradd -d "${JROOT}/home/ftp" [...]
 
 Did you have something else in mind?
 
State-Changed-From-To: feedback->closed 
State-Changed-By: eadler 
State-Changed-When: Tue Nov 13 20:53:54 UTC 2012 
State-Changed-Why:  
pw_mkdb supports -d, but pw does not do what is being said here. Perhaps 
you can clarify and I can reopen? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=117751 
>Unformatted:
