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