I’m trying to understand how things work with sudo and have traced through the steps of what happens after I intentially gave a wrong password. I can roughly understand the sequence of events by going down the lines and googling what each line does. However, I’m having trouble understanding how the lines are linked.
Below are shows some output from strace -f -p <PID of sudo>
. I picked them to help with my questioning.
1 sendto(5, "<85>Jun 16 20:10:50 sudo: pam_un"..., 102, MSG_NOSIGNAL, NULL, 0) = 102
2 openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 6
3 lseek(6, 0, SEEK_CUR) = 0
4 fstat(6, {st_mode=S_IFREG|0644, st_size=3328, ...}) = 0
5 read(6, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 3328
6 close(6) = 0
7 openat(AT_FDCWD, "/etc/shadow", O_RDONLY|O_CLOEXEC) = 6
8 lseek(6, 0, SEEK_CUR) = 0
9 fstat(6, {st_mode=S_IFREG|0640, st_size=1720, ...}) = 0
10 read(6, "root:!:18503:0:99999:7:::\ndaemon"..., 4096) = 1720
11 close(6) = 0
12 brk(0x55b06cff6000) = 0x55b06cff6000
13 access("/var/run/utmpx", F_OK) = -1 ENOENT (No such file or directory)
14 openat(AT_FDCWD, "/var/run/utmp", O_RDONLY|O_CLOEXEC) = 6
15 lseek(6, 0, SEEK_SET) = 0
16 alarm(0) = 0
At line 12, there is a brk() syscall. Who called it? Is it the previous process close()
? Who called access()
in line 13? Line 13 is the line I’ve tracked to show any indication that the password was incorrect, but I can’t trace who/what called it and why. I have looked at the sudo source code, however I think the syscall span across one source code and i need help knowing where to look and how to trace.