Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which code set is /etc/passwd stored in? Can it be UTF-8? What limits are placed on user names?

On a modern Unix or Linux system, how can you tell which code set the /etc/passwd file stores user names in? Are user names allowed to contain accented characters (from the range 0x80..0xFF in, say, ISO 8859-1 or 8859-15)? Can the /etc/passwd file contain UTF-8? Can you tell that it contains UTF-8? What about the plain text of passwords before they are encrypted or hashed?

Clearly, if the usernames and other data is limited to the 0x00..0x7F range (and excludes 0x00 anyway), then there is no difference between UTF-8, 8859-1 or 8859-15; the characters present are all encoded the same.

Also, I'm using /etc/passwd as an abbreviation for something along the lines of "the user identification and authentication database (sometimes termed a directory service) on a Unix-based machine, usually accessed via PAM and sometimes hosted on other machines altogether from the local one, but sometimes still actually a file on the local hard disk, conventionally called /etc/passwd, often supported by /etc/shadow". I'm also assuming that the equivalent questions about the group database (often the /etc/group file) have the same answer.

like image 597
Jonathan Leffler Avatar asked Sep 11 '09 17:09

Jonathan Leffler


People also ask

What is stored in etc passwd file?

The /etc/passwd file contains the username, real name, identification information, and basic account information for each user. Each line in the file contains a database record; the record fields are separated by a colon (:).

What is the ETC passwd file and what is its format?

Traditionally, the /etc/passwd file is used to keep track of every registered user that has access to a system. The /etc/passwd file is a colon-separated file that contains the following information: User name. Encrypted password.

What command would allow you to display the file passwd under the root's etc directory?

The /etc/passwd file is stored in /etc directory. To view it, we can use any regular file viewer command such as cat, less, more, etc. Each line in /etc/passwd file represents an individual user account and contains following seven fields separated by colons (:).

Are passwords stored in etc passwd?

The first file we will look at, called the "/etc/passwd" file, does not actually store passwords. At one time, this file stored the hashed passwords of every user on the system. However, this responsibility has been moved to a separate file for security reasons.


1 Answers

It's all ASCII. But the password itself is never stored - only the results of the one-way hash. If you're wondering what characters can be in the password itself, it depends on the locale, which will restrict the characters your terminal is able to deal with. See "man locale"

From the BSD man page:

"/etc/passwd ASCII password file..."

As for usernames, I can tell you that Solaris only supports ASCII. I can't speak for other Unix-en.

"Not every object in Solaris 2 and Solaris 7can have names composed of arbitrary characters. The names of the following objects must be composed of ASCII characters:

* User names, group name, and passwords
* System name ...

"

like image 125
nont Avatar answered Sep 22 '22 05:09

nont