1#!/bin/sh
2# Ensure "install -C" compares owner and group.
3
4# Copyright (C) 2008-2023 Free Software Foundation, Inc.
5
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20print_ver_ ginstall
21require_root_
22skip_if_setgid_
23skip_if_nondefault_group_
24
25u1=1
26u2=2
27g1=1
28g2=2
29
30
31echo test > a || framework_failure_
32echo "'a' -> 'b'" > out_installed_first
33echo "removed 'b'
34'a' -> 'b'" > out_installed_second
35> out_empty
36
37# destination file does not exist
38ginstall -Cv -o$u1 -g$g1 a b > out || fail=1
39compare out out_installed_first || fail=1
40
41# destination file exists
42ginstall -Cv -o$u1 -g$g1 a b > out || fail=1
43compare out out_empty || fail=1
44
45# destination file exists but -C is not given
46ginstall -v -o$u1 -g$g1 a b > out || fail=1
47compare out out_installed_second || fail=1
48
49# destination file exists but owner differs
50ginstall -Cv -o$u2 -g$g1 a b > out || fail=1
51compare out out_installed_second || fail=1
52ginstall -Cv -o$u2 -g$g1 a b > out || fail=1
53compare out out_empty || fail=1
54
55# destination file exists but group differs
56ginstall -Cv -o$u2 -g$g2 a b > out || fail=1
57compare out out_installed_second || fail=1
58ginstall -Cv -o$u2 -g$g2 a b > out || fail=1
59compare out out_empty || fail=1
60
61# destination file exists but owner differs from getuid ()
62ginstall -Cv -o$u2 a b > out || fail=1
63compare out out_installed_second || fail=1
64ginstall -Cv a b > out || fail=1
65compare out out_installed_second || fail=1
66ginstall -Cv a b > out || fail=1
67compare out out_empty || fail=1
68
69# destination file exists but group differs from getgid ()
70ginstall -Cv -g$g2 a b > out || fail=1
71compare out out_installed_second || fail=1
72ginstall -Cv a b > out || fail=1
73compare out out_installed_second || fail=1
74ginstall -Cv a b > out || fail=1
75compare out out_empty || fail=1
76
77Exit $fail
78