1f08c3bdfSopenharmony_ci#!/bin/bash
2f08c3bdfSopenharmony_ci##############################################################
3f08c3bdfSopenharmony_ci#
4f08c3bdfSopenharmony_ci#  Copyright (c) International Business Machines  Corp., 2003
5f08c3bdfSopenharmony_ci#
6f08c3bdfSopenharmony_ci#  This program is free software;  you can redistribute it and/or modify
7f08c3bdfSopenharmony_ci#  it under the terms of the GNU General Public License as published by
8f08c3bdfSopenharmony_ci#  the Free Software Foundation; either version 2 of the License, or
9f08c3bdfSopenharmony_ci#  (at your option) any later version.
10f08c3bdfSopenharmony_ci#
11f08c3bdfSopenharmony_ci#  This program is distributed in the hope that it will be useful,
12f08c3bdfSopenharmony_ci#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
13f08c3bdfSopenharmony_ci#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
14f08c3bdfSopenharmony_ci#  the GNU General Public License for more details.
15f08c3bdfSopenharmony_ci#
16f08c3bdfSopenharmony_ci#  You should have received a copy of the GNU General Public License
17f08c3bdfSopenharmony_ci#  along with this program;  if not, write to the Free Software
18f08c3bdfSopenharmony_ci#  Foundation,
19f08c3bdfSopenharmony_ci#
20f08c3bdfSopenharmony_ci#  FILE        : tacl_xattr.sh
21f08c3bdfSopenharmony_ci#  USAGE       : ./tacl_xattr.sh
22f08c3bdfSopenharmony_ci#
23f08c3bdfSopenharmony_ci#  DESCRIPTION : A script that will test ACL and Extend Attribute on Linux system.
24f08c3bdfSopenharmony_ci#  REQUIREMENTS:
25f08c3bdfSopenharmony_ci#                1) Kernel with loop device support
26f08c3bdfSopenharmony_ci#                2) A spare (scratch) disk partition of 100MB or larger.
27f08c3bdfSopenharmony_ci#                3) Kernel with ACL and Extend Attribute function support
28f08c3bdfSopenharmony_ci#
29f08c3bdfSopenharmony_ci#  HISTORY     :
30f08c3bdfSopenharmony_ci#      10/23/2003 Kai Zhao (ltcd3@cn.ibm.com)
31f08c3bdfSopenharmony_ci#      07/06/2004 Jacky Malcles enable ext3 & clean users home dir.
32f08c3bdfSopenharmony_ci#
33f08c3bdfSopenharmony_ci#  CODE COVERAGE:
34f08c3bdfSopenharmony_ci#                 76.3% - fs/posix_acl.c
35f08c3bdfSopenharmony_ci#                 80.9% - xattr_acl.c
36f08c3bdfSopenharmony_ci#                 73.0% - xattr.c
37f08c3bdfSopenharmony_ci#
38f08c3bdfSopenharmony_ci##############################################################
39f08c3bdfSopenharmony_ci
40f08c3bdfSopenharmony_ciCUR_PATH=""
41f08c3bdfSopenharmony_ciCONTENT=""
42f08c3bdfSopenharmony_ciRES=""
43f08c3bdfSopenharmony_ciUSER_PERMISSION=""
44f08c3bdfSopenharmony_ciGROUP_PERMISSION=""
45f08c3bdfSopenharmony_ciOTHER_PERMISSION=""
46f08c3bdfSopenharmony_ciITEM_OWNER=""
47f08c3bdfSopenharmony_ciITEM_GROUP=""
48f08c3bdfSopenharmony_ci
49f08c3bdfSopenharmony_ci################################################################
50f08c3bdfSopenharmony_ci#
51f08c3bdfSopenharmony_ci# Make sure that uid=root is running this script.
52f08c3bdfSopenharmony_ci# Make sure that loop device is built into the kernel
53f08c3bdfSopenharmony_ci# Make sure that ACL(Access Control List) and Extended Attribute are
54f08c3bdfSopenharmony_ci#     built into the kernel
55f08c3bdfSopenharmony_ci#
56f08c3bdfSopenharmony_ci################################################################
57f08c3bdfSopenharmony_ci
58f08c3bdfSopenharmony_ciif [ $UID != 0 ]
59f08c3bdfSopenharmony_cithen
60f08c3bdfSopenharmony_ci	echo "FAILED: Must have root access to execute this script"
61f08c3bdfSopenharmony_ci	exit 1
62f08c3bdfSopenharmony_cifi
63f08c3bdfSopenharmony_ci
64f08c3bdfSopenharmony_ci#################################################################
65f08c3bdfSopenharmony_ci#
66f08c3bdfSopenharmony_ci# Prepare Ext2 file system for ACL and Extended Attribute test
67f08c3bdfSopenharmony_ci# Make some directory , file and symlink for the test
68f08c3bdfSopenharmony_ci# Add three users for the test
69f08c3bdfSopenharmony_ci#
70f08c3bdfSopenharmony_ci#################################################################
71f08c3bdfSopenharmony_ci
72f08c3bdfSopenharmony_ciif [ ! -e tacl ]
73f08c3bdfSopenharmony_cithen
74f08c3bdfSopenharmony_ci	mkdir -m 777 tacl
75f08c3bdfSopenharmony_cielse
76f08c3bdfSopenharmony_ci	echo "FAILED: Directory tacl are exist"
77f08c3bdfSopenharmony_ci	exit 1
78f08c3bdfSopenharmony_cifi
79f08c3bdfSopenharmony_ci
80f08c3bdfSopenharmony_cidd if=/dev/zero of=tacl/blkext2 bs=1k count=10240
81f08c3bdfSopenharmony_cichmod 777 tacl/blkext2
82f08c3bdfSopenharmony_ci
83f08c3bdfSopenharmony_cilosetup /dev/loop0 tacl/blkext2 >/dev/null 2>&1
84f08c3bdfSopenharmony_ciif [ $? != 0 ]
85f08c3bdfSopenharmony_cithen
86f08c3bdfSopenharmony_ci	printf "\nFAILED:  [ losetup ] Must have loop device support by kernel\n"
87f08c3bdfSopenharmony_ci	printf "\t to execute this script\n"
88f08c3bdfSopenharmony_ci	exit 1
89f08c3bdfSopenharmony_cifi
90f08c3bdfSopenharmony_ci
91f08c3bdfSopenharmony_cimount | grep ext2
92f08c3bdfSopenharmony_ciif [ $? != 0 ]
93f08c3bdfSopenharmony_cithen
94f08c3bdfSopenharmony_ci	mkfs -t ext3 /dev/loop0
95f08c3bdfSopenharmony_ci	mkdir  -m 777 tacl/mount-ext2
96f08c3bdfSopenharmony_ci	mount -t ext3 -o defaults,acl,user_xattr /dev/loop0 tacl/mount-ext2
97f08c3bdfSopenharmony_ci	if [ $? != 0 ]
98f08c3bdfSopenharmony_ci	then
99f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ mount ] Make sure that ACL (Access Control List)\n"
100f08c3bdfSopenharmony_ci		printf "\t and Extended Attribute are built into the kernel\n"
101f08c3bdfSopenharmony_ci		printf "\t Can not mount ext2 file system with acl and user_xattr options\n"
102f08c3bdfSopenharmony_ci		exit 1
103f08c3bdfSopenharmony_ci	fi
104f08c3bdfSopenharmony_ci
105f08c3bdfSopenharmony_cielse
106f08c3bdfSopenharmony_ci	mkfs -t ext2 /dev/loop0
107f08c3bdfSopenharmony_ci	mkdir  -m 777 tacl/mount-ext2
108f08c3bdfSopenharmony_ci	mount -t ext2 -o defaults,acl,user_xattr /dev/loop0 tacl/mount-ext2
109f08c3bdfSopenharmony_ci	if [ $? != 0 ]
110f08c3bdfSopenharmony_ci	then
111f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ mount ] Make sure that ACL (Access Control List)\n"
112f08c3bdfSopenharmony_ci		printf "\t and Extended Attribute are built into the kernel\n"
113f08c3bdfSopenharmony_ci		printf "\t Can not mount ext2 file system with acl and user_xattr options\n"
114f08c3bdfSopenharmony_ci		exit 1
115f08c3bdfSopenharmony_ci	fi
116f08c3bdfSopenharmony_cifi
117f08c3bdfSopenharmony_ci
118f08c3bdfSopenharmony_cichmod 777 tacl/mount-ext2
119f08c3bdfSopenharmony_ci
120f08c3bdfSopenharmony_ciuseradd -d `pwd`/tacl/tacluser1 tacluser1
121f08c3bdfSopenharmony_ciuseradd -d `pwd`/tacl/tacluser2 tacluser2
122f08c3bdfSopenharmony_ciuseradd -d `pwd`/tacl/tacluser3 tacluser3
123f08c3bdfSopenharmony_ciuseradd -d `pwd`/tacl/tacluser4 tacluser4
124f08c3bdfSopenharmony_ci
125f08c3bdfSopenharmony_ciif [ ! -e tacl/mount-ext2/shared ]
126f08c3bdfSopenharmony_cithen
127f08c3bdfSopenharmony_ci	mkdir -p -m 777 tacl/mount-ext2/shared
128f08c3bdfSopenharmony_cifi
129f08c3bdfSopenharmony_ci
130f08c3bdfSopenharmony_ciCUR_PATH=`pwd`
131f08c3bdfSopenharmony_ci
132f08c3bdfSopenharmony_cisu - tacluser1 << TACL_USER1
133f08c3bdfSopenharmony_ci
134f08c3bdfSopenharmony_ci	mkdir $CUR_PATH/tacl/mount-ext2/shared/team1
135f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/file1
136f08c3bdfSopenharmony_ci
137f08c3bdfSopenharmony_ci	cd $CUR_PATH/tacl/mount-ext2/shared/team1
138f08c3bdfSopenharmony_ci	ln -sf file1 symlinkfile1
139f08c3bdfSopenharmony_ci	cd $CUR_PATH
140f08c3bdfSopenharmony_ci
141f08c3bdfSopenharmony_ci	cd $CUR_PATH/tacl/mount-ext2/shared
142f08c3bdfSopenharmony_ci	ln -sf team1 symlinkdir1
143f08c3bdfSopenharmony_ci	cd $CUR_PATH
144f08c3bdfSopenharmony_ci
145f08c3bdfSopenharmony_ciTACL_USER1
146f08c3bdfSopenharmony_ci
147f08c3bdfSopenharmony_cisu - tacluser2 << TACL_USER2
148f08c3bdfSopenharmony_ci
149f08c3bdfSopenharmony_ci	mkdir $CUR_PATH/tacl/mount-ext2/shared/team2
150f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team2/file1
151f08c3bdfSopenharmony_ci
152f08c3bdfSopenharmony_ci	cd $CUR_PATH/tacl/mount-ext2/shared/team2
153f08c3bdfSopenharmony_ci	ln -sf file1 symlinkfile1
154f08c3bdfSopenharmony_ci	cd $CUR_PATH
155f08c3bdfSopenharmony_ci
156f08c3bdfSopenharmony_ci	cd $CUR_PATH/tacl/mount-ext2/shared
157f08c3bdfSopenharmony_ci	ln -sf team2 symlinkdir2
158f08c3bdfSopenharmony_ci	cd $CUR_PATH
159f08c3bdfSopenharmony_ci
160f08c3bdfSopenharmony_ciTACL_USER2
161f08c3bdfSopenharmony_ci
162f08c3bdfSopenharmony_ci#############################################################################################
163f08c3bdfSopenharmony_ci#
164f08c3bdfSopenharmony_ci#  The permissions bit limit user's act
165f08c3bdfSopenharmony_ci#  lrwxrwxrwx    1 tacluser1 tacluser1        5 Jun 23 13:39 symlinkdir1 -> team1
166f08c3bdfSopenharmony_ci#  lrwxrwxrwx    1 tacluser2 tacluser2        5 Jun 23 13:39 symlinkdir2 -> team2
167f08c3bdfSopenharmony_ci#  dr-x------    2 tacluser1 tacluser1     1024 Jun 23 13:39 team1
168f08c3bdfSopenharmony_ci#  drwxrwxr-x    2 tacluser2 tacluser2     1024 Jun 23 13:39 team2
169f08c3bdfSopenharmony_ci#
170f08c3bdfSopenharmony_ci#############################################################################################
171f08c3bdfSopenharmony_ci
172f08c3bdfSopenharmony_cichmod 500 tacl/mount-ext2/shared/team1
173f08c3bdfSopenharmony_ci
174f08c3bdfSopenharmony_cisu - tacluser1 << TACL_USER1
175f08c3bdfSopenharmony_ci
176f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfil1 2> /dev/null
177f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile1 ]
178f08c3bdfSopenharmony_ci	then
179f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] Create file must be denied by file permission bits\n"
180f08c3bdfSopenharmony_ci		printf "\t [ Physical Directory ]\n"
181f08c3bdfSopenharmony_ci	else
182f08c3bdfSopenharmony_ci		printf "\nSUCCESS: Create file denied by file permission bits [ Physical directory ]\n"
183f08c3bdfSopenharmony_ci	fi
184f08c3bdfSopenharmony_ci
185f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfil2 2> /dev/null
186f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile2 ]
187f08c3bdfSopenharmony_ci	then
188f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] Create file must be denied by file permission bits\n"
189f08c3bdfSopenharmony_ci		printf "\t [ Symlink Directory ]\n"
190f08c3bdfSopenharmony_ci	else
191f08c3bdfSopenharmony_ci		printf "\nSUCCESS: Create file denied by file permission bits [ Symlink directory ]\n"
192f08c3bdfSopenharmony_ci	fi
193f08c3bdfSopenharmony_ci
194f08c3bdfSopenharmony_ciTACL_USER1
195f08c3bdfSopenharmony_ci
196f08c3bdfSopenharmony_ci#################################################################
197f08c3bdfSopenharmony_ci#
198f08c3bdfSopenharmony_ci# ACL_USER_OBJ are a superset of the permissions specified
199f08c3bdfSopenharmony_ci#   by the file permission bits.
200f08c3bdfSopenharmony_ci# The effective user ID of the process matches the user ID of
201f08c3bdfSopenharmony_ci#   the file object owner.
202f08c3bdfSopenharmony_ci# Owner's act are based ACL_USER_OBJ
203f08c3bdfSopenharmony_ci#
204f08c3bdfSopenharmony_ci#################################################################
205f08c3bdfSopenharmony_ci
206f08c3bdfSopenharmony_cisetfacl -m u::rx tacl/mount-ext2/shared/team1
207f08c3bdfSopenharmony_cisu - tacluser1 << TACL_USER1
208f08c3bdfSopenharmony_ci
209f08c3bdfSopenharmony_ci	cd $CUR_PATH/tacl/mount-ext2/shared/team1/ 2> /dev/null
210f08c3bdfSopenharmony_ci	if [ $? != 0 ]
211f08c3bdfSopenharmony_ci	then
212f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner execute\n"
213f08c3bdfSopenharmony_ci		printf "\t permissions, but operation failed [ Physical Directory ]\n"
214f08c3bdfSopenharmony_ci	else
215f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,\n"
216f08c3bdfSopenharmony_ci		printf "\t operation success [ Physical Directory ]\n"
217f08c3bdfSopenharmony_ci	fi
218f08c3bdfSopenharmony_ci
219f08c3bdfSopenharmony_ci	cd $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/ 2> /dev/null
220f08c3bdfSopenharmony_ci	if [ $? != 0 ]
221f08c3bdfSopenharmony_ci	then
222f08c3bdfSopenharmony_ci		printf "\nFAILED: [ touch ] ACL_USER_OBJ  entry already contains the owner execute\n"
223f08c3bdfSopenharmony_ci		printf "\t permissions, but operation failed [ Symlink Directory ]\n"
224f08c3bdfSopenharmony_ci	else
225f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,\n"
226f08c3bdfSopenharmony_ci		printf "\t operation success [ Symlink Directory ]\n"
227f08c3bdfSopenharmony_ci	fi
228f08c3bdfSopenharmony_ci
229f08c3bdfSopenharmony_ciTACL_USER1
230f08c3bdfSopenharmony_ci
231f08c3bdfSopenharmony_cisetfacl -m u::rwx tacl/mount-ext2/shared/team1
232f08c3bdfSopenharmony_ci
233f08c3bdfSopenharmony_cisu - tacluser1 << TACL_USER1
234f08c3bdfSopenharmony_ci
235f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfil1 2> /dev/null
236f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile1 ]
237f08c3bdfSopenharmony_ci	then
238f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write \n"
239f08c3bdfSopenharmony_ci		printf "\t permissions, but operation failed [ Physical Directory ]\n"
240f08c3bdfSopenharmony_ci	else
241f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,\n"
242f08c3bdfSopenharmony_ci		printf "\t operation success [ Physical Directory ]\n"
243f08c3bdfSopenharmony_ci	fi
244f08c3bdfSopenharmony_ci
245f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfil2 2> /dev/null
246f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile2 ]
247f08c3bdfSopenharmony_ci	then
248f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write \n"
249f08c3bdfSopenharmony_ci		printf "\t permissions, but operation failed [ Symlink Directory ]\n"
250f08c3bdfSopenharmony_ci	else
251f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,\n"
252f08c3bdfSopenharmony_ci		printf "\t operation success [ Symlink Directory ]\n"
253f08c3bdfSopenharmony_ci	fi
254f08c3bdfSopenharmony_ci
255f08c3bdfSopenharmony_ciTACL_USER1
256f08c3bdfSopenharmony_ci
257f08c3bdfSopenharmony_ci#################################################################
258f08c3bdfSopenharmony_ci#
259f08c3bdfSopenharmony_ci# The effective user ID of the process matches the qualifier of
260f08c3bdfSopenharmony_ci#   any entry of type ACL_USER
261f08c3bdfSopenharmony_ci# IF  the  matching  ACL_USER entry and the ACL_MASK
262f08c3bdfSopenharmony_ci#   entry contain the requested permissions,#  access is granted,
263f08c3bdfSopenharmony_ci#  ELSE access is denied.
264f08c3bdfSopenharmony_ci#
265f08c3bdfSopenharmony_ci#################################################################
266f08c3bdfSopenharmony_ci
267f08c3bdfSopenharmony_cisetfacl -m u:tacluser3:rwx tacl/mount-ext2/shared/team1
268f08c3bdfSopenharmony_ci
269f08c3bdfSopenharmony_cisu - tacluser3 << TACL_USER3
270f08c3bdfSopenharmony_ci
271f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3 2> /dev/null
272f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3 ]
273f08c3bdfSopenharmony_ci	then
274f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
275f08c3bdfSopenharmony_ci		printf "\t operation success [ Physical Directory ]\n"
276f08c3bdfSopenharmony_ci	else
277f08c3bdfSopenharmony_ci		printf "\nFAILED:  ACL_USER entry contains the user permissions,\n"
278f08c3bdfSopenharmony_ci		printf "\t but operation denied [ Physical Directory ]\n"
279f08c3bdfSopenharmony_ci	fi
280f08c3bdfSopenharmony_ci
281f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile4 2> /dev/null
282f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile4 ]
283f08c3bdfSopenharmony_ci	then
284f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
285f08c3bdfSopenharmony_ci		printf "\t operation success [ Symlink Directory ]\n"
286f08c3bdfSopenharmony_ci	else
287f08c3bdfSopenharmony_ci		printf "\nFAILED:  ACL_USER entry contains the user permissions,\n"
288f08c3bdfSopenharmony_ci		printf "\t but operation denied [ Symlink Directory ]\n"
289f08c3bdfSopenharmony_ci	fi
290f08c3bdfSopenharmony_ci
291f08c3bdfSopenharmony_ciTACL_USER3
292f08c3bdfSopenharmony_ci
293f08c3bdfSopenharmony_cisetfacl -m mask:--- tacl/mount-ext2/shared/team1
294f08c3bdfSopenharmony_ci
295f08c3bdfSopenharmony_cisu - tacluser3 << TACL_USER3
296f08c3bdfSopenharmony_ci
297f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile5 2> /dev/null
298f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile5 ]
299f08c3bdfSopenharmony_ci	then
300f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_USER entry contains the user permissions\n"
301f08c3bdfSopenharmony_ci		printf "\t but ACL_MASK are set --- ,\n"
302f08c3bdfSopenharmony_ci		printf "\t operation must be denied [ Physical Directory ]\n"
303f08c3bdfSopenharmony_ci	else
304f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
305f08c3bdfSopenharmony_ci		printf "\t but ACL_MASK are set ___ ,\n"
306f08c3bdfSopenharmony_ci		printf "\t operation success [ Physical Directory ]\n"
307f08c3bdfSopenharmony_ci	fi
308f08c3bdfSopenharmony_ci
309f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile6 2> /dev/null
310f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile6 ]
311f08c3bdfSopenharmony_ci	then
312f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_USER entry contains the user permissions\n"
313f08c3bdfSopenharmony_ci		printf "\t but ACL_MASK are set --- ,\n"
314f08c3bdfSopenharmony_ci		printf "\t operation must be denied [ Symlink Directory ]\n"
315f08c3bdfSopenharmony_ci	else
316f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
317f08c3bdfSopenharmony_ci		printf "\t but ACL_MASK are set ___ ,\n"
318f08c3bdfSopenharmony_ci		printf "\t operation success [ Symlink Directory ]\n"
319f08c3bdfSopenharmony_ci	fi
320f08c3bdfSopenharmony_ci
321f08c3bdfSopenharmony_ciTACL_USER3
322f08c3bdfSopenharmony_ci
323f08c3bdfSopenharmony_ci###########################################################################################
324f08c3bdfSopenharmony_ci#
325f08c3bdfSopenharmony_ci# The effective group ID or any of the supplementary group IDs of the process match the
326f08c3bdfSopenharmony_ci#  qualifier of the entry of type ACL_GROUP_OBJ, or the qualifier of any entry of type
327f08c3bdfSopenharmony_ci#  ACL_GROUP
328f08c3bdfSopenharmony_ci#
329f08c3bdfSopenharmony_ci# IF the ACL contains an ACL_MASK entry, THEN
330f08c3bdfSopenharmony_ci#                 if  the ACL_MASK entry and any of the matching ACL_GROUP_OBJ
331f08c3bdfSopenharmony_ci#                 or ACL_GROUP  entries  contain  the  requested  permissions,
332f08c3bdfSopenharmony_ci#                 access is granted,
333f08c3bdfSopenharmony_ci#
334f08c3bdfSopenharmony_ci#                 else access is denied.
335f08c3bdfSopenharmony_ci#
336f08c3bdfSopenharmony_ci# ELSE  (note  that  there  can be no ACL_GROUP entries without an ACL_MASK entry)
337f08c3bdfSopenharmony_ci#                 if the ACL_GROUP_OBJ entry contains  the  requested  permis-
338f08c3bdfSopenharmony_ci#                 sions, access is granted,
339f08c3bdfSopenharmony_ci#
340f08c3bdfSopenharmony_ci#                 else access is denied.
341f08c3bdfSopenharmony_ci#
342f08c3bdfSopenharmony_ci###########################################################################################
343f08c3bdfSopenharmony_ci
344f08c3bdfSopenharmony_cisetfacl -m g:tacluser2:rwx tacl/mount-ext2/shared/team1
345f08c3bdfSopenharmony_ci
346f08c3bdfSopenharmony_cisu - tacluser2 << TACL_USER2
347f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile7 2> /dev/null
348f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile7 ]
349f08c3bdfSopenharmony_ci	then
350f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP entry contains the group permissions,\n"
351f08c3bdfSopenharmony_ci		printf "\t option success [ Physical Directory ]\n"
352f08c3bdfSopenharmony_ci	else
353f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,\n"
354f08c3bdfSopenharmony_ci		printf "\t but option success [ Physical Directory ]\n"
355f08c3bdfSopenharmony_ci	fi
356f08c3bdfSopenharmony_ci
357f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile8 2> /dev/null
358f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile8 ]
359f08c3bdfSopenharmony_ci	then
360f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP entry contains the group permissions,\n"
361f08c3bdfSopenharmony_ci		printf "\t option success [ Symlink Directory ]\n"
362f08c3bdfSopenharmony_ci	else
363f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,\n"
364f08c3bdfSopenharmony_ci		printf "\t but option success [ Symlink Directory ]\n"
365f08c3bdfSopenharmony_ci	fi
366f08c3bdfSopenharmony_ci
367f08c3bdfSopenharmony_ciTACL_USER2
368f08c3bdfSopenharmony_ci
369f08c3bdfSopenharmony_cisetfacl -m mask:--- tacl/mount-ext2/shared/team1
370f08c3bdfSopenharmony_ci
371f08c3bdfSopenharmony_cisu - tacluser2 << TACL_USER2
372f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile9 2> /dev/null
373f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile9 ]
374f08c3bdfSopenharmony_ci	then
375f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP entry contains the group permissions\n"
376f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
377f08c3bdfSopenharmony_ci		printf "\t option must no be success [ Physical Directory ]\n"
378f08c3bdfSopenharmony_ci	else
379f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP entry already contains the group permissions\n"
380f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
381f08c3bdfSopenharmony_ci		printf "\t option success [ Physical Directory ]\n"
382f08c3bdfSopenharmony_ci	fi
383f08c3bdfSopenharmony_ci
384f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile10 2> /dev/null
385f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile10 ]
386f08c3bdfSopenharmony_ci	then
387f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP entry contains the group permissions\n"
388f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
389f08c3bdfSopenharmony_ci		printf "\t option must no be success [ Symlink Directory ]\n"
390f08c3bdfSopenharmony_ci	else
391f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP entry already contains the group permissions\n"
392f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
393f08c3bdfSopenharmony_ci		printf "\t option success [ Symlink Directory ]\n"
394f08c3bdfSopenharmony_ci	fi
395f08c3bdfSopenharmony_ci
396f08c3bdfSopenharmony_ciTACL_USER2
397f08c3bdfSopenharmony_ci
398f08c3bdfSopenharmony_cisetfacl -m g::rwx tacl/mount-ext2/shared/team1
399f08c3bdfSopenharmony_ciusermod -g tacluser1 tacluser2
400f08c3bdfSopenharmony_ci
401f08c3bdfSopenharmony_cisu - tacluser2 << TACL_USER2
402f08c3bdfSopenharmony_ci
403f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile11 2> /dev/null
404f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile11 ]
405f08c3bdfSopenharmony_ci	then
406f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,\n"
407f08c3bdfSopenharmony_ci		printf "\t option success [ Physical Directory ]\n"
408f08c3bdfSopenharmony_ci	else
409f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,\n"
410f08c3bdfSopenharmony_ci		printf "\t but option denied [ Physical Directory ]\n"
411f08c3bdfSopenharmony_ci	fi
412f08c3bdfSopenharmony_ci
413f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile12 2> /dev/null
414f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile12 ]
415f08c3bdfSopenharmony_ci	then
416f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,\n"
417f08c3bdfSopenharmony_ci		printf "\t option success [ Symlink Directory ]\n"
418f08c3bdfSopenharmony_ci	else
419f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,\n"
420f08c3bdfSopenharmony_ci		printf "\t but option denied [ Symlink Directory ]\n"
421f08c3bdfSopenharmony_ci	fi
422f08c3bdfSopenharmony_ci
423f08c3bdfSopenharmony_ciTACL_USER2
424f08c3bdfSopenharmony_ci
425f08c3bdfSopenharmony_cisetfacl -m mask:--- tacl/mount-ext2/shared/team1
426f08c3bdfSopenharmony_ci
427f08c3bdfSopenharmony_cisu - tacluser2 << TACL_USER2
428f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile13 2> /dev/null
429f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile13 ]
430f08c3bdfSopenharmony_ci	then
431f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions\n"
432f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
433f08c3bdfSopenharmony_ci		printf "\t option must no be success [ Physical Directory ]\n"
434f08c3bdfSopenharmony_ci	else
435f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions\n"
436f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
437f08c3bdfSopenharmony_ci		printf "\t option success [ Physical Directory ]\n"
438f08c3bdfSopenharmony_ci	fi
439f08c3bdfSopenharmony_ci
440f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile14 2> /dev/null
441f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile14 ]
442f08c3bdfSopenharmony_ci	then
443f08c3bdfSopenharmony_ci		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions\n"
444f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
445f08c3bdfSopenharmony_ci		printf "\t option must no be success [ Symlink Directory ]\n"
446f08c3bdfSopenharmony_ci	else
447f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions\n"
448f08c3bdfSopenharmony_ci		printf "\t and ACL_MASK entry are set ---,\n"
449f08c3bdfSopenharmony_ci		printf "\t option success [ Symlink Directory ]\n"
450f08c3bdfSopenharmony_ci	fi
451f08c3bdfSopenharmony_ci
452f08c3bdfSopenharmony_ciTACL_USER2
453f08c3bdfSopenharmony_ci
454f08c3bdfSopenharmony_ciusermod -g tacluser2 tacluser2
455f08c3bdfSopenharmony_ci
456f08c3bdfSopenharmony_ci###################################################################################
457f08c3bdfSopenharmony_ci#
458f08c3bdfSopenharmony_ci# IF the ACL_OTHER entry contains the requested permissions, access is granted
459f08c3bdfSopenharmony_ci#
460f08c3bdfSopenharmony_ci###################################################################################
461f08c3bdfSopenharmony_ci
462f08c3bdfSopenharmony_cisetfacl -m o::rwx tacl/mount-ext2/shared/team1
463f08c3bdfSopenharmony_ci
464f08c3bdfSopenharmony_cisu - tacluser4 << TACL_USER4
465f08c3bdfSopenharmony_ci
466f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile15 2> /dev/null
467f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile15 ]
468f08c3bdfSopenharmony_ci	then
469f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_OTHER entry contains the user permissions,\n"
470f08c3bdfSopenharmony_ci		printf "\t operation success [ Physical Directory ]\n"
471f08c3bdfSopenharmony_ci	else
472f08c3bdfSopenharmony_ci		printf "\nFAILED:  ACL_OTHER entry contains the user permissions,\n"
473f08c3bdfSopenharmony_ci		printf "\t but operation denied [ Physical Directory ]\n"
474f08c3bdfSopenharmony_ci	fi
475f08c3bdfSopenharmony_ci
476f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile16 2> /dev/null
477f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile16 ]
478f08c3bdfSopenharmony_ci	then
479f08c3bdfSopenharmony_ci		printf "\nSUCCESS: ACL_OTHER entry contains the user permissions,\n"
480f08c3bdfSopenharmony_ci		printf "\t operation success [ Symlink Directory ]\n"
481f08c3bdfSopenharmony_ci	else
482f08c3bdfSopenharmony_ci		printf "\nFAILED:  ACL_OTHER entry contains the user permissions,\n"
483f08c3bdfSopenharmony_ci		printf "\t but operation denied [ Symlink Directory ]\n"
484f08c3bdfSopenharmony_ci	fi
485f08c3bdfSopenharmony_ci
486f08c3bdfSopenharmony_ciTACL_USER4
487f08c3bdfSopenharmony_ci
488f08c3bdfSopenharmony_cisetfacl -m mask:--- tacl/mount-ext2/shared/team1
489f08c3bdfSopenharmony_ci
490f08c3bdfSopenharmony_cisu - tacluser4 << TACL_USER4
491f08c3bdfSopenharmony_ci
492f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile17 2> /dev/null
493f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile17 ]
494f08c3bdfSopenharmony_ci	then
495f08c3bdfSopenharmony_ci		printf "\nSUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]\n"
496f08c3bdfSopenharmony_ci	else
497f08c3bdfSopenharmony_ci		printf "\nFAILED:  ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]\n"
498f08c3bdfSopenharmony_ci	fi
499f08c3bdfSopenharmony_ci
500f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile18 2> /dev/null
501f08c3bdfSopenharmony_ci	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile18 ]
502f08c3bdfSopenharmony_ci	then
503f08c3bdfSopenharmony_ci		printf "\nSUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]\n"
504f08c3bdfSopenharmony_ci	else
505f08c3bdfSopenharmony_ci		printf "\nFAILED:  ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]\n"
506f08c3bdfSopenharmony_ci	fi
507f08c3bdfSopenharmony_ci
508f08c3bdfSopenharmony_ciTACL_USER4
509f08c3bdfSopenharmony_ci
510f08c3bdfSopenharmony_ci############################################################################
511f08c3bdfSopenharmony_ci#
512f08c3bdfSopenharmony_ci# OBJECT CREATION AND DEFAULT ACLs
513f08c3bdfSopenharmony_ci# The new object inherits the default ACL of the containing directory as its access ACL.
514f08c3bdfSopenharmony_ci#
515f08c3bdfSopenharmony_ci############################################################################
516f08c3bdfSopenharmony_ci
517f08c3bdfSopenharmony_cirm -f tacl/mount-ext2/shared/team1/newfil*
518f08c3bdfSopenharmony_ci
519f08c3bdfSopenharmony_ci#
520f08c3bdfSopenharmony_ci# Test ACL_USER_OBJ default ACLs
521f08c3bdfSopenharmony_ci#
522f08c3bdfSopenharmony_cisetfacl -m d:u::r -m d:g::r -m d:o::r tacl/mount-ext2/shared/team1
523f08c3bdfSopenharmony_ci
524f08c3bdfSopenharmony_cisu - tacluser1 << TACL_USER1
525f08c3bdfSopenharmony_ci
526f08c3bdfSopenharmony_ci	MASK=`umask`
527f08c3bdfSopenharmony_ci	umask 0
528f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile1
529f08c3bdfSopenharmony_ci	umask $MASK > /dev/null
530f08c3bdfSopenharmony_ci
531f08c3bdfSopenharmony_ciTACL_USER1
532f08c3bdfSopenharmony_ci
533f08c3bdfSopenharmony_ciCONTENT=""
534f08c3bdfSopenharmony_ciCONTENT=`ls -l tacl/mount-ext2/shared/team1/newfile1`
535f08c3bdfSopenharmony_ciRES=`echo $CONTENT | grep ".r--r--r--" | awk '{print $1}'`
536f08c3bdfSopenharmony_ci
537f08c3bdfSopenharmony_ciif [ $RES != "" ]
538f08c3bdfSopenharmony_cithen
539f08c3bdfSopenharmony_ci	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
540f08c3bdfSopenharmony_cielse
541f08c3bdfSopenharmony_ci	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
542f08c3bdfSopenharmony_cifi
543f08c3bdfSopenharmony_ci
544f08c3bdfSopenharmony_ci
545f08c3bdfSopenharmony_ci
546f08c3bdfSopenharmony_ci#
547f08c3bdfSopenharmony_ci# Test ACL_USER and ACL_GROUP defaults ACLs
548f08c3bdfSopenharmony_ci#
549f08c3bdfSopenharmony_cisetfacl -m d:u:tacluser3:rw -m d:g:tacluser3:rw tacl/mount-ext2/shared/team1
550f08c3bdfSopenharmony_cisu - tacluser3 << TACL_USER3
551f08c3bdfSopenharmony_ci
552f08c3bdfSopenharmony_ci	MASK=`umask`
553f08c3bdfSopenharmony_ci	umask 0
554f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile2
555f08c3bdfSopenharmony_ci	umask $MASK > /dev/null
556f08c3bdfSopenharmony_ci
557f08c3bdfSopenharmony_ciTACL_USER3
558f08c3bdfSopenharmony_ci
559f08c3bdfSopenharmony_ciCONTENT=""
560f08c3bdfSopenharmony_ciCONTENT=`ls -l tacl/mount-ext2/shared/team1/newfile2`
561f08c3bdfSopenharmony_ciRES=`echo $CONTENT | grep ".r--rw-r--" | awk '{print $1}'`
562f08c3bdfSopenharmony_ci
563f08c3bdfSopenharmony_ciif [ $RES != "" ]
564f08c3bdfSopenharmony_cithen
565f08c3bdfSopenharmony_ci	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
566f08c3bdfSopenharmony_cielse
567f08c3bdfSopenharmony_ci	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
568f08c3bdfSopenharmony_cifi
569f08c3bdfSopenharmony_ci
570f08c3bdfSopenharmony_ci#
571f08c3bdfSopenharmony_ci# Test ACL_GROUP default ACLs
572f08c3bdfSopenharmony_ci#
573f08c3bdfSopenharmony_ci
574f08c3bdfSopenharmony_cisetfacl -m d:u::rwx -m d:g::rwx -m d:o::rwx tacl/mount-ext2/shared/team1
575f08c3bdfSopenharmony_cisu - tacluser3 << TACL_USER3
576f08c3bdfSopenharmony_ci
577f08c3bdfSopenharmony_ci	MASK=`umask`
578f08c3bdfSopenharmony_ci	umask 0
579f08c3bdfSopenharmony_ci	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3
580f08c3bdfSopenharmony_ci	umask $MASK > /dev/null
581f08c3bdfSopenharmony_ci
582f08c3bdfSopenharmony_ciTACL_USER3
583f08c3bdfSopenharmony_ci
584f08c3bdfSopenharmony_ciCONTENT=""
585f08c3bdfSopenharmony_ciCONTENT=`ls -l tacl/mount-ext2/shared/team1/newfile3`
586f08c3bdfSopenharmony_ciRES=`echo $CONTENT | grep ".rw-rw-rw-" | awk '{print \$1}'`
587f08c3bdfSopenharmony_ci
588f08c3bdfSopenharmony_ciif [ $RES != "" ]
589f08c3bdfSopenharmony_cithen
590f08c3bdfSopenharmony_ci	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
591f08c3bdfSopenharmony_cielse
592f08c3bdfSopenharmony_ci	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
593f08c3bdfSopenharmony_cifi
594f08c3bdfSopenharmony_ci
595f08c3bdfSopenharmony_ci
596f08c3bdfSopenharmony_ci#################################################################################
597f08c3bdfSopenharmony_ci#
598f08c3bdfSopenharmony_ci# Chmod also change ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER permissions
599f08c3bdfSopenharmony_ci#
600f08c3bdfSopenharmony_ci#################################################################################
601f08c3bdfSopenharmony_cisu - tacluser3 << TACL_USER3
602f08c3bdfSopenharmony_ci	MASK=`umask`
603f08c3bdfSopenharmony_ci	umask 0
604f08c3bdfSopenharmony_ci
605f08c3bdfSopenharmony_ci	chmod 777 $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3
606f08c3bdfSopenharmony_ci	umask $MASK > /dev/null
607f08c3bdfSopenharmony_ciTACL_USER3
608f08c3bdfSopenharmony_ci
609f08c3bdfSopenharmony_ciCONTENT=""
610f08c3bdfSopenharmony_ciCONTENT=`getfacl tacl/mount-ext2/shared/team1/newfile3`
611f08c3bdfSopenharmony_ci
612f08c3bdfSopenharmony_ciUSER_PERMISSION=`echo $CONTENT | awk '{print \$10}'`
613f08c3bdfSopenharmony_ci
614f08c3bdfSopenharmony_ciGROUP_PERMISSION=`echo $CONTENT | awk '{print \$12}'`
615f08c3bdfSopenharmony_ciOTHER_PERMISSION=`echo $CONTENT | awk '{print \$15}'`
616f08c3bdfSopenharmony_ci
617f08c3bdfSopenharmony_ciif [ $USER_PERMISSION = "user::rwx" ]
618f08c3bdfSopenharmony_cithen
619f08c3bdfSopenharmony_ci	if [ $GROUP_PERMISSION = "group::rwx" ]
620f08c3bdfSopenharmony_ci	then
621f08c3bdfSopenharmony_ci		if [ $OTHER_PERMISSION = "other::rwx" ]
622f08c3bdfSopenharmony_ci		then
623f08c3bdfSopenharmony_ci			printf "\nSUCCESS: Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are correct\n"
624f08c3bdfSopenharmony_ci		else
625f08c3bdfSopenharmony_ci			printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
626f08c3bdfSopenharmony_ci		fi
627f08c3bdfSopenharmony_ci	else
628f08c3bdfSopenharmony_ci		printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
629f08c3bdfSopenharmony_ci	fi
630f08c3bdfSopenharmony_cielse
631f08c3bdfSopenharmony_ci	printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
632f08c3bdfSopenharmony_cifi
633f08c3bdfSopenharmony_ci
634f08c3bdfSopenharmony_ci
635f08c3bdfSopenharmony_ci#####################################################################################
636f08c3bdfSopenharmony_ci#
637f08c3bdfSopenharmony_ci# Chown only change object owner and group
638f08c3bdfSopenharmony_ci#
639f08c3bdfSopenharmony_ci#####################################################################################
640f08c3bdfSopenharmony_ci
641f08c3bdfSopenharmony_cichown tacluser2.tacluser2 tacl/mount-ext2/shared/team1/newfile2
642f08c3bdfSopenharmony_ciCONTENT=""
643f08c3bdfSopenharmony_ciCONTENT=`getfacl tacl/mount-ext2/shared/team1/newfile2`
644f08c3bdfSopenharmony_ci
645f08c3bdfSopenharmony_ciITEM_OWNER=`echo $CONTENT | awk '{print \$6}'`
646f08c3bdfSopenharmony_ciITEM_GROUP=`echo $CONTENT | awk '{print \$9}'`
647f08c3bdfSopenharmony_ci
648f08c3bdfSopenharmony_ciif [ $ITEM_OWNER = "tacluser2" ]
649f08c3bdfSopenharmony_cithen
650f08c3bdfSopenharmony_ci	if [ $ITEM_GROUP = "tacluser2" ]
651f08c3bdfSopenharmony_ci	then
652f08c3bdfSopenharmony_ci		printf "\nSUCCESS: Chown correct\n"
653f08c3bdfSopenharmony_ci	else
654f08c3bdfSopenharmony_ci		printf "\nFAILED:  Chown are not correct\n"
655f08c3bdfSopenharmony_ci	fi
656f08c3bdfSopenharmony_cielse
657f08c3bdfSopenharmony_ci	echo "FAILED:  Chown are not correct"
658f08c3bdfSopenharmony_cifi
659f08c3bdfSopenharmony_ci
660f08c3bdfSopenharmony_ci#####################################################
661f08c3bdfSopenharmony_ci#
662f08c3bdfSopenharmony_ci# Test ACLs backup and restore
663f08c3bdfSopenharmony_ci#
664f08c3bdfSopenharmony_ci#####################################################
665f08c3bdfSopenharmony_ci
666f08c3bdfSopenharmony_cigetfacl -RL tacl/mount-ext2/ > tacl/tmp1
667f08c3bdfSopenharmony_cisetfacl -m u::--- -m g::--- -m o::--- tacl/mount-ext2/shared/team1
668f08c3bdfSopenharmony_cisetfacl --restore tacl/tmp1
669f08c3bdfSopenharmony_cigetfacl -RL tacl/mount-ext2/ > tacl/tmp2
670f08c3bdfSopenharmony_ci
671f08c3bdfSopenharmony_ciif [ `diff tacl/tmp1 tacl/tmp2` ]
672f08c3bdfSopenharmony_cithen
673f08c3bdfSopenharmony_ci	printf "\nFAILED:  ACLs backup and restore are not correct\n"
674f08c3bdfSopenharmony_cielse
675f08c3bdfSopenharmony_ci	printf "\nSUCCESS: ACLs backup and restore are correct\n"
676f08c3bdfSopenharmony_cifi
677f08c3bdfSopenharmony_ci
678f08c3bdfSopenharmony_ciprintf "\n\tEnd ACLs Test\n"
679f08c3bdfSopenharmony_ci
680f08c3bdfSopenharmony_ci#####################################################
681f08c3bdfSopenharmony_ci#
682f08c3bdfSopenharmony_ci# Now begin Extend Attribute test
683f08c3bdfSopenharmony_ci#
684f08c3bdfSopenharmony_ci#####################################################
685f08c3bdfSopenharmony_ci
686f08c3bdfSopenharmony_ciprintf "\nNow begin Extend Attribute Test\n"
687f08c3bdfSopenharmony_ci
688f08c3bdfSopenharmony_ci# dir
689f08c3bdfSopenharmony_ciprintf "\nAttach name:value pair to object dir\n\n"
690f08c3bdfSopenharmony_ciattr -s attrname1 -V attrvalue1 tacl/mount-ext2/shared/team2
691f08c3bdfSopenharmony_ciif [ $? != 0 ]
692f08c3bdfSopenharmony_cithen
693f08c3bdfSopenharmony_ci	echo "FAILED: Attach name:value pair to object dir"
694f08c3bdfSopenharmony_cifi
695f08c3bdfSopenharmony_ci
696f08c3bdfSopenharmony_ci#file
697f08c3bdfSopenharmony_ciecho
698f08c3bdfSopenharmony_ciecho "Attach name:value pair to object file "
699f08c3bdfSopenharmony_ciecho ""
700f08c3bdfSopenharmony_ciattr -s attrname2 -V attrvalue2 tacl/mount-ext2/shared/team2/file1
701f08c3bdfSopenharmony_ciif [ $? != 0 ]
702f08c3bdfSopenharmony_cithen
703f08c3bdfSopenharmony_ci	echo "FAILED: Attach name:value pair to object file"
704f08c3bdfSopenharmony_cifi
705f08c3bdfSopenharmony_ci
706f08c3bdfSopenharmony_ci#symlink file
707f08c3bdfSopenharmony_ciecho
708f08c3bdfSopenharmony_ciecho "Attach name:value pair to object symlink file"
709f08c3bdfSopenharmony_ciecho ""
710f08c3bdfSopenharmony_ciattr -s attrname3 -V attrvalue3 tacl/mount-ext2/shared/team2/symlinkfile1
711f08c3bdfSopenharmony_ciif [ $? != 0 ]
712f08c3bdfSopenharmony_cithen
713f08c3bdfSopenharmony_ci	echo "INFO: Can't attach name:value pair to object symlink file"
714f08c3bdfSopenharmony_cifi
715f08c3bdfSopenharmony_ci
716f08c3bdfSopenharmony_ciecho ""
717f08c3bdfSopenharmony_cils -lRt tacl/mount-ext2/shared/team2
718f08c3bdfSopenharmony_ci
719f08c3bdfSopenharmony_ciecho
720f08c3bdfSopenharmony_ciecho "get extended attributes of filesystem objects"
721f08c3bdfSopenharmony_ciecho ""
722f08c3bdfSopenharmony_ci
723f08c3bdfSopenharmony_ciecho "Dump the values"
724f08c3bdfSopenharmony_cigetfattr -d tacl/mount-ext2/shared/team2
725f08c3bdfSopenharmony_ciif [ $? != 0 ]
726f08c3bdfSopenharmony_cithen
727f08c3bdfSopenharmony_ci	echo "FAILED: getfattr: Dump the values"
728f08c3bdfSopenharmony_cifi
729f08c3bdfSopenharmony_ci
730f08c3bdfSopenharmony_ciecho "Recursively dump the values"
731f08c3bdfSopenharmony_cigetfattr -dR tacl/mount-ext2/*
732f08c3bdfSopenharmony_ciif [ $? != 0 ]
733f08c3bdfSopenharmony_cithen
734f08c3bdfSopenharmony_ci	echo "FAILED: getfattr: Recursively Dump the values"
735f08c3bdfSopenharmony_cifi
736f08c3bdfSopenharmony_ci
737f08c3bdfSopenharmony_ciecho "Do not follow symlinks."
738f08c3bdfSopenharmony_ciecho "but extended user attributes are disallowed for symbolic links"
739f08c3bdfSopenharmony_cigetfattr -h --no-dereference tacl/mount-ext2/shared/team2/symlinkfile1
740f08c3bdfSopenharmony_ciif [ $? != 0 ]
741f08c3bdfSopenharmony_cithen
742f08c3bdfSopenharmony_ci        echo "FAILED: getfattr: Do not follow symlinks."
743f08c3bdfSopenharmony_cifi
744f08c3bdfSopenharmony_ciecho
745f08c3bdfSopenharmony_ci
746f08c3bdfSopenharmony_ciecho "Logical walk, follow symbolic links"
747f08c3bdfSopenharmony_cigetfattr -L tacl/mount-ext2/shared/team2/*
748f08c3bdfSopenharmony_ciif [ $? != 0 ]
749f08c3bdfSopenharmony_cithen
750f08c3bdfSopenharmony_ci	echo "FAILED: getfattr: Logical walk"
751f08c3bdfSopenharmony_cifi
752f08c3bdfSopenharmony_ci
753f08c3bdfSopenharmony_ciecho "Physical walk, skip all symbolic links"
754f08c3bdfSopenharmony_cigetfattr -P tacl/mount-ext2/shared/team2/*
755f08c3bdfSopenharmony_ciif [ $? != 0 ]
756f08c3bdfSopenharmony_cithen
757f08c3bdfSopenharmony_ci	echo "FAILED: getfattr: Physical walk"
758f08c3bdfSopenharmony_cifi
759f08c3bdfSopenharmony_ci
760f08c3bdfSopenharmony_ciecho "attr -g to search the named object"
761f08c3bdfSopenharmony_ciattr -g attrname1 tacl/mount-ext2/shared/team2
762f08c3bdfSopenharmony_ciif [ $? != 0 ]
763f08c3bdfSopenharmony_cithen
764f08c3bdfSopenharmony_ci	echo "FAILED: attr: to search the named object"
765f08c3bdfSopenharmony_cifi
766f08c3bdfSopenharmony_ciecho
767f08c3bdfSopenharmony_ci
768f08c3bdfSopenharmony_ciecho "attr -r to remove the named object"
769f08c3bdfSopenharmony_ciattr -r attrname2 tacl/mount-ext2/shared/team2/file1
770f08c3bdfSopenharmony_ciif [ $? != 0 ]
771f08c3bdfSopenharmony_cithen
772f08c3bdfSopenharmony_ci	echo "FAILED: attr: to remove the named object"
773f08c3bdfSopenharmony_cifi
774f08c3bdfSopenharmony_ci
775f08c3bdfSopenharmony_ci
776f08c3bdfSopenharmony_ci#################################
777f08c3bdfSopenharmony_ci#
778f08c3bdfSopenharmony_ci# Backup and Restore
779f08c3bdfSopenharmony_ci#
780f08c3bdfSopenharmony_ci#################################
781f08c3bdfSopenharmony_cigetfattr -dhR -m- -e hex tacl/mount-ext2 > tacl/backup.ea
782f08c3bdfSopenharmony_cisetfattr -h --restore=tacl/backup.ea
783f08c3bdfSopenharmony_ci
784f08c3bdfSopenharmony_cigetfattr -dhR -m- -e hex tacl/mount-ext2 > tacl/backup.ea1
785f08c3bdfSopenharmony_ciif [ `diff  tacl/backup.ea1  tacl/backup.ea` ]
786f08c3bdfSopenharmony_cithen
787f08c3bdfSopenharmony_ci        printf "\nFAILED:  EAs backup and restore are not correct\n"
788f08c3bdfSopenharmony_cielse
789f08c3bdfSopenharmony_ci        printf "\nSUCCESS: EAs backup and restore are correct\n"
790f08c3bdfSopenharmony_cifi
791f08c3bdfSopenharmony_ci
792f08c3bdfSopenharmony_ciprintf "\n\tEnd EAs Test\n"
793f08c3bdfSopenharmony_ci
794f08c3bdfSopenharmony_ci
795f08c3bdfSopenharmony_ci
796f08c3bdfSopenharmony_ci#####################################################
797f08c3bdfSopenharmony_ci#
798f08c3bdfSopenharmony_ci# Clean up
799f08c3bdfSopenharmony_ci#
800f08c3bdfSopenharmony_ci#####################################################
801f08c3bdfSopenharmony_ci
802f08c3bdfSopenharmony_ciuserdel tacluser1
803f08c3bdfSopenharmony_ciuserdel tacluser2
804f08c3bdfSopenharmony_ciuserdel tacluser3
805f08c3bdfSopenharmony_ciuserdel tacluser4
806f08c3bdfSopenharmony_ciumount -d tacl/mount-ext2
807f08c3bdfSopenharmony_cirm -rf tacl
808