Commit 59c1bf97 authored by Michael Shigorin's avatar Michael Shigorin

initial nodm autologin support

This one is contributed by Max Kosmach and somewhat streamlined/tweaked by me; a part of it rather belongs to nodm and xinitrc packages but is not exactly trivial to get it there due to the looming systemd-logind/consolekit disaster; see also #27449. Several hacks to make NetworkManager usable in a LiveCD environment are there too (but it resists so far).
parent 743bc279
...@@ -9,6 +9,10 @@ use/live: use/stage2 sub/stage2/live ...@@ -9,6 +9,10 @@ use/live: use/stage2 sub/stage2/live
use/live/base: use/live use/syslinux/ui/menu use/live/base: use/live use/syslinux/ui/menu
@$(call add,LIVE_LISTS,$(call tags,base && (live || network))) @$(call add,LIVE_LISTS,$(call tags,base && (live || network)))
# a very simplistic one
use/live/x11: use/live use/x11/xorg
@$(call add,LIVE_PACKAGES,xinit)
# optimized out: use/x11/xorg # optimized out: use/x11/xorg
use/live/desktop: use/live/base use/x11/wacom use/live/sound +vmguest +power use/live/desktop: use/live/base use/x11/wacom use/live/sound +vmguest +power
@$(call add,LIVE_LISTS,$(call tags,desktop && (live || network))) @$(call add,LIVE_LISTS,$(call tags,desktop && (live || network)))
...@@ -26,9 +30,12 @@ use/live/textinstall: use/syslinux/localboot.cfg ...@@ -26,9 +30,12 @@ use/live/textinstall: use/syslinux/localboot.cfg
# NB: there's an unconditional live/image-scripts.d/40-autologin script # NB: there's an unconditional live/image-scripts.d/40-autologin script
# *but* it only configures some of the *existing* means; let's add one # *but* it only configures some of the *existing* means; let's add one
# for the cases when there should be no display manager # or another for the cases when there should be no display manager
use/live/autologin: use/live use/x11/xorg use/live/autologin: use/live/x11
@$(call add,LIVE_PACKAGES,autologin xinit) @$(call add,LIVE_PACKAGES,autologin)
use/live/nodm: use/live/x11
@$(call add,LIVE_PACKAGES,nodm)
use/live/hooks: use/live use/live/hooks: use/live
@$(call add,LIVE_PACKAGES,livecd-run-hooks) @$(call add,LIVE_PACKAGES,livecd-run-hooks)
......
#!/bin/sh -ef #!/bin/sh -e
if [ ! -x /usr/bin/X ]; then if [ ! -x /usr/bin/X ]; then
echo "SKIP autologin: X not installed" >&2 echo "SKIP autologin: X not installed" >&2
...@@ -7,14 +7,14 @@ fi ...@@ -7,14 +7,14 @@ fi
USER=altlinux USER=altlinux
# setup runlevel ## setup runlevel
INITTAB=/etc/inittab INITTAB=/etc/inittab
if [ -f "$INITTAB" ]; then if [ -f "$INITTAB" ]; then
[ -z "$runlevel" ] && runlevel=5 [ -z "$runlevel" ] && runlevel=5
sed -i "s,^\(id:\)\(.*\)\(:initdefault.*\),\\1$runlevel\\3," "$INITTAB" sed -i "s,^\(id:\)\(.*\)\(:initdefault.*\),\\1$runlevel\\3," "$INITTAB"
fi fi
# autologin^2 ## autologin^2
if [ -x /usr/sbin/autologin ]; then if [ -x /usr/sbin/autologin ]; then
cat << E_O_F >> /etc/sysconfig/autologin cat << E_O_F >> /etc/sysconfig/autologin
USER=$USER USER=$USER
...@@ -22,7 +22,7 @@ AUTOLOGIN=yes ...@@ -22,7 +22,7 @@ AUTOLOGIN=yes
E_O_F E_O_F
fi fi
# lightdm autologin ## lightdm autologin
LIGHTDM_CONF=/etc/lightdm/lightdm.conf LIGHTDM_CONF=/etc/lightdm/lightdm.conf
if [ -f "$LIGHTDM_CONF" ]; then if [ -f "$LIGHTDM_CONF" ]; then
sed -i \ sed -i \
...@@ -31,14 +31,14 @@ if [ -f "$LIGHTDM_CONF" ]; then ...@@ -31,14 +31,14 @@ if [ -f "$LIGHTDM_CONF" ]; then
"$LIGHTDM_CONF" "$LIGHTDM_CONF"
fi fi
# gdm2 autologin ## gdm2 autologin
GDM_CONF=/etc/X11/gdm/custom.conf GDM_CONF=/etc/X11/gdm/custom.conf
if [ -f "$GDM_CONF" ]; then if [ -f "$GDM_CONF" ]; then
sed -i -e '/\[daemon\]/aAutomaticLoginEnable=true\nAutomaticLogin='$USER \ sed -i -e '/\[daemon\]/aAutomaticLoginEnable=true\nAutomaticLogin='$USER \
"$GDM_CONF" "$GDM_CONF"
fi fi
# kdm3 autologin ## kdm3 autologin
# TODO: iterate over kdm{,4} if feasible # TODO: iterate over kdm{,4} if feasible
KDMRC=/etc/X11/kdm/kdmrc KDMRC=/etc/X11/kdm/kdmrc
if [ -f "$KDMRC" ]; then if [ -f "$KDMRC" ]; then
...@@ -47,3 +47,66 @@ if [ -f "$KDMRC" ]; then ...@@ -47,3 +47,66 @@ if [ -f "$KDMRC" ]; then
-e '/AutoLoginUser/ s,^.*$,AutoLoginUser='$USER',' \ -e '/AutoLoginUser/ s,^.*$,AutoLoginUser='$USER',' \
"$KDMRC" "$KDMRC"
fi fi
## nodm autologin (the last since the most intrusive)
# FIXME nodm and xinitrc should be modified (also in p6)
NODM_RC=/etc/sysconfig/nodm
NODM_EXE=/usr/sbin/nodm
if [ -x "$NODM_EXE" ]; then
cat << E_O_F >> "$NODM_RC"
export NODM_USER=$USER
E_O_F
else
exit 0
fi
# FIXME: drop when #27449 is fixed
PREFDM=/etc/X11/prefdm
if [ -f "$PREFDM" ] && ! grep -q nodm "$PREFDM"; then
sed -i \
-e '/AUTOLOGIN_EXE=/ s,^.*$,AUTOLOGIN_EXE='$NODM_EXE',' \
-e '/AUTOLOGIN_CFG=/ s,^.*$,AUTOLOGIN_CFG='$NODM_RC',' \
"$PREFDM"
fi
# FIXME: drop when #27451 is fixed
NODM_PAM=/etc/pam.d/nodm
for module in pam_console.so pam_ck_connector.so; do
if [ -f /lib*/security/$module ]; then
str="-session optional $module"
grep -q "^$str$" "$NODM_PAM" || echo -e "$str" >> "$NODM_PAM"
fi
done
NODM_POLKIT_CONFDIR=/etc/polkit-1/localauthority/50-local.d
NODM_POLKIT_CONF=org.freedesktop.NetworkManager.pkla
if [ -d "$NODM_POLKIT_CONFDIR" ]; then
cat > "$NODM_POLKIT_CONFDIR/$NODM_POLKIT_CONF" << _EOF_
[nm-applet]
Identity=unix-group:users
Action=org.freedesktop.NetworkManager.*
ResultAny=yes
ResultInactive=no
ResultActive=yes
_EOF_
fi
NODM_DBUS_NM_CONF=/etc/dbus-1/system.d/nm-applet.conf
if [ -f "$NODM_DBUS_NM_CONF" ]; then
sed -i "s/at_console=\"true\"/user=\"$USER\"/" "$NODM_DBUS_NM_CONF"
fi
NODM_G2KR_DIR=/etc/skel/.gnome2/keyrings
mkdir -p "$NODM_G2KR_DIR"
echo -n login > "$NODM_G2KR_DIR"/default
cat > "$NODM_G2KR_DIR"/login.keyring << _EOF_
[keyring]
display-name=login
ctime=0
mtime=0
lock-on-idle=false
lock-after=false
_EOF_
:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment