summaryrefslogtreecommitdiff
path: root/source/l/polkit/doinst.sh
blob: 3d81307e8e3859b49338067a009394825270af76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

if [ -r etc/pam.d/polkit-1.new ]; then
  config etc/pam.d/polkit-1.new
fi

# Make sure the polkitd user and group exist:
if ! grep -q "^polkitd:" etc/passwd ; then
  echo "polkitd:x:87:87:PolicyKit daemon owner:/var/lib/polkit:/bin/false" >> etc/passwd
fi
if ! grep -q "^polkitd:" etc/group ; then
  echo "polkitd:x:87:" >> etc/group
fi

# Remove obsolete rules:
rm -f etc/polkit-1/localauthority/50-local.d/*.pkla{,.new}
rm -f etc/polkit-1/rules.d/*.pkla{,.new}

# Remove obsolete directory:
rmdir etc/polkit-1/localauthority/50-local.d 2> /dev/null
rmdir etc/polkit-1/localauthority 2> /dev/null