lightdm: misc improvements.

This commit is contained in:
Juan RP 2012-04-20 10:22:48 +02:00
parent b04d585ecf
commit 95f5cbeec6
5 changed files with 109 additions and 212 deletions

View File

@ -1,194 +0,0 @@
#!/bin/sh
#
# This is SORT OF LIKE an X session, but not quite. You get a command as the
# first argument (it could be multiple words, so run it with "eval"). As a
# special case, the command can be:
# default - Run the appropriate Xclients startup (see the code below)
# custom - Run ~/.xsession and if that's not available run 'default'
#
# (Note that other arguments could also follow, but only the command one is
# right now relevant and supported)
#
# The output is ALREADY redirected to .xsession-errors in GDM. This way
# .xsession-errors actually gets more output such as if the PreSession script
# is failing. This also prevents DoS attacks if some app in the users session
# can be prodded to dump lots of stuff on the stdout/stderr. We wish to be
# robust don't we? In case you wish to use an existing script for other DM's,
# you can just not redirect when GDMSESSION is set. GDMSESSION will always
# be set from gdm.
#
# Also note that this is not run as a login shell, this is just executed.
# This is why we source the profile files below.
#
# based on:
# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
command="$@"
# this will go into the .xsession-errors along with all other echo's
# good for debugging where things went wrong
echo "$0: Beginning session setup..."
# First read /etc/profile and .profile
test -f /etc/profile && . /etc/profile
test -f "$HOME/.profile" && . "$HOME/.profile"
# Note that this should only go to zenity dialogs which always expect utf8
gettextfunc () {
if [ "x$gdmtranslate" != "x" ] ; then
"$gdmtranslate" --utf8 "$1"
else
echo "$1"
fi
}
OLD_IFS=$IFS
gdmwhich () {
COMMAND="$1"
OUTPUT=
IFS=:
for dir in $PATH
do
if test -x "$dir/$COMMAND" ; then
if test "x$OUTPUT" = "x" ; then
OUTPUT="$dir/$COMMAND"
fi
fi
done
IFS=$OLD_IFS
echo "$OUTPUT"
}
zenity=`gdmwhich zenity`
# Note: ~/.xsession-errors is now done in the daemon so that it
# works for ALL sessions (except ones named 'Failsafe')
# clean up after xbanner
freetemp=`gdmwhich freetemp`
if [ -n "$freetemp" ] ; then
"$freetemp"
fi
userresources="$HOME/.Xresources"
usermodmap="$HOME/.Xmodmap"
userxkbmap="$HOME/.Xkbmap"
sysresources=/etc/X11/Xresources
sysmodmap=/etc/X11/Xmodmap
sysxkbmap=/etc/X11/Xkbmap
rh6sysresources=/etc/X11/xinit/Xresources
rh6sysmodmap=/etc/X11/xinit/Xmodmap
# merge in defaults
if [ -f "$rh6sysresources" ]; then
xrdb -nocpp -merge "$rh6sysresources"
fi
if [ -f "$sysresources" ]; then
xrdb -nocpp -merge "$sysresources"
fi
if [ -f "$userresources" ]; then
xrdb -nocpp -merge "$userresources"
fi
# merge in keymaps
if [ -f "$sysxkbmap" ]; then
setxkbmap `cat "$sysxkbmap"`
XKB_IN_USE=yes
fi
if [ -f "$userxkbmap" ]; then
setxkbmap `cat "$userxkbmap"`
XKB_IN_USE=yes
fi
#
# Eeek, this seems like too much magic here
#
if [ -z "$XKB_IN_USE" -a ! -L /etc/X11/X ]; then
if grep '^exec.*/Xsun' /etc/X11/X > /dev/null 2>&1 && [ -f /etc/X11/XF86Config ]; then
xkbsymbols=`sed -n -e 's/^[ ]*XkbSymbols[ ]*"\(.*\)".*$/\1/p' /etc/X11/XF86Config`
if [ -n "$xkbsymbols" ]; then
setxkbmap -symbols "$xkbsymbols"
XKB_IN_USE=yes
fi
fi
fi
# xkb and xmodmap don't play nice together
if [ -z "$XKB_IN_USE" ]; then
if [ -f "$rh6sysmodmap" ]; then
xmodmap "$rh6sysmodmap"
fi
if [ -f "$sysmodmap" ]; then
xmodmap "$sysmodmap"
fi
if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
fi
unset XKB_IN_USE
# run all system xinitrc shell scripts.
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for i in /etc/X11/xinit/xinitrc.d/* ; do
if [ -x "$i" -a ! -d "$i" ]; then
. "$i"
fi
done
fi
if [ "x$command" = "xcustom" ] ; then
if [ -x "$HOME/.xsession" ]; then
command="$HOME/.xsession"
else
echo "$0: Cannot find ~/.xsession will try the default session"
command="default"
fi
fi
if [ "x$command" = "xdefault" ] ; then
if [ -x "$HOME/.Xclients" ]; then
command="$HOME/.Xclients"
elif [ -x /etc/X11/xinit/Xclients ]; then
command="/etc/X11/xinit/Xclients"
elif [ -x /etc/X11/Xclients ]; then
command="/etc/X11/Xclients"
else
if [ -n "$zenity" ] ; then
disptext=`gettextfunc "System has no Xclients file, so starting a failsafe xterm session. Windows will have focus only if the mouse pointer is above them. To get out of this mode type 'exit' in the window."`
"$zenity" --info --text "$disptext"
else
echo "$0: Cannot find Xclients"
fi
exec xterm -geometry 80x24+0+0
fi
fi
# add ssh-agent if found
sshagent="`gdmwhich ssh-agent`"
if [ -n "$sshagent" ] && [ -x "$sshagent" ] && [ -z "$SSH_AUTH_SOCK" ]; then
command="$sshagent -- $command"
elif [ -z "$sshagent" ] ; then
echo "$0: ssh-agent not found!"
fi
echo "$0: Setup done, will execute: $command"
eval exec $command
echo "$0: Executing $command failed, will run xterm"
if [ -n "$zenity" ] ; then
disptext=`gettextfunc "Failed to start the session, so starting a failsafe xterm session. Windows will have focus only if the mouse pointer is above them. To get out of this mode type 'exit' in the window."`
"$zenity" --info --text "$disptext"
fi
exec xterm -geometry 80x24+0+0

View File

@ -0,0 +1,13 @@
#%PAM-1.0
auth requisite pam_nologin.so
auth required pam_env.so
auth requisite pam_permit.so
auth sufficient pam_succeed_if.so uid >= 1000 quiet
auth required pam_deny.so
account required pam_unix.so
password required pam_deny.so
session required pam_loginuid.so
-session optional pam_systemd.so
session optional pam_keyinit.so revoke
session required pam_limits.so
session required pam_unix.so

View File

@ -1,10 +1,11 @@
#%PAM-1.0
auth requisite pam_nologin.so
auth required pam_env.so
auth required pam_unix.so
auth optional pam_gnome_keyring.so
account required pam_unix.so
session required pam_limits.so
session required pam_unix.so
session optional pam_gnome_keyring.so auto_start
password required pam_unix.so
auth requisite pam_nologin.so
auth required pam_env.so
auth required pam_unix.so
auth optional pam_gnome_keyring.so
account required pam_unix.so
session required pam_limits.so
session required pam_unix.so
session optional pam_systemd.so
password required pam_unix.so
session optional pam_gnome_keyring.so auto_start

View File

@ -0,0 +1,69 @@
#!/bin/sh
#
# LightDM wrapper to run around X sessions.
echo "Running X session wrapper"
# Load profile
for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do
if [ -f "$file" ]; then
echo "Loading profile from $file";
. "$file"
fi
done
# Load resources
for file in "/etc/X11/Xresources" "$HOME/.Xresources"; do
if [ -f "$file" ]; then
echo "Loading resource: $file"
xrdb -nocpp -merge "$file"
fi
done
# Load keymaps
for file in "/etc/X11/Xkbmap" "$HOME/.Xkbmap"; do
if [ -f "$file" ]; then
echo "Loading keymap: $file"
setxkbmap `cat "$file"`
XKB_IN_USE=yes
fi
done
# Load xmodmap if not using XKB
if [ -z "$XKB_IN_USE" ]; then
for file in "/etc/X11/Xmodmap" "$HOME/.Xmodmap"; do
if [ -f "$file" ]; then
echo "Loading modmap: $file"
xmodmap "$file"
fi
done
fi
unset XKB_IN_USE
# Run all system xinitrc shell scripts.
xinitdir="/etc/X11/xinit/xinitrc.d"
if [ -d "$xinitdir" ]; then
for script in $xinitdir/*; do
echo "Loading xinit script $script"
if [ -x "$script" -a ! -d "$script" ]; then
. "$script"
fi
done
fi
# Load Xsession scripts
xsessionddir="/etc/X11/Xsession.d"
if [ -d "$xsessionddir" ]; then
for i in `ls $xsessionddir`; do
script="$xsessionddir/$i"
echo "Loading X session script $script"
if [ -r "$script" -a -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
. "$script"
fi
done
fi
echo "X session wrapper complete, running session $@"
exec $@

View File

@ -1,11 +1,12 @@
# Template file for 'lightdm'
pkgname=lightdm
version=1.2.2
revision=1
revision=2
homepage="https://launchpad.net/lightdm"
distfiles="https://launchpad.net/lightdm/1.2/$version/+download/$pkgname-$version.tar.gz"
build_style=gnu-configure
configure_args="--with-greeter-user=lightdm --disable-static"
configure_args="--with-greeter-session=lightdm-gtk-greeter
--with-greeter-user=lightdm --disable-static --disable-tests"
short_desc="Light Display Manager"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-3, LGPL-3"
@ -21,7 +22,9 @@ long_desc="
conf_files="
/etc/lightdm/keys.conf
/etc/lightdm/lightdm.conf
/etc/lightdm/users.conf"
/etc/lightdm/users.conf
/etc/pam.d/lightdm
/etc/pam.d/lightdm-autologin"
provides="display-manager-1"
replaces="display-manager>=0"
@ -48,21 +51,26 @@ Add_dependency build gobject-introspection
Add_dependency full gnome-icon-theme
Add_dependency full dbus
post_install()
{
local xs="/usr/share/lightdm/Xsession"
Add_dependency run accountsservice
post_install() {
# Remove provided init file and use our own.
rm -rf ${DESTDIR}/etc/init
vinstall ${FILESDIR}/lightdm.service 644 lib/systemd/system
vinstall ${FILESDIR}/lightdm.pam 644 etc/pam.d lightdm
vinstall ${FILESDIR}/Xsession 755 usr/share/lightdm
vmkdir var/cache/lightdm
vinstall ${FILESDIR}/lightdm-autologin.pam 644 etc/pam.d lightdm-autologin
vinstall ${FILESDIR}/xsession 755 etc/lightdm
# Minimum UID shall be 1000 for ordinary users.
sed -i -e "s|^\(minimum-uid=\).*|\11000|" \
${DESTDIR}/etc/lightdm/users.conf
# Fix path to nologin.
sed -i -e "s|/usr/sbin/nologin|/sbin/nologin|g" \
${DESTDIR}/etc/lightdm/users.conf
# Provide a working session wrapper.
sed -i -e "s|^\#\(session-wrapper=\).*|\1${xs}|" \
sed -i -e "s|#session-wrapper=lightdm-session|session-wrapper=/etc/lightdm/xsession|g" \
${DESTDIR}/etc/lightdm/lightdm.conf
# Provide a working PAM autologin service.
sed -i -e "s|#autologin-session=UNIMPLEMENTED|#autologin-session=UNIMPLEMENTED\n#pam-service=lightdm-autologin|g" \
${DESTDIR}/etc/lightdm/lightdm.conf
}