Command to display SID and login name

There are two system calls getsid(2) and getlogin(2) that return session identifier and login name associated to current session, but it seems that there is no user command to show these values. I expect id(1) command to be able to show SID and login name, but it can not (at least in 6.4-STABLE release I'm currently using).

It should be quite easy to extend id(1) command to be able to print these values.

Are there any reason why these values could not be displayed via user commands?
 
Just clarify. Value returned by getlogin(2) system call may differ from value of USER environment variable. It also can differ from user name corresponding to current UID or EUID.

For example, "su -l" will change UID and EUID and $USER, but login name associated to current session as well as SID will be unchanged.
 
mvladimriov said:
For example, "su -l" will change UID and EUID and $USER, but login name associated to current session as well as SID will be unchanged.
su -l spawns a new process with the new UID. The parent process keeps the 'old' UID.

Code:
USER      PID  PPID  PGID   SID JOBC STAT  TT       TIME COMMAND
dice    15162 15161 15162 15162    0 Is     1    0:00.08 -tcsh (tcsh)
root    15185 15162 15185 15162    1 I      1    0:00.04 su -
root    15186 15185 15186 15162    1 S      1    0:00.09 -su (csh)
root    15249 15186 15249 15162    1 R+     1    0:00.01 ps -axj
 
Back
Top