xref: /illumos-gate/usr/src/test/util-tests/tests/find/findroot.ksh (revision 47ec9542e2cec788e0d0ff35e54ad5cef6f520d5)
1#!/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12# Copyright 2024 Bill Sommerfeld <sommerfeld@hamachi.org>
13#
14
15#
16# Tests for find(1) that exercise file ownership tests and thus need
17# to run as root to set up the test
18#
19
20# Regression test for SID operations
21
22. "$(dirname $0)/find.kshlib"
23
24if [ $(svcs -H -o state svc:/system/idmap) != "online" ]; then
25    echo "svc:/system/idmap not enabled and online; can't do SID-to-UID mapping" >&2
26    exit 4
27fi
28
29sida=S-1-5-21-11111111-22222222-33333333
30sidb=S-1-5-21-44444444-55555555-66666666
31
32mkdir -p $find_dir/a
33mkdir -p $find_dir/b
34
35# Functional test for -usid and -gsid
36
37chown -s $sida $find_dir/a
38chgrp -s $sidb $find_dir/b
39
40cd $find_dir
41
42testfind "./a", $find_prog . -usid ${sida}
43testfind "./b", $find_prog . -gsid ${sidb}
44
45# Functional test for -usidacl and -gsidacl
46
47chmod A+groupsid:${sidb}:read_set:allow $find_dir/a
48chmod A+usersid:${sida}:read_set:allow $find_dir/b
49
50testfind "./a", $find_prog . -gsidacl ${sidb}
51testfind "./b", $find_prog . -usidacl ${sida}
52
53# Functional test for -sidacl
54
55mkdir $find_dir/c
56mkdir $find_dir/d
57
58chmod A+groupsid:${sida}:read_set:allow $find_dir/c
59chmod A+usersid:${sidb}:read_set:allow $find_dir/d
60
61testfind "./b,./c," $find_prog . -sidacl ${sida}
62testfind "./a,./d," $find_prog . -sidacl ${sidb}
63
64cd -
65rm -rf $find_dir
66
67exit $find_exit
68