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.
BowPark
  • 4,895
  • 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 02 '16 at 22:05
  • @Barmar Maybe this is another question. You are right. But how is it possible to log in just once, and then have the possibility to open a lot of terminals without credentials? – BowPark May 02 '16 at 22:18
  • 1
    There's little difference between opening terminals and opening other types of communication streams, like pipes and sockets. – Barmar May 02 '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 02 '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 02 '16 at 23:39
  • @Barmar Sorry for the delay. The question you guessed is one of mine. I was only able to see that executables like /usr/bin/gnome-terminal belong to the user root and to the group root: I didn't see they belong to the utmp group. Anyway, I made a more specific question here. – BowPark May 09 '16 at 11:11
  • 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
  • Which question is the one I guessed? I don't see references to other questions here. – Barmar May 10 '16 at 16:48
  • @Barmar This was the question: "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?" – BowPark May 11 '16 at 10:01

1 Answers1

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`.

Barmar
  • 9,927