CRANIX session: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Admin (Diskussion | Beiträge) Die Seite wurde neu angelegt: „== CRANIX Session == Auf dem Server wird eine Session für jede Anmeldung an einem Client-Rechner erstellt. Diese Session dient dazu, in der CRANIX-Admin-Oberfläche den angemeldeten Benutzer anzuzeigen bzw. zu entscheiden, in welches Verzeichnis eine ausgeteilte Datei gelangt. === Programme === Folgende Programme sind notwendig: ==== pam_session ==== Die Datei /home/profiles/linux/pam_session mit dem Inhalt: #!/bin/bash # Copyright (c) 2016 Peter Var…“ |
(kein Unterschied)
|
Aktuelle Version vom 31. Januar 2025, 20:56 Uhr
CRANIX Session
Auf dem Server wird eine Session für jede Anmeldung an einem Client-Rechner erstellt. Diese Session dient dazu, in der CRANIX-Admin-Oberfläche den angemeldeten Benutzer anzuzeigen bzw. zu entscheiden, in welches Verzeichnis eine ausgeteilte Datei gelangt.
Programme
Folgende Programme sind notwendig:
pam_session
Die Datei /home/profiles/linux/pam_session mit dem Inhalt:
#!/bin/bash
# Copyright (c) 2016 Peter Varkoly <peter@varkoly.de> Nürnberg, Germany. All rights reserved.
# edited and supplied with additional systemd script cranix_session@.service by Frank Schütte <fschuett@gymhim.de>
if [ "$PAM_USER" = "root" -o "$PAM_USER" = "gast" -o "$PAM_USER" = "sddm" ]
then
exit 0;
fi
read p
TOKENFILE=TOKEN-$(id -u $PAM_USER)
rm -f /tmp/pw
#date >> /tmp/pw
#set >> /tmp/pw
#echo "PAM_USER: $PAM_USER, PAM_TYPE: $PAM_TYPE, PAM_SERVICE: $PAM_SERVICE TOKEN: $TOKENFILE" >> /tmp/pw
if [ "$PAM_TYPE" = "auth" ]; then
# echo curl --insecure -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: text/plain' -d "username=$PAM_USER&password=$p" 'https://admin/api/sessions/login' >>/tmp/pw
TOKEN=$( curl --insecure -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: text/plain' --data-urlencode "username=$PAM_USER" --data-urlencode "password=$p" 'https://admin/api/sessions/login' )
if [ "$TOKEN" -a "${TOKEN:0:7}" != '{"code"' ]
then
echo $TOKEN > /tmp/$TOKENFILE
exit 0
else
exit 1
fi
fi
if [ "$PAM_TYPE" = "close_session" -a -s /tmp/$TOKENFILE ]; then
if [ $PAM_SERVICE = "gdm" -o $PAM_SERVICE = "kdm" -o $PAM_SERVICE = "login" -o $PAM_SERVICE = "xdm" -o $PAM_SERVICE = "sddm" -o $PAM_SERVICE = "cranix_session" ]; then
TOKEN=$( cat /tmp/$TOKENFILE )
curl --insecure -X DELETE --header 'Content-Type: application/x-www-form-urlencoded' --header "Authorization: Bearer $TOKEN" "https://admin/api/sessions/$TOKEN"
rm -r /tmp/$TOKENFILE
fi
exit 0
fi
cranix_session@.service
Die Datei /usr/lib/systemd/system/cranix_session@.service mit dem Inhalt:
# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Notify CRANIX server of user login / logout Before=user@%i.service [Service] Type=oneshot RemainAfterExit=yes Slice=user-%i.slice RemainAfterExit=yes StandardOutput=journal StandardError=syslog SyslogIdentifier=cranix_session ExecStart=/usr/bin/env PAM_USER=%i PAM_SERVICE=cranix_session PAM_TYPE=open_session /home/profiles/linux/pam_session ExecStop=/usr/bin/env PAM_USER=%i PAM_SERVICE=cranix_session PAM_TYPE=close_session /home/profiles/linux/pam_session [Install] WantedBy=user@%i.service
Anmeldung am Rechner
Bei der Anmeldung wird der Dienst PAM aktiviert, daher muss an entsprechenden Stellen die Datei pam_session ausgeführt werden. Dazu wird an geeigneter Stelle unter /etc/pam.d hinzugefügt:
session optional pam_exec.so /home/profiles/linux/pam_session
und
auth required pam_exec.so expose_authtok /home/profiles/linux/pam_session
Außerdem muss der cranix_service@ aktiviert werden mit:
systemctl enable cranix_session@
(Vorher muss eventuell ein
systemctl daemon-reload
ausgeführt werden.)