[SOLVED] who and w does not display x server session user
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have Slackware 14.1 on a MSI Wind U100. I've been using Ubuntu for 10+ years. I have a script attempting to run xrandr. This is not working correctly (I can go into this, but I think my issue is below). Google is not my friend in this because everything says it should work as expected. In my investigations, I found what I think is the root issue, that being something that I just haven't configured quite correctly.
Installation of Slackware was: Full Installation excluding KDE and XFCE. XDM is DM, fluxbox is WM. runlevel is 4.
Logged into fluxbox (user), tty1 (root) and tty2 (user)
On tty1 or tty2, who and w only shows the tty sessions.
Code:
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - 13:05 19:05 0.15s 0.14s -bash
user tty2 - 13:05 19:05 0.15s 0.14s -bash
I open a terminal in flux box, then who and w (in either tty) show both tty sessions, and the lone terminal session
Code:
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - 13:05 19:00 0.15s 0.14s -bash
user tty2 - 13:05 19:05 0.15s 0.14s -bash
user pts/0 :0.0 13:35 6.00s 0.04S 0.00S -bash
On my workstation, which is Ubuntu 14.10, logged into xfce, and logged into a tty, running who and w in the tty shows that xfce session.
Code:
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - 13:05 19:00 0.15s 0.14s -bash
user tty2 - 13:05 19:05 0.15s 0.14s -bash
user :0 :0 11:45 ?xdm? 0.10s 0.15s upstart --user
user pts/0 :0.0 13:35 6.00s 0.04S 0.00S -bash
I know slackware doesn't have upstart, so I won't see that. But, it seems that I'm missing an important piece. I'm not using a DE, but simply a WM, and I feel Google is out right mocking me. Maybe I'm just not competent enough to see that they've given me correct information, but xdmcp doesn't seem appropriate, nor does it seem appropriate to forward X over ssh and I really don't see how hardware acceleration in Xorg will help me.
What am I missing? What configuration settings do I need to make sure I have?
I grepped all files in /var/log ( find . -type f -exec grep -H [wtmp|utmp] {} \; ) None of the files had "Registering your session ... wtmp and utmp". I flux starting with logging, I do not see any message for wtmp or utmp in that log file, and I see no errors for wtmp or utmp in .xsession-errors. I'm not familiar with wtmp or utmp, I do see the files in /var/log, but they appear to be in binary form.
However, last does show each of the logins for today (3 logins, root on tty1, user on tty2, user on flux): one for root on tty1, one for user on tty2 and one for user on pts/0. However, user on pts/0 appears to the open terminal I have in the fluxbox session. I rebooted and checked again (this time with out opening a terminal in flux). The results on that are (2 logins, user on tty2, user on flux): one for user on tty2.
Okay -- seems there's a apparently issues with XDM not registering correctly going back to at least 2003.
Here's a posting from ArchLinux that suggests to either make an edit with in pam (not a solution as I don't have pam installed) or use gdm, lxdm or kdm (which, I'm assuming is either going to set pam correctly).
However, I'll attempt to use this posting from bodenstab.org. It's from 2003, but I'll make back up of the files and see if it takes care of the issue.
If you look at /etc/X11/xdm/xdm-config you see the following:
Code:
...
! All displays should use authorization, but we cannot be sure
! X terminals may not be configured that way, so they will require
! individual resource settings.
DisplayManager*authorize: true
!
DisplayManager*chooser: /usr/lib64/X11/xdm/chooser
DisplayManager*startup: /usr/lib64/X11/xdm/Xstartup
DisplayManager*session: /usr/lib64/X11/xdm/Xsession
DisplayManager*reset: /usr/lib64/X11/xdm/Xreset
DisplayManager*authComplain: true
! The following three resources set up display :0 as the console.
DisplayManager._0.setup: /usr/lib64/X11/xdm/Xsetup_0
DisplayManager._0.startup: /usr/lib64/X11/xdm/GiveConsole
DisplayManager._0.reset: /usr/lib64/X11/xdm/TakeConsole
DisplayManager*loginmoveInterval: 10
...
Note the definitions for the "startup", resources.
First is set "DisplayManager*startup: /usr/lib64/X11/xdm/Xstartup".
The contents of this Xstartup file is:
Code:
#!/bin/sh
# Register a login (derived from GiveConsole as follows:)
#
exec /usr/bin/sessreg -a -w /var/log/wtmp -u /var/run/utmp -x /usr/lib64/X11/xdm/Xservers -l $DISPLAY -h "" $USER
Which will register the user in the wtmp and utmp file.
Now observe the following entries under the "! The following three resources set up display :0 as the console.".
The "DisplayManager._0.startup: /usr/lib64/X11/xdm/GiveConsole". This overrides the Xstartup entry provided by default...
The contents of GiveConsole are:
Code:
#!/bin/sh
# Assign ownership of the console to the invoking user
#
# By convention, both xconsole and xterm -C check that the
# console is owned by the invoking user and is readable before attaching
# the console output. This way a random user can invoke xterm -C without
# causing serious grief.
#
chown $USER /dev/console
This does NOT register the login in the umtp or wtmp files.
It isn't supposed to.
If you DO want the user registered, then you have ADD the line
This must be the LAST line (you can remove the "exec" if you want other commands to follow it though).
The choice of not registering the user as root is deliberate. I have seen places (usually on servers mind) where the console user is not registered to allow that user to check up on other users of the system without alerting them to the presence of the system administrator. (I caught a rogue user using zsh notify options to report when an user logged in - and logged out if it was one of the staff).
It also tends not to apply if the user is on a single user workstation as that is normally a don't care situation.
If you do want the user registered, then just add the sessreg command line to the GiveConsole file.
I was about to start trying to figure out what changes I needed to make. That's interesting, I appreciate learning something new. Now that you point out the setup, startup and reset overrides, it seems obvious to me and that I should have picked up on it, but again, I was on Ubuntu, and I didn't have to bother with this. My goal is to learn linux better, I'm on my way.
Following the logic, I'll add the sessreg command to the end of the GiveConsole script, then I should also add the sessreg command that unregisters (sessreg -d ...) to the end of the TakeConsole script as well. That way when I log out of the xsession, then I should no longer show up in a w or who listing. Or do I have a flaw in my reasoning?
Well, after having tested it out, I was able to resolve the original issue that took me down the path of registering the user. I had some other issues with the script, but I was able to export the display correctly after registering the user.
Thank you for the help. jpollard, I had this issue opened in another forum that I've been updating through this, I'll credit your response and post excerpts from so other users can see it at either site.
Last edited by Anaximander; 12-15-2014 at 10:21 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.