04-change-gids-and-uids 937 Bytes
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
37
38
39
40
41
Change_uid tails-persistent-setup 150
Change_gid tails-persistent-setup 150

# Ensure debian-tor's gid remains does not break upgrades (#15695)
Change_gid monkeysphere 151
Change_gid debian-tor 152
Change_gid lpadmin 153
Change_gid vboxsf 154