Why does su command ignore SIGSTOP?

z0lupka

After entering su when I prompted to enter a password:

user@debian:~$ su
Password:

I can't send SIGSTOP (ctrl+Z) from my keyboard (the same terminal) - nothing happens. So the only way to exit is to type some (right or wrong) password. Why can't I suspend su such a way?

UPD: It seems that ctrl+Z is queued. Thus when sending ctrl+Z - nothing happens, but then after typing Enter signal arrives and su becomes stopped. Still can't understand such behavior. Is this standard behavior for all Unix-like or just Linux?

JdeBP

Let's clear up some basic errors:

  1. The signal is not queued. Queueing is a specific thing when it comes to signals, and does not happen with this particular signal. The signal is masked.
  2. This particular signal is not SIGSTOP. The susp character causes the line discipline to send a SIGTSTP.

As with so many things that contradict the 1980s view of the login and su commands, the root of the behaviour here is PAM.

It's not su doing this. And it does not happen on operating systems other than those using the Linux PAM library. It does not happen on the BSDs using the OpenPAM library, for example.

It is the Linux PAM provided PAM module named pam_unix doing this. More specifically, it is the library-supplied default "conversation" function misc_conv(), called inside the pam_unix code, that is doing this. It specifically masks SIGTSTP whilst it is prompting for an item of input, ostensibly so that the library can clean up. This is why the signal is not delivered until the input has been entered.

OpenPAM supplies a pam_unix PAM module too. This calls the OpenPAM library-supplied default "conversation" function openpam_ttyconv(). That latter does not mask signals. No-one seems to have noticed that one can suspend su at the password prompt on FreeBSD et al. and the terminal will be left with echo turned off. This is possibly because the operating-system-supplied command-line shells on FreeBSD all have line editing libraries, which immediately re-adjust terminal settings when they take over to prompt for input and do their own echoing anyway.

Further reading

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why does SIGTSTP exist when there is already SIGSTOP?

From Dev

Why does 'tree' command ignore directories but not files

From Dev

Why does Scala ignore exclamation points in command line arguments?

From Dev

How does the "su" command work?

From Dev

Why doesn't the 'su' command work in Ubuntu but does in other Linux distros?

From Dev

SIGSTOP does not work when scripted

From Dev

Why does Git ignore these folders?

From Dev

Why does FloatToStr ignore ThousandSeparator?

From Dev

Why does setInterval() ignore errors?

From Dev

Why does GLSL ignore return?

From Dev

Why does sudo ignore aliases?

From Dev

Why does bash ignore SIGTERM?

From Dev

Why Gulp does not ignore the file?

From Dev

Why does "su - -c" make this fail?

From Dev

Why does my su start in background?

From Dev

How does SIGSTOP work in Linux kernel?

From Dev

Why does AngularJS ignore $scope field change?

From Dev

Why does this code ignore the await and proceed anyway?

From Dev

Why does make ignore my modifications?

From Dev

Why does Python requests ignore the verify parameter?

From Dev

Why does Git ignore the .vs directory?

From Dev

Why does SQL Anywhere ignore the @ named parameter?

From Dev

Why does XhtmlTextWriter ignore custom attributes?

From Dev

Why does Linq ignore my where clause?

From Dev

Why does Yii ignore my .po file?

From Dev

Why does my Android transition ignore the TransitionListener?

From Dev

Why does expand.grid ignore options?

From Dev

Why does for /f not ignore blank lines?

From Dev

Why does HTMLDocument ignore white spaces