Checks if the entered passwd/shadow linux command has a valid syntax
-> Spaces are illegal (Exception: passwd field 5)
7 fields:
- Username = Symbols, numbers and alphabets allowed
- Encrypted password = x
- UID = Only integers allowed
- GID = Only integers allowed
- Username = Symbols, numbers and alphabets allowed. Spaces allowed.
- Home directory = Starts with /, symbols, numbers and alphabets allowed
- Command/shell = Starts with /, symbols, numbers and alphabets allowed
8 fields:
- Username = Symbols, numbers and alphabets allowed
- Encrypted password = Symbols, numbers and alphabets allowed
- Last password change = Only integers allowed
- Min days = Only integers allowed
- Max days = Only integers allowed
- Warn days = Only integers allowed
- Inactive days = Only integers allowed (Optional)
- Expiry days = Only integers allowed (Optional)
- If fields are left empty, for eg, root::::::, it is still a valid format
- If the file exists, but is empty, the format check still returns success
- This program doesnt make sure the usernames in passwd and shadow match i.e, any pwconv command functionalities
- Assuming the txt files scanned have less than 1000 lines, functions in this program return 1000 on success, and -1 on failure