0

In a Ubuntu 14.04 system, who has the following output:

user1   :0           2016-05-02 14:49 (:0)
user1   pts/4        2016-05-02 15:10 (:0)

So apparently just the pts/4 is used. But, for example, sudo fuser /dev/pts/1 produces as output 2573, which is cupsd. So, that terminal is used too, by a process.

In order to use a terminal, one has to make a login. user1 has logged in;

  • did processes like cups make a login as well?
  • If yes, what is the difference between a regular user login and a process login? It does not appear in who.
  • 1
    You don't need to login to get a terminal. Every xterm window gets a terminal. But you just login once on the display. – Barmar May 2 '16 at 22:05
  • 1
    There's little difference between opening terminals and opening other types of communication streams, like pipes and sockets. – Barmar May 2 '16 at 23:36
  • 1
    What I think you're really asking is how do programs like xterm get their terminal listed by the "who" command if they don't require authentication, is that right? – Barmar May 2 '16 at 23:37
  • 1
    I think the answer is that the file /var/run/utmp is writable by the utmp group, and these programs are set-GID to that group, so they can add update it. – Barmar May 2 '16 at 23:39
  • 1
    If it's set-uid to root then it can write to anything. The utmp group is for programs that don't need any other special privileges. – Barmar May 10 '16 at 16:47
1

Any program can allocate a pseudo-terminal, it doesn't have to involve a login. It's just another form of inter-process communication, which is useful if the application needs to emulate a terminal.

An example is the Expect program. It allocates a pseudo-terminal when it spawns a program, so that the program will act as if it's being run interactively by a user.

As for showing up in the who output, the program needs to be set-UID to root or set-GID to utmp to be able to update the /var/run/utmp file that lists which user is logged into each terminal. This is generally only done for programs that create interactive logins, like login, gnome-terminal, orxterm`.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.