weston-launch: get ttynr also when no user is given

In case an user is given but no tty, the code opens tty0 to allocate a
new tty. With that ttynr is known.

In case a tty name is given the user must be given too. In this case
we later recover the ttynr by using stat on the file tty file descriptor
which allows as to find the ttynr by looking at the devices minor number.

However, the third case, when no user and no tty name is given, we do
not get the ttynr.

This hasn't been a problem in practise since ttynr has not been used.
However, it makes sense to get the ttynr always for consistency. Also
upcomming fixes will start to make use of ttynr.

Fixes: 636156d5f6 ("weston-launch: Don't start new session unless -u is given")
Signed-off-by: Stefan Agner <stefan@agner.ch>
dev
Stefan Agner 5 years ago committed by Pekka Paalanen
parent aaa5b82e61
commit 77e3b056d7
  1. 2
      libweston/weston-launch.c

@ -589,7 +589,7 @@ setup_tty(struct weston_launch *wl, const char *tty)
return -1;
}
if (tty) {
if (!wl->new_user || tty) {
if (fstat(wl->tty, &buf) < 0) {
fprintf(stderr, "weston: stat %s failed: %s\n", tty,
strerror(errno));

Loading…
Cancel
Save