blob: 63cb5e911fbbac78fadc821206ebfc84535f047f (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/usr/bin/env bash
# Convert Arch's dynamically allocated UIDs and GIDs to traditional static ones.
set -u -e
# Only those groups which realistically would own files.
declare -A groups=(
adm 4
wheel 10
uucp 14
utmp 20
users 100
)
for name in "${!groups[@]}"; do
id=${groups[$name]}
current=$(getent -s files group "$id" | cut -d: -f1)
if [[ "$current" = "$name" ]]; then
echo "group '$name' ($id) ok"
elif [[ "$current" ]]; then
echo "error: id $id (for $name) already in use by '$current'" >&2
else
if [[ "$(getent -s files group "$name")" ]]; then
# use -o to ignore LDAP/Hesiod shadows
echo "changing group '$name' (to $id)"
find /dev -group "$name" -exec chown -c ":$id" {} +
groupmod -o -g "$id" "$name"
else
echo "creating group '$name' ($id)"
groupadd -o -g "$id" "$name"
fi
if [[ "$name" == utmp ]]; then
chown -c :utmp /run/utmp /var/log/{[bw]tmp,lastlog}
chown -c :utmp /usr/lib/utempter/utempter || true
chmod -c g+s /usr/lib/utempter/utempter || true
fi
if [[ "$name" == adm ]]; then
echo "resetting ACLs for /var/log/journal"
setfacl -R -b /var/log/journal
setfacl -R -m g:adm:rX,g:wheel:rX /var/log/journal
setfacl -R -dm g:adm:rX,g:wheel:rX /var/log/journal
fi
fi
done
grpck -s
|