File: 010_non-existing_uids

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (42 lines) | stat: -rwxr-xr-x 713 bytes parent folder | download | duplicates (5)
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
#!/bin/bash

set -e 
$PREPARE_CLEAN > /dev/null
$INCLUDE_FUNCS
cd $WC

if [[ $UID -ne 0 ]]
then
  echo "Warning: cannot test changing userids as normal user."
	exit
fi

filename=uid-gid-test

# Find an unused id
function unused_id
{
  perl -e '$i=shift || 100; $grp=shift; $i++ while ($grp ? getgrgid($i) : getpwuid($i)); print $i' $1 $2
}

uid=`unused_id 100 0`
gid=`unused_id 100 1`

echo "Using UID $uid and GID $gid for unknown-user-tests."

if [[ -e $filename ]]
then
  rm $filename
	$BINq ci -m "delete the test-file"
fi

date > $filename
chown $uid.$gid $filename
echo "     ci1"
$BINq ci -m "uid-gid-test"

echo "Another line" >> $filename
echo "     ci2"
$BINq ci -m "uid-gid-expand"

$WC2_UP_ST_COMPARE