GNU bug report logs - #15945
chown: accept "[NUMERIC-ID]:" syntax

Previous Next

Package: coreutils;

Reported by: Tormen <quickhelp <at> gmail.com>

Date: Thu, 21 Nov 2013 15:18:03 UTC

Severity: wishlist

Full log


Message #64 received at 15945 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Tormen <quickhelp <at> gmail.com>
Cc: Andreas Schwab <schwab <at> linux-m68k.org>, 15945 <at> debbugs.gnu.org
Subject: Re: bug#15945: chown: Does now allow setting user and users login
 group with numerical user ID
Date: Thu, 21 Nov 2013 13:53:37 -0700
[Message part 1 (text/plain, inline)]
On 11/21/2013 11:07 AM, Tormen wrote:

>>> There may not be a unique uid to user name mapping.
> Interesting. But I guess the ID (for owner and group) is what is stored
> in the filesystem
> (as you can rename users and the ID stays the same on the file).
> In which case there is no tranlsation (ID -> name) necessary when
> calling chown with an uid.
> The "ls" then does the lookup to translate the ID in a name then.
> And so the ls could run into the mapping problem...  or chown if called
> with a username.
> 
> Or is it the other way round ?

No, you have it right - stat() stores only uid, and ls(1) does a name
lookup for printing "the" (more precisely, "a") username associated with
that id.

>> Right, but in that case, the error message should make sense.  Rather
>> than being a blanket "invalid spec: `1001:'" it should say something
>> like "unable to determine default group for user `1001'"
>>
> So in no case there should be a mapping problem when using numerical IDs
> for users/groups.
> Only when called with names.

Not true - we still have two potential lookup problems.  One is that
that there may be NO name associated with ID (ls -l just falls back to
listing id, but in the chmod case, we can't do a default login group
lookup if we don't have a name).  Try as root:

# touch /tmp/f
# chown 12345 /tmp/f
# ls -l /tmp/f
-rw-r--r--. 1 12345 root 0 Nov 21 13:51 /tmp/f

The other is that even if a name is associated with an ID (whether the
only name, or whether the first name out of multiple that map to the
id), the default login group lookup for that name may fail (but that's
true even if we didn't first do a uid->name lookup).

Either way, my point remains - we should have a saner error message if
we are unable to determine a default login group for a given user
identification, rather than just declaring the entire '1001:' an invalid
spec.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 6 years and 155 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.