From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 2 00:30:03 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DFEC16A469 for ; Fri, 2 Nov 2007 00:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id DFDD313C4AC for ; Fri, 2 Nov 2007 00:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id lA20U2eQ047941 for ; Fri, 2 Nov 2007 00:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id lA20U2EX047936; Fri, 2 Nov 2007 00:30:02 GMT (envelope-from gnats) Resent-Date: Fri, 2 Nov 2007 00:30:02 GMT Resent-Message-Id: <200711020030.lA20U2EX047936@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ivan Voras Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CDF1616A418 for ; 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 ; 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 ; 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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/117751: Make pw(8) support "-d" argument X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2007 00:30:03 -0000 >Number: 117751 >Category: bin >Synopsis: Make pw(8) support "-d" argument >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Nov 02 00:30:02 UTC 2007 >Closed-Date: >Last-Modified: >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: >Unformatted: