source: trunk/debathena/config/reactivate/debian/snapshot-run @ 25609

Revision 25609, 2.3 KB checked in by jdreed, 12 years ago (diff)
In reactivate: * Avoid race conditions by inhibiting dbus-daemon-launch-helper during a chroot shutdown (Trac: #1052, probably)
  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# snapshot-run PROGRAM [ARGS]
4# Create an Athena login snapshot, run PROGRAM within it, and clean up
5# the snapshot.
6#
7# This script is run as the user who is logging in, usually as a wrapper
8# around their Xsession or shell. You probably want to run reactivate
9# immediately afterwards, as root.
10
11if [ -e /var/run/debathena-inhibit-dbus-helper ]; then
12    logger -p user.notice -t reactivate "debathena-inhibit-dbus-helper still exists in snapshot-run (shouldn't happen)"
13    rm /var/run/debathena-inhibit-dbus-helper
14fi
15
16set -e
17cd /
18
19addgroups="sudo admin lpadmin adm fuse cdrom floppy audio video plugdev scanner dialout lp"
20daemons="$(/usr/sbin/policy-rc.d --daemons)"
21
22# Setup
23
24session=$(schroot -c login -b)
25cleanup() {
26    # Teardown
27
28    # Remove file from above.
29    # (This also gets nuked in reactivate, but be paranoid)
30    rm -f /tmp/ticketenv
31
32    for daemon in $daemons; do
33        schr invoke-rc.d "$daemon" stop || [ $? = 100 ]
34    done
35
36    schroot -c "$session" -e
37}
38trap 'cleanup' EXIT
39sch() { schroot -r -c "$session" -- "$@"; }          # Run in the chroot
40schq() { schroot -q -r -c "$session" -- "$@"; }      # Run in the chroot quietly
41schr() { schroot -r -c "$session" -u root -- "$@"; } # Run in the chroot as root
42
43for group in $addgroups; do
44    schr env NSS_NONLOCAL_IGNORE=ignore getent group "$group" >/dev/null 2>&1 && schr adduser "$USER" "$group"
45done
46
47schr sed -i "/su-error/d" "/etc/pam.d/su.debathena"
48
49schr touch /ClusterLogin
50
51for daemon in $daemons; do
52    schr invoke-rc.d "$daemon" start || [ $? = 100 ]
53done
54
55schr rm /etc/debian_chroot
56
57# Deter people from thinking they can use /home as persistant storage
58# by punting it
59schr rm -rf /home
60
61# Fix up mtab so that df and friends work correctly
62schr sed -i "s| /var/lib/schroot/mount/${session}/| /|" /etc/mtab
63
64# Run the session
65#
66# We wrap the target command in sudo because it runs initgroups(3)
67# /after/ being chrooted, which puts users back in the groups we
68# added them to
69
70# Workaround for stupidity, see #928 for details
71# Remove this once we're running pam-afs-session 2.4
72# Run this inside the "set -e" block so it'll fail if necessary
73echo "KRB5CCNAME=$KRB5CCNAME" >| /tmp/ticketenv
74
75set +e
76
77echo "$USER ALL=(ALL) ALL" | schr sh -c "cat >> /etc/sudoers"
78
79cd
80schroot -c "$session" -r -p -- sudo -E -u "$USER" -- "$@"
81cd /
82
Note: See TracBrowser for help on using the repository browser.