04-change-gids-and-uids 1.27 KB
Newer Older
1
2
3
4
#!/bin/sh

set -e

5
# Free the fixed GIDs and UIDs we're using.
6

7
echo "Change GIDs and UIDs"
8

9
Change_uid () {
10
	NAME="$1"
11
	NEW="$2"
12
	OLD="$(getent passwd "$NAME" | awk -F ':' '{print $3}')"
13

14
	if [ -n "$OLD" ]; then
15
16
17
18
19
20
21
		echo "Changing UID for $NAME ($OLD -> $NEW)"
		usermod --uid "$NEW" "$NAME"
		find / -wholename /proc -prune -o \( \! -type l -a -uid "$OLD" -exec chown "$NEW" '{}' \; \)
	fi
}

Change_gid () {
22
	NAME="$1"
23
	NEW="$2"
24
	OLD="$(getent group "$NAME" | awk -F ':' '{print $3}')"
25

26
	if [ -n "$OLD" ]; then
27
28
29
30
31
32
33
		echo "Changing GID for $NAME ($OLD -> $NEW)"
		groupmod --gid "$NEW" "$NAME"
		find / -wholename /proc -prune -o \( \! -type l -a -gid "$OLD" -exec chgrp "$NEW" '{}' \; \)
	fi
}


34
35
36
Change_uid tails-persistent-setup 150
Change_gid tails-persistent-setup 150

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
### Ensure GIDs are stable accross releases
#   ... otherwise, things such as tor@service are broken
#   after applying an automatic upgrade (#15695, #15424, #13426, #15407)

# Temporarily give these groups a GID that's out of the way, to avoid collisions
Change_gid vboxsf       1120
Change_gid monkeysphere 1130
Change_gid debian-tor   1140
Change_gid lpadmin      1150

# Finally, give these groups the desired GID
Change_gid vboxsf       112
Change_gid monkeysphere 113
Change_gid debian-tor   114
Change_gid lpadmin      115