pwck-mimic is a C-based program that replicates the functionality of the Linux pwck command. It verifies the integrity of user authentication files (passwd and shadow) by validating their format and consistency. This project uses a modular design with a Makefile for simplified execution and comes with example files (passwd.txt and shadow.txt) for testing.
The Linux pwck command is a system administration utility that checks the validity of /etc/passwd and /etc/shadow files. It ensures these files are correctly formatted and consistent. pwck-mimic provides a similar functionality using custom code written in C.
This project is implemented in C, leveraging modular programming principles for scalability and maintainability.
-
client1.c: Contains the main program logic that:- Opens the
passwdandshadowfiles. - Checks for errors in file access and passes the files for validation.
- Opens the
-
server1.c: Includes the logic to:- Validate the
passwdfile for inconsistencies, such as:- Empty usernames.
- Missing or invalid password fields.
- Non-numeric user IDs.
- Validate the
shadowfile for errors, such as:- Empty usernames.
- Invalid password formats.
- Non-numeric user IDs.
- Validate the
-
interface.h: Header file containing function declarations used in the project. -
passwd.txt: Samplepasswdfile used for testing the program. -
shadow.txt: Sampleshadowfile used for testing the program. -
lab3.mk: Makefile used for building and running the project.
- File Integrity Checks: Ensures that all fields in the
passwdandshadowfiles follow the correct format. - Validation Logic:
- Checks for empty fields.
- Ensures passwords are properly formatted (e.g., encrypted or valid placeholders like
x,*, or!). - Verifies that user IDs are numeric.
- Modular Design: Implements separation of concerns with reusable functions.
- Example Files: Comes with sample files (
passwd.txtandshadow.txt) for quick testing. - Makefile Support: Simplifies the build and execution process.
-
Ensure you have a C compiler (like GCC) installed on your system.
-
Use the following command to compile and run the program using the provided Makefile:
make -f lab3.mk
-
After successful compilation, execute the program: ./lab3
-
Follow the program's instructions to enter the names of the passwd and shadow files you wish to validate.
- File Parsing:
- Reading and parsing the
passwdorshadowfile: O(n), wherenis the number of lines in the file.
- Reading and parsing the
- Validation:
- Checking the fields within each line: O(m), where
mis the number of fields per line.
- Checking the fields within each line: O(m), where
- In-Memory Storage:
- Temporary storage for file content: O(n), where
nis the number of lines in the largest file.
- Temporary storage for file content: O(n), where