~ubuntu-core-dev/livecd-rootfs/bionic-proposed

« back to all changes in this revision

Viewing changes to live-build/ubuntu-desktop-next/hooks/99zz-check-uid-gid.chroot

  • Committer: Balint Reczey
  • Date: 2019-01-31 08:14:49 UTC
  • Revision ID: balint.reczey@canonical.com-20190131081449-n8ne0p9wd90j5cle
Moved to git at https://git.launchpad.net/livecd-rootfs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -eu
2
 
 
3
 
ERRCNT=""
4
 
 
5
 
passwd_hash=$(set -- $(md5sum /etc/passwd) && echo $1)
6
 
shadow_hash=$(set -- $(cat /etc/shadow | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1)
7
 
group_length=$(cat /etc/group | wc -l)
8
 
gshadow_length=$(cat /etc/gshadow | wc -l)
9
 
 
10
 
passwd_orig_hash=$(set -- $(md5sum /etc/passwd.orig) && echo $1)
11
 
shadow_orig_hash=$(set -- $(cat /etc/shadow.orig | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1)
12
 
group_orig_length=$(cat /etc/group.orig | wc -l)
13
 
gshadow_orig_length=$(cat /etc/gshadow.orig | wc -l)
14
 
 
15
 
if [ "$passwd_hash" != "$passwd_orig_hash" ]; then
16
 
    echo "/etc/passwd has changed during setup." >&2
17
 
    echo "The new /etc/passwd md5sum is: $passwd_hash" >&2
18
 
    diff -Nrup /etc/passwd.orig /etc/passwd >&2 || true
19
 
    ERRCNT=1
20
 
fi
21
 
 
22
 
if [ "$shadow_hash" != "$shadow_orig_hash" ]; then
23
 
    echo "/etc/shadow has changed during setup." >&2
24
 
    echo "The new /etc/shadow md5sum is: $shadow_hash" >&2
25
 
    diff -Nrup /etc/shadow.orig /etc/shadow >&2 || true
26
 
    ERRCNT=1
27
 
fi
28
 
 
29
 
if [ "$group_length" != "$group_orig_length" ]; then
30
 
    echo "/etc/group has changed during setup." >&2
31
 
    diff -Nrup /etc/group.orig /etc/group >&2 || true
32
 
    ERRCNT=1
33
 
fi
34
 
 
35
 
if [ "$gshadow_length" != "$gshadow_orig_length" ]; then
36
 
    echo "/etc/gshadow has changed during setup." >&2
37
 
    diff -Nrup /etc/gshadow.orig /etc/gshadow >&2 || true
38
 
    ERRCNT=1
39
 
fi
40
 
 
41
 
if [ -n "$ERRCNT" ]; then
42
 
        echo "There were changes to the password database," >&2
43
 
        echo "please adjust the values in the livecd-rootfs source in the file:" >&2
44
 
        echo "live-build/ubuntu-core/hooks/00-uid-gid-fix.chroot_early" >&2
45
 
        echo >&2
46
 
        echo "Please check also if a maintainer script of the package" >&2
47
 
        echo "that added these entries perhaps created a home directory and," >&2
48
 
        echo "if needed, add code for creation of it to the above hook" >&2
49
 
        exit 1
50
 
fi
51
 
 
52
 
rm /etc/passwd.orig /etc/shadow.orig /etc/group.orig /etc/gshadow.orig