From owner-freebsd-bugs@FreeBSD.ORG Fri Feb 20 22:30:20 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6322516A4CF for ; Fri, 20 Feb 2004 22:30:20 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 42BF743D41 for ; Fri, 20 Feb 2004 22:30:20 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i1L6UKbv016991 for ; Fri, 20 Feb 2004 22:30:20 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i1L6UKI2016990; Fri, 20 Feb 2004 22:30:20 -0800 (PST) (envelope-from gnats) Resent-Date: Fri, 20 Feb 2004 22:30:20 -0800 (PST) Resent-Message-Id: <200402210630.i1L6UKI2016990@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, Paul Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 21C5316A4CE for ; Fri, 20 Feb 2004 22:24:58 -0800 (PST) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C49643D1D for ; Fri, 20 Feb 2004 22:24:58 -0800 (PST) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i1L6Ov72038619 for ; Fri, 20 Feb 2004 22:24:57 -0800 (PST) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.10/8.12.10/Submit) id i1L6OvuR038618; Fri, 20 Feb 2004 22:24:57 -0800 (PST) (envelope-from nobody) Message-Id: <200402210624.i1L6OvuR038618@www.freebsd.org> Date: Fri, 20 Feb 2004 22:24:57 -0800 (PST) From: Paul To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: bin/63160: chown failed to chown valid files/dirs to valid username X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Feb 2004 06:30:20 -0000 >Number: 63160 >Category: bin >Synopsis: chown failed to chown valid files/dirs to valid username >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 20 22:30:19 PST 2004 >Closed-Date: >Last-Modified: >Originator: Paul >Release: 5.1-RELEASE-p11 >Organization: DataPipe >Environment: FreeBSD Lucky 5.1-RELEASE-p11 FreeBSD 5.1-RELEASE-p11 #0: Tue Jan 27 14:11:27 EST 2004 root@Lucky:/usr/obj/usr/src/sys/LUCKY i386 >Description: chown'ing a directory as such: chown nobody /path/to/directory fails. ############################### Lucky# ./chown nobody /usr/local/samba chown: nobody: Invalid argument ############################### Lucky# fgrep nobody /etc/passwd nobody:*:65534:65534:Unprivileged user:/nonexistent:/sbin/nologin ######################################## In /usr/src/usr.sbin/chown/chown.c line 262 it reads: val = strtoul(name, &ep, 10); man strtoul reads that the value of this function if an error returns will always return ERANGE. Adding if (errno == ERANGE) puts("Debug"); yeilds nothing. Adding printf("%d %d\n", ERANGE, errno); is showing EINVAL being returned. This looks like a bug in strtoul, as "name" (nobdoy), should be easily converted to an unsigned long val. >How-To-Repeat: run chown name dir where name is a name as in nobody and the uid, in my example is 65534. >Fix: >Release-Note: >Audit-Trail: >Unformatted: