The reason that this is allowed today, is simply because the system doesn't prevent it.
If this changed, then it would break those systems where admins have had a use for this feature, (see Terdon's example). So it has never been changed, and I don't think it ever will.
Originally there was only the passwd and group files, and they served their purpose. there was no adduser command, no addgroup, the files were edited by root using vi or ed.
There were a few quirks !
In order to remember the next user-id to use, it was common for admins to have a special user as the last line which had a user-name of !
(because !
was an invalid user name) and that entry was used to store the next user-id. Crude, I admit, but It worked! So why bust a gut making it more complicated, akin to agile development today.
There were known flaws. The main being, that it had to be world readable, so that utilities like ls
could could map user-id => name
. This meant anybody could see everybody's encrypted password, and all the users and id's in the system.
Some Unix systems began introducing a couple of shell scripts adduser
addgroup
, often these were ignored, because they were a inconsistent between Unixes, so most people just carried on with the manual edit.
It took quite a few years, before the shadow
password file was invented, this provided a little more security, by hiding the encrypted passwords. Again, just enough complexity was added, but it was still fairly crude and simple. The utilities useradd
and groupadd
were introduced, which kept shadow
and shadow-
updated. To start with, these were often simple shell script wrappers around vendors proprietary adduser/addgroup utilities. Again it was just enough to keep going.
Networks of computers were growing up, people were working on several at a time to get jobs done, so admin of the passwd/group
files was becoming a nightmare, especially with NFS, so in comes Yellow Pages also known as NIS to alleviate the burden.
It was becoming obvious by now that something a bit more flexible was needed, and PAM was was invented. So if you were really sophisticated and wanted a centralised, secure, unique-id'ed, all bells and whistles authentication system you would call out to a central server to authenticate, maybe a Radius server, LDAP server or Active directory.
The world had grown up. But the passwd/group/shadow files still remained for us smaller users/developers/labs. We still didn't really require the all bells and whistles. I guess the philosophy had changed a bit by now to, "If you were going to make it better, you wouldn't use it at all", so don't worry about it.
This is why I don't think the simple passwd file will ever change. There's no point any more, and it's just great for those £30 Raspberry Pi's with 2 maybe 3 user's monitoring temperature, and twitter feeds. OK, You just have to be a bit careful with your user-id's if you want them unique, and there's nothing to prevent the enthusiast from wrapping useradd in a script which first selects the next unique id from a database (file) to set a unique id, if that's what you want. It is open source after all.