I want to verify the security performance of the su password. The way I think of is to execute the su command by setting up the child process, then enter the password, and then get the current UID to determine if it is equal to 0, but I don't know how to connect the IO now. Go to the script opened by the child process, is there any way to connect IO, or other methods to verify the security of su password, thank you very much:)
int main(){
pid_t pid;
if((pid = fork()) < 0){
printf("fock error!\n");
}
else if(pid == 0){// child
execl("/bin/sh", "-sh", (char*)0);
//Execute su and input password to become root user, but I dont know how to pass the command to my shell
exit(1);
}
else{ // parents
waitpid(pid, NULL, 1);
//get my child process exec ' result
}