From nobody@FreeBSD.org  Fri Feb 20 22:24:58 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 21C5316A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <pprocacci@datapipe.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: chown failed to chown valid files/dirs to valid username
X-Send-Pr-Version: www-2.3

>Number:         63160
>Category:       bin
>Synopsis:       chown failed to chown valid files/dirs to valid username
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    le
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 20 22:30:19 PST 2004
>Closed-Date:    Wed Mar 10 07:48:20 PST 2004
>Last-Modified:  Wed Mar 10 07:48:20 PST 2004
>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:
Responsible-Changed-From-To: freebsd-bugs->le 
Responsible-Changed-By: le 
Responsible-Changed-When: Wed Mar 10 04:06:57 PST 2004 
Responsible-Changed-Why:  
I can't reproduce this behaviour on 5.2-CURRENT, but I'll take this PR. 

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

From: Lukas Ertl <le@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, pprocacci@datapipe.com
Cc:  
Subject: Re: bin/63160: chown failed to chown valid files/dirs to valid
 username
Date: Wed, 10 Mar 2004 13:06:35 +0100 (CET)

 Hi,
 
 # chown nobody /path/to/dir
 
 works fine on 5.2-CURRENT.  Could you please try to reproduce the
 behaviour you mentioned?
 
 regards,
 le
 
 -- 
 Lukas Ertl                           http://mailbox.univie.ac.at/~le/
 le@FreeBSD.org                       http://people.freebsd.org/~le/
State-Changed-From-To: open->closed 
State-Changed-By: le 
State-Changed-When: Wed Mar 10 07:48:03 PST 2004 
State-Changed-Why:  
Submitter reports that the problem is gone in 5.2. 

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