sudo-project/sudo

Ask some questions about the process model:There are two distinct ways sudo can run a command.

BornThisWay opened this issue · 1 comments

I've read the implementation of sudo_execute many times, but there's still a lot of confusion. It's mainly about suspension and resumption.

int sudo_execute(struct command_details *details, struct command_status *cstat)

bool exec_pty(struct command_details *details, struct command_status *cstat)

void exec_nopty(struct command_details *details, struct command_status *cstat)
  1. If the command is paused because it receives SIGTSTP, sudo will also send this signal to itself, Who is handling the SIGTSTP of sudo? Default handling by the signal system? or signal_cb_pty (or signal_cb_nopty)? but I don't see the code in signal_cb_pty (or signal_cb_nopty).
  2. If sudo does suspend, who will notify it of the resumption and how? (notty + tty)
    In scenarios where tty is required:
    The code says: /* Suspend parent and tell monitor how to resume on return. */
    But,I didn't see how
  3. The sudo.man says "This makes it possible to suspend and resume the command." in scenarios where tty is required.
    But I see that they(tty + notty) handle Command suspension scenario very similarly in their code. Why distinguish between the two models when both can be paused?

I don't think I can get out on my own :D, I'm looking forward to your reply.