mirror of
https://github.com/MatMasIt/guestacct.git
synced 2026-01-20 12:06:52 +01:00
First commit
This commit is contained in:
3
lightdm_add.conf
Normal file
3
lightdm_add.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[Seat:*]
|
||||||
|
session-setup-script=/usr/local/sbin/prepare-guest-home.sh
|
||||||
|
session-cleanup-script=/usr/local/sbin/prepare-guest-home.sh
|
||||||
31
notice.py
Executable file
31
notice.py
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# To put in home directory autoexec
|
||||||
|
import sys
|
||||||
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
from PyQt5.QtCore import Qt
|
||||||
|
|
||||||
|
# Create a Qt application
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
|
# Create a message box
|
||||||
|
msg = QMessageBox()
|
||||||
|
msg.setIcon(QMessageBox.Information)
|
||||||
|
|
||||||
|
msg.setWindowTitle("Welcome into the guest account!")
|
||||||
|
msg.setText("Welcome!\nThis is an ephemeral session.\n\nAll the changes made will be reverted at logout.\nPlease save your work elsewhere.\n\nFor more information, contact the administrator.")
|
||||||
|
msg.setStandardButtons(QMessageBox.Ok)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Set the window flags to remove all buttons (minimize, maximize, close)
|
||||||
|
msg.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
|
||||||
|
|
||||||
|
# Disable resizing by setting a fixed size
|
||||||
|
msg.setFixedSize(400, 200)
|
||||||
|
|
||||||
|
# Make the window modal (optional, to block interaction with other windows)
|
||||||
|
msg.setWindowModality(Qt.ApplicationModal)
|
||||||
|
|
||||||
|
# Show the message box in the center of the screen
|
||||||
|
msg.exec_()
|
||||||
34
prepare-guest-home.sh
Normal file
34
prepare-guest-home.sh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ "$USER" != "guest" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
GUEST_HOME="/home/guest"
|
||||||
|
SKELETON="/home/guest-freeze"
|
||||||
|
|
||||||
|
# Validate guest home directory: check if it's a symlink
|
||||||
|
if [ -L "$GUEST_HOME" ]; then
|
||||||
|
echo "Home directory is a symlink. Removing it and restoring as a directory."
|
||||||
|
rm -f "$GUEST_HOME" # Remove the symlink
|
||||||
|
|
||||||
|
# Recreate the home directory as a proper directory
|
||||||
|
mkdir -p "$GUEST_HOME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validate guest home directory exists and is not a symlink
|
||||||
|
if [ ! -d "$GUEST_HOME" ]; then
|
||||||
|
echo "Unsafe guest home or home directory creation failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove contents safely (if any) while ignoring "file not found" errors
|
||||||
|
find "$GUEST_HOME" -mindepth 1 -xdev -exec rm -rf -- {} + 2>/dev/null || true
|
||||||
|
|
||||||
|
# Restore skeleton safely
|
||||||
|
rsync -a --safe-links --no-devices --no-specials \
|
||||||
|
"$SKELETON"/ "$GUEST_HOME"/
|
||||||
|
|
||||||
|
# Fix ownership and permissions
|
||||||
|
chown -R guest:guest "$GUEST_HOME"
|
||||||
|
chmod 700 "$GUEST_HOME"
|
||||||
Reference in New Issue
Block a user