Would it be difficult to increase the limit or would it just be a one-place change?

I have a system that could really elegantly make use of the Unix multiuser model for process isolation but I'd need much longer usernames than just 32 characters.

Is the name length standardized (POSIX)?

  • 1
    Can't you map the longer names onto 32 characters? – user1794469 Aug 6 '15 at 13:21
  • 1
    Short answer: No; Long answer: The system I speak of is a nonconflicting package manager with packages of potentially really long url-based fully qualified names (which in certain contexts abbreviate for user convenience). I'd like to add the option of optionally jailing packages to their own, dynamically-created (at installation time) system user, but in order to preserve the nonconflicting nature of the system, the names of dynamically created users would need to be based on the fully qualified name of the appropriate package. Mapping to a shorter wouldn't be guaranteedly conflictless. – PSkocik Aug 6 '15 at 13:44
  • 1
    Sounds like the use of a database to map your really-long-lots-of-info-in-ther-username names to a simple name is a better solution. (this would be a much shorter job than trying to fix all the places to to support longer usernames). – Drav Sloan Aug 6 '15 at 13:52
  • 1
    Surely that's (127-32)^32, not (127-32)*32? – Useless Aug 6 '15 at 14:02
  • 2
    a one-way mapping from arbitrary long string to 32 chat can be achieved using md5. (there is however no guarantee that you get a name conflict). – Archemar Aug 6 '15 at 14:11

Don't try making the login name longer, you'll probably find loads of places it breaks.

Note that you don't have a problem with the number of possible login names (you only get UID_MAX-UID_MIN uids anyway, which is 59,000 on my system).

The problem is just with how descriptive they are, but fortunately there's another field intended to be descriptive: the GECOS/comment field. Just put the URL in there, and make the username either a 32-character hash of that, or simply the UID in base 10.

Then, best case you can always hash the URL to get UID, and worst case you need a reverse lookup from URL to UID, which is pretty trivial for 59,000 items - even a grep of /etc/passwd would be sufficient.

  • Do you know if there are any limits on the length of the comment field (character set restrictions don't worry me as I only need a very basic character set ([a-zA-Z_0-9])? – PSkocik Aug 6 '15 at 14:42
  • 1
    Not on Linux at least (you can see that glibc:fgetpwent grows its buffer as required). The GECOS field is an addition to the POSIX standard, so you'd need to check any other platforms individually. – Useless Aug 6 '15 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.