This forum has been archived. All content is frozen. Please use KDE Discuss instead.

KDM forbid multiple sessions per user

Tags: None
(comma "," separated)
samuelm1
Registered Member
Posts
4
Karma
0
OS
Hi,
How is it possible to configure KDM so that it does not allow any user to have more than one session? On GDM for example, if you're already logged in, and you go to the login screen and try to login again, GDM will automatically redirect you to your current session and unlock your screen. KDM, instead of doing the same, will actually start a second session. How can I configure KDM to behave like GDM in this respect?

Thanks,
samuelm1
User avatar
google01103
Manager
Posts
6668
Karma
25
I'd look @ PAM http://www.kernel.org/pub/linux/libs/pa ... imits.html
maxlogins - maximum number of logins for this user
maxsyslogins - maximum number of logins on system


note: limits.conf is the configuration file for the pam_limits module, just run: man limits.conf"


OpenSuse Leap 42.1 x64, Plasma 5.x

samuelm1
Registered Member
Posts
4
Karma
0
OS
Thank you for your answer. That works, almost. Is there any way to limit just the graphical sessions? Also, is there a bash command or a dbus call to kdm with which I can switch X displays to the correct session (i.e. the session of the user that tried to login again)?
User avatar
google01103
Manager
Posts
6668
Karma
25
different questions - should probably create new threads

easy answer - use gdm instead of kdm


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
dpalacio
Registered Member
Posts
240
Karma
2
OS
samuelm1 wrote:Thank you for your answer. That works, almost. Is there any way to limit just the graphical sessions?


Hi. KDM should have a pam config file of it own (on my system it is /etc/pam.d/kdm). Using pam_limits with option conf=/path/to/gui-users-limits.conf should do what you want.


connect(post, SIGNAL(readSignature()), qapp, SLOT(quit()));
dtr
Registered Member
Posts
1
Karma
0
Hello dpalacio,
This is probably a dumb question, but do you mean that I could just add conf=/path/to/gui-users-limits.conf to the kdm file in /etc/pam.d/kdm? Or do I need to make changes to conf=/path/to/gui-users-limits.conf, if so can you give an example.

thanks
User avatar
dpalacio
Registered Member
Posts
240
Karma
2
OS


connect(post, SIGNAL(readSignature()), qapp, SLOT(quit()));
samuelm1
Registered Member
Posts
4
Karma
0
OS
I know it's been almost six months since the last post, but for those interested I have found a solution. I did some investigating into the inner workings of KDM, and found out that KDM executes a script called "Xstartup" (in my case, it was in /etc/kde4/kdm) before starting a session. Editing the script allowed me to achieve what I wanted. Here's how to do it:

Remove the following line from the end of /etc/kde4/kdm/Xstartup:

Code: Select all
/sbin/initctl -q emit desktop-session-start DISPLAY_MANAGER=kdm USER=$USER


Then, append the following lines to the end of the file:

Code: Select all
SESSIONS=$(/usr/bin/kdmctl list | grep $USER)
if [ "${SESSIONS:0:2}" == "ok" ]; then
        SESSIONS=(${SESSIONS//\\t/ })
        for i in ${SESSIONS[@]}
        do
                find_user=$(echo $i | grep $USER)
                if [[ "$find_user" != "" && "${i:0:1}" == ":" ]]; then
                        X_DISPLAY=${i:0:2}
                        break
                fi
        done
        if ["$X_DISPLAY" == ""]
        then
                /sbin/initctl -q emit desktop-session-start DISPLAY_MANAGER=kdm USER=$USER
        else
                kdmctl activate $X_DISPLAY
                DISPLAY="$X_DISPLAY"
                su --preserve-environment -c "/usr/bin/qdbus org.kde.screenlocker /MainApplication quit && /usr/bin/qdbus org.kde.screensaver /MainApplication quit" $USER
                exit 1
        fi
else
        /sbin/initctl -q emit desktop-session-start DISPLAY_MANAGER=kdm USER=$USER
fi


This addition to the script makes KDM behave in the following way:

As normal, if you enter an incorrect password, it won't let you login.

If you do enter a correct username/password combination and do not have an already-running graphical session under your username, KDM will login you in as normal.

If you do enter a correct username/password combination and have an already-running graphical session under your username, KDM will terminate the currently running new session that you started, transfer you back to your already running session, and unlock your screen.

Enjoy!

samuelm1

P.S. You need the qdbus executable in order for screen unlocking to work. Also, screen unlocking will not work for non-KDE graphical sessions running under KDM.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You may wish to post this in Tutorials & Tips.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Luda
Registered Member
Posts
19
Karma
0
OS
I think there is an updated version: viewtopic.php?f=14&t=102164

In our office we use Gnome and KDE and need a DM that can display a long userlist and has the option to type in usernames, which currently only leaves KDM. GDM and LightDM show lists, but there are no scrollbars, the lists can get longer than the screen and so on.

But there are problems with KDM as well:
I used the fix mentioned above, but when I log in (KDE), use "swicth user", then someone else logs in (Gnome), then uses "switch user" again and then I log in again, my KDE-session gets unlocked, but it shows the (locked) Gnome-Session. I have to manually select my KDE-Session with Ctrl+Alt+F$n.

I wonder what happend to Linux... 10 years ago I had the impression it was a multi-user-system. It doesn't really feel the same way today...
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Unlocking your session should not cause the active virtual terminal to change.
If two users are logged on using KDE, does this same behaviour occur?
Also, are you sure that only a KDE session is running under your user? (and that no user home directory is shared between the two users)


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Luda
Registered Member
Posts
19
Karma
0
OS
Yes, It also happens when both users are running KDE.
One of the useraccounts I used for this test has /home/$username1 as his homedirectory (/home is mounted via NFS), the other user uses /$username2.

Switching from one VT to the other after locking the screen works, but we want the users to use "switch user" or "lock screen; start new session", so anyone accessing the computer is greeted by the DM. The DM should be able to unlock and activate the running session if the user is already logged in.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Ok to clarify this, the issue is after logging in you are placed on the incorrect TTY if you have already logged in. Namely, you are placed on the TTY of the last user to login.

If this is the case, the bug is probably in the script you got from viewtopic.php?f=14&t=102164#p222372
It is activating the wrong TTY.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kde-naveen, Sogou [Bot], Yahoo [Bot]