From owner-freebsd-bugs@FreeBSD.ORG Thu May 1 09:10:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D943FBF8 for ; Thu, 1 May 2014 09:10:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B3E291212 for ; Thu, 1 May 2014 09:10:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s419A0iD049417 for ; Thu, 1 May 2014 09:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s419A0A1049405; Thu, 1 May 2014 09:10:00 GMT (envelope-from gnats) Resent-Date: Thu, 1 May 2014 09:10:00 GMT Resent-Message-Id: <201405010910.s419A0A1049405@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, "Matthew D.Fuller" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5BF3AA68 for ; Thu, 1 May 2014 09:04:13 +0000 (UTC) Received: from thyme.infocus-llc.com (server.infocus-llc.com [206.156.254.44]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "*.infocus-llc.com", Issuer "*.infocus-llc.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 35F8811CA for ; Thu, 1 May 2014 09:04:12 +0000 (UTC) Received: from draco.over-yonder.net (c-75-65-60-66.hsd1.ms.comcast.net [75.65.60.66]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by thyme.infocus-llc.com (Postfix) with ESMTPSA id 1FEFF37B513 for ; Thu, 1 May 2014 04:04:12 -0500 (CDT) Received: by draco.over-yonder.net (Postfix, from userid 100) id 3gK9d75Gycz2VH; Thu, 1 May 2014 04:04:11 -0500 (CDT) Message-Id: <3gK9d75Gycz2VH@draco.over-yonder.net> Date: Thu, 1 May 2014 04:04:11 -0500 (CDT) From: "Matthew D.Fuller" To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: bin/189172: [PATCH] pw usermod breaks on changing username X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: "Matthew D.Fuller" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 May 2014 09:10:01 -0000 >Number: 189172 >Category: bin >Synopsis: [PATCH] pw usermod breaks on changing username >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu May 01 09:10:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Matthew D. Fuller >Release: FreeBSD 9.1-STABLE amd64 >Organization: >Environment: System: FreeBSD draco.over-yonder.net 9.1-STABLE FreeBSD 9.1-STABLE #0 r251584: Sun Jun 9 14:23:33 CDT 2013 root@draco.over-yonder.net:/usr/obj/usr/src/sys/DRACO amd64 >Description: When calling `pw usermod` with -l to change the username, the password database doesn't get updated correctly. pw_mkdb() gets called with the original username (which works fine for every OTHER call to usermod), which means that while the master.passwd gets the new correct info, the *pwd.db's do not, as they get (attemped) updated with a nonexistent username. As a result, the old name remains and the new one isn't brought in. With repeated calls this can lead to multiple lines being added to master.passwd, as the scan fails to find what it's looking for and keeps trying to add it as a new user. >How-To-Repeat: Add a 'pwtst' user with uid 999 pw usermod 999 -l pwt pw usermod 999 -l pwt pw usermod 999 -l pwt Look at the 3 pwt lines in [master.]passwd, and how finger(1) shows pwtst still but no pwt. >Fix: Index: pwupd.c =================================================================== --- pwupd.c (revision 264991) +++ pwupd.c (working copy) @@ -150,7 +150,7 @@ * in case of deletion of a user, the whole database * needs to be regenerated */ - if (pw_mkdb(pw != NULL ? user : NULL) == -1) { + if (pw_mkdb(pw != NULL ? pw->pw_name : NULL) == -1) { pw_fini(); err(1, "pw_mkdb()"); } >Release-Note: >Audit-Trail: >Unformatted: