This script verifies that a username passed as a string to the function would be a good username. The test of goodness requires that the proposed username is unique to the system (i.e. no existing user has this name), and that the username is comprised of only alphabetic characters, numbers, underscores and dots (period), and that the username is between 4 and 16 characters long. For the purpose of the test, uppercase and lowercase characters are equivalent so that if the user has chosen a username of upper-case characters, these characters will be replaced with their lower-case equivalents.
Verify the appropriateness and uniqueness of the proposed username by performing the following steps:
Check that the username is between 4 and 16 characters in length and contains only characters, digits, underscores and dots (periods). If it fails this test, exit this function and return an appropriate error description.
Convert the proposed username to all lowercase letters.
Check that the username is unique within the system. If this test fails, exit the function and return an appropriate error description. This test of uniqueness is met if:
There is no existing entry in the /etc/password file with the same username
There is no existing entry in the /etc/mail/aliases file such that the proposed username was a previous system username that has since been remapped to a new username.
There is no other entry in the User table or Member table with this username such that the same username is in a pending state awaiting another user’s agreement or remittance.
Return a null length string if the proposed username is acceptable to the system.
Possible Exit Conditions and Return Values
If the username is not appropriate, a descriptive error message is returned as a scalar variable.
If the username is appropriate, the function returns a null length string.