NetBSD Problem Report #10401

Received: (qmail 11929 invoked from network); 20 Jun 2000 11:32:28 -0000
Message-Id: <200006201132.NAA12426@segue.brwn.org>
Date: Tue, 20 Jun 2000 13:32:23 +0200 (SAST)
From: root@segue.brwn.org
Reply-To: willem@brwn.org
To: gnats-bugs@gnats.netbsd.org
Subject: useradd doesn't add home dir when using the -d option
X-Send-Pr-Version: 3.95

>Number:         10401
>Category:       bin
>Synopsis:       useradd doesn't add the home dir to the passwd file if specified with the -d option
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    releng-1-4
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 20 11:33:00 +0000 2000
>Closed-Date:    Thu Sep 14 11:43:42 +0000 2000
>Last-Modified:  Thu Sep 14 11:43:42 +0000 2000
>Originator:     Charlie Root
>Release:        NetBSD-1.4.2 RELEASE
>Organization:

>Environment:

System: NetBSD segue 1.4.2 NetBSD 1.4.2 (SEGUE) #1: Thu Mar 23 22:21:15 SAST 2000 root@segue:/usr/src/sys/arch/i386/compile/SEGUE i386


>Description:
	The home directory field is not added to the passwd database if it is specfified on
	the command line using the -d option to the /usr/sbin/useradd tool.

	If the -d option is specified, the u_homeset variable is set to 1. The relevent code
	checks to see if the u_homeset variable is not set.

        /* if home directory hasn't been given, make it up */
        if (!up->u_homeset) {
                (void) snprintf(home, sizeof(home), "%s/%s", up->u_basedir, login);
        }

	It only set the home variable if the -d is not specfified.

>How-To-Repeat:
	This command is used by the PostgreSQL package to add a user for PostgreSQL.

	user add -c "PostgreSQL database administrator" -d /usr/pkg/pgsql -g ingres -s /bin/sh pgsql

	It will leave the home directory field in the password database with no value or whatever whas
	in the memory the home variable occupied at the time.
>Fix:
	This patch attempts to fix this problem.

	RCS id of the file.

/* $NetBSD: user.c,v 1.10.2.2 2000/02/04 22:57:21 he Exp $ */

	The patch.

--- usr.sbin/user/user.c.orig   Tue Jun 20 12:18:58 2000
+++ usr.sbin/user/user.c        Tue Jun 20 13:28:27 2000
@@ -708,6 +708,8 @@
        /* if home directory hasn't been given, make it up */
        if (!up->u_homeset) {
                (void) snprintf(home, sizeof(home), "%s/%s", up->u_basedir, login);
+       } else {
+               (void) strlcpy(home, up->u_home, sizeof(home));
        }
        expire = 0;
        if (up->u_expire != (char *) NULL) {
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: he 
State-Changed-When: Tue Sep 12 15:13:09 PDT 2000 
State-Changed-Why:  
Revision 1.13 of usr.sbin/user/user.c has been pulled 
up to the netbsd-1-4 branch and will be part of 1.4.3. 
This should fix this problem -- please verify and report 
back. 
Responsible-Changed-From-To: bin-bug-people->releng-1-4 
Responsible-Changed-By: he 
Responsible-Changed-When: Tue Sep 12 15:14:17 PDT 2000 
Responsible-Changed-Why:  
Releng-1-4 will handle this problem now. 
State-Changed-From-To: feedback->closed 
State-Changed-By: he 
State-Changed-When: Thu Sep 14 04:43:13 PDT 2000 
State-Changed-Why:  
Originator reports problem fixed by pull-up. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.