From: Tim Shimmin Date: Tue, 29 May 2001 07:08:24 +0000 (+0000) Subject: Fix up 057 to test the prior bug in acl_get_fd, acl_get_file. X-Git-Tag: v1.1.0~1241 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4a846cb27ab938969cb265b414b878f072f01bbd;p=users%2Fhch%2Fxfstests-dev.git Fix up 057 to test the prior bug in acl_get_fd, acl_get_file. --- diff --git a/057 b/057 index be9934059..76dacbae0 100755 --- a/057 +++ b/057 @@ -42,6 +42,7 @@ owner=tes@sherman.melbourne.sgi.com # get standard environment, filters and checks . ./common.rc . ./common.filter +. ./common.attr seq=`basename $0` echo "QA output created by $seq" @@ -102,6 +103,7 @@ rm -f $seq.full _need_to_be_root [ -x $acl_get ] || _notrun "$acl_get command not found" +[ -x /bin/chacl ] || _notrun "chacl command not found" # get dir cd $TEST_DIR @@ -115,7 +117,11 @@ touch file1 chmod 752 file1 _get_file file1 - +# ensure that full blown acls' get/set work, not just minimal ones +_acl_setup_ids +chacl u::rwx,g::rw-,o::---,u:$acl1:r-x,g:$acl1:r--,m::rwx file1 2>&1 +chacl -l file1 | _acl_filter_id +_get_file file1 | _acl_filter_id # success, all done status=0 diff --git a/057.out b/057.out index eb9bbc79b..7e38ab37e 100644 --- a/057.out +++ b/057.out @@ -15,3 +15,20 @@ file1: access irix-empty access, fd, linux-semantics file1: access u::rwx,g::r-x,o::-w- +file1 [u::rwx,g::rw-,o::---,u:id1:r-x,g:id1:r--,m::rwx] +-rwxrwx--- 0 0 file1 + +access, default, irix-semantics +file1: access u::rwx,g::rw-,o::---,u:id1:r-x,g:id1:r--,m::rwx +file1: default irix-empty + +access, default, linux-semantics +file1: access u::rwx,g::rw-,o::---,u:id1:r-x,g:id1:r--,m::rwx +file1: default linux-empty + +access, fd, irix-semantics +file1: access u::rwx,g::rw-,o::---,u:id1:r-x,g:id1:r--,m::rwx + +access, fd, linux-semantics +file1: access u::rwx,g::rw-,o::---,u:id1:r-x,g:id1:r--,m::rwx + diff --git a/058 b/058 new file mode 100755 index 000000000..0205c8011 --- /dev/null +++ b/058 @@ -0,0 +1,60 @@ +#! /bin/sh +# XFS QA Test No. 058 +# $Id: 1.1 $ +# +# Test some libacl functions. +# +#----------------------------------------------------------------------- +# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Further, this software is distributed without any warranty that it is +# free of the rightful claim of any third person regarding infringement +# or the like. Any license provided herein, whether implied or +# otherwise, applies only to this software file. Patent licenses, if +# any, provided herein do not apply to combinations of this program with +# other software, or any other product whatsoever. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston MA 02111-1307, USA. +# +# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, +# Mountain View, CA 94043, or: +# +# http://www.sgi.com +# +# For further information regarding this notice, see: +# +# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ +#----------------------------------------------------------------------- +# +# creator +owner=tes@sherman.melbourne.sgi.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# real QA test starts here + +src/acl_test + +# success, all done +status=0 +exit diff --git a/058.out b/058.out new file mode 100644 index 000000000..d55bc9152 --- /dev/null +++ b/058.out @@ -0,0 +1,234 @@ +QA output created by 058 +*** test out creating an ACL *** +Test acl_init(ACL_MAX_ENTRIES+1) +acl_test: acl_init(max+1): Invalid argument +Test acl_init(-1) +acl_test: acl_init(-1): Invalid argument +Test acl_init(0) +Test acl_create_entry(NULL, ...) +acl_test: acl_create_entry(NULL,ace1): Invalid argument +Test acl_create_entry(..., NULL) +acl_test: acl_create_entry(NULL,ace1): Invalid argument +Test acl_create_entry(acl1, ace1) +acl_test: acl_create_entry(*null,ace1): Invalid argument +0: creating ace +ACL[n=1]: 0: +1: creating ace +ACL[n=2]: 0: 1: +2: creating ace +ACL[n=3]: 0: 1: 2: +3: creating ace +ACL[n=4]: 0: 1: 2: 3: +4: creating ace +ACL[n=5]: 0: 1: 2: 3: 4: +5: creating ace +ACL[n=6]: 0: 1: 2: 3: 4: 5: +6: creating ace +ACL[n=7]: 0: 1: 2: 3: 4: 5: 6: +7: creating ace +ACL[n=8]: 0: 1: 2: 3: 4: 5: 6: 7: +8: creating ace +ACL[n=9]: 0: 1: 2: 3: 4: 5: 6: 7: 8: +9: creating ace +ACL[n=10]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: +10: creating ace +ACL[n=11]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: +11: creating ace +ACL[n=12]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: +12: creating ace +ACL[n=13]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: +13: creating ace +ACL[n=14]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: +14: creating ace +ACL[n=15]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: +15: creating ace +ACL[n=16]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: +16: creating ace +ACL[n=17]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: +17: creating ace +ACL[n=18]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: +18: creating ace +ACL[n=19]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: +19: creating ace +ACL[n=20]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: +20: creating ace +ACL[n=21]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: +21: creating ace +ACL[n=22]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: +22: creating ace +ACL[n=23]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: +23: creating ace +ACL[n=24]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: +24: creating ace +ACL[n=25]: 0: 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: creating ace +acl_test: acl_create_entry: Cannot allocate memory +ACL[n=25]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: +26: creating ace +acl_test: acl_create_entry: Cannot allocate memory +ACL[n=25]: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: +*** test out getting ACEs *** +Get 1st entry on filled ACL +acl_get_entry -> 1 +1: +Get 2th entry on filled ACL +acl_get_entry -> 1 +2: +Get 3th entry on filled ACL +acl_get_entry -> 1 +3: +Get 4th entry on filled ACL +acl_get_entry -> 1 +4: +Get 5th entry on filled ACL +acl_get_entry -> 1 +5: +Get 6th entry on filled ACL +acl_get_entry -> 1 +6: +Get 7th entry on filled ACL +acl_get_entry -> 1 +7: +Get 8th entry on filled ACL +acl_get_entry -> 1 +8: +Get 9th entry on filled ACL +acl_get_entry -> 1 +9: +Get 10th entry on filled ACL +acl_get_entry -> 1 +10: +Get 11th entry on filled ACL +acl_get_entry -> 1 +11: +Get 12th entry on filled ACL +acl_get_entry -> 1 +12: +Get 13th entry on filled ACL +acl_get_entry -> 1 +13: +Get 14th entry on filled ACL +acl_get_entry -> 1 +14: +Get 15th entry on filled ACL +acl_get_entry -> 1 +15: +Get 16th entry on filled ACL +acl_get_entry -> 1 +16: +Get 17th entry on filled ACL +acl_get_entry -> 1 +17: +Get 18th entry on filled ACL +acl_get_entry -> 1 +18: +Get 19th entry on filled ACL +acl_get_entry -> 1 +19: +Get 20th entry on filled ACL +acl_get_entry -> 1 +20: +Get 21th entry on filled ACL +acl_get_entry -> 1 +21: +Get 22th entry on filled ACL +acl_get_entry -> 1 +22: +Get 23th entry on filled ACL +acl_get_entry -> 1 +23: +Get 24th entry on filled ACL +acl_get_entry -> 1 +24: +Get 25th entry on filled ACL +acl_get_entry -> 1 +25: +Get 26th entry on filled ACL +acl_get_entry -> 0 +Get 27th entry on filled ACL +acl_get_entry -> 0 +dump empty ACL +Get 1st entry on filled ACL +acl_get_entry -> 0 +Get 2th entry on filled ACL +acl_get_entry -> 0 +fill an ACL with known bogus values +Get 1st entry on filled ACL +acl_get_entry -> 1 +1: +Get 2th entry on filled ACL +acl_get_entry -> 1 +2: +Get 3th entry on filled ACL +acl_get_entry -> 1 +3: +Get 4th entry on filled ACL +acl_get_entry -> 1 +4: +Get 5th entry on filled ACL +acl_get_entry -> 1 +5: +Get 6th entry on filled ACL +acl_get_entry -> 1 +6: +Get 7th entry on filled ACL +acl_get_entry -> 1 +7: +Get 8th entry on filled ACL +acl_get_entry -> 1 +8: +Get 9th entry on filled ACL +acl_get_entry -> 1 +9: +Get 10th entry on filled ACL +acl_get_entry -> 1 +10: +Get 11th entry on filled ACL +acl_get_entry -> 1 +11: +Get 12th entry on filled ACL +acl_get_entry -> 1 +12: +Get 13th entry on filled ACL +acl_get_entry -> 1 +13: +Get 14th entry on filled ACL +acl_get_entry -> 1 +14: +Get 15th entry on filled ACL +acl_get_entry -> 1 +15: +Get 16th entry on filled ACL +acl_get_entry -> 1 +16: +Get 17th entry on filled ACL +acl_get_entry -> 1 +17: +Get 18th entry on filled ACL +acl_get_entry -> 1 +18: +Get 19th entry on filled ACL +acl_get_entry -> 1 +19: +Get 20th entry on filled ACL +acl_get_entry -> 1 +20: +Get 21th entry on filled ACL +acl_get_entry -> 1 +21: +Get 22th entry on filled ACL +acl_get_entry -> 1 +22: +Get 23th entry on filled ACL +acl_get_entry -> 1 +23: +Get 24th entry on filled ACL +acl_get_entry -> 1 +24: +Get 25th entry on filled ACL +acl_get_entry -> 1 +25: +Get 26th entry on filled ACL +acl_get_entry -> 0 +Get 27th entry on filled ACL +acl_get_entry -> 0 diff --git a/group b/group index fa6ee39b7..c82a3f725 100644 --- a/group +++ b/group @@ -29,6 +29,9 @@ logprint dxm@sgi.com # xfsdump, xfsrestore, xfsinvutil, xfs_copy xfsdump tes@sgi.com ivanr@sgi.com +# chacl, libacl +acl tes@sgi.com ajag@sgi.com + # xfs_growfs growfs ajag@sgi.com @@ -106,3 +109,4 @@ auto dxm@sgi.com 055 xfsdump auto 056 xfsdump auto 057 acl auto +058 acl auto diff --git a/src/Makefile b/src/Makefile index 201c5fb32..fdd1b3987 100644 --- a/src/Makefile +++ b/src/Makefile @@ -33,9 +33,9 @@ TOPDIR = .. include $(TOPDIR)/include/builddefs -TARGETS = alloc acl_get bstat devzero dirstress fault feature fsstress \ - fill fill2 holes ioctl loggen lstat64 nametest permname \ - randholes truncfile usemem runas +TARGETS = alloc acl_get acl_test bstat devzero dirstress fault feature \ + fsstress fill fill2 holes ioctl loggen lstat64 nametest permname \ + randholes runas truncfile usemem ifeq ($(HAVE_DB), true) TARGETS += dbtest endif @@ -80,6 +80,10 @@ LOGGEN_OBJECTS = loggen.o $(LIBXFS) loggen: $(HFILES) $(LOGGEN_OBJECTS) $(CCF) -o $@ $(LDFLAGS) $(LOGGEN_OBJECTS) $(LDLIBS) -ACL_OBJECTS = acl_get.o $(LIBACL) -acl_get: $(HFILES) $(ACL_OBJECTS) - $(CCF) -o $@ $(LDFLAGS) $(ACL_OBJECTS) $(LDLIBS) +ACLGET_OBJECTS = acl_get.o $(LIBACL) +acl_get: $(HFILES) $(ACLGET_OBJECTS) + $(CCF) -o $@ $(LDFLAGS) $(ACLGET_OBJECTS) $(LDLIBS) + +ACLTEST_OBJECTS = acl_test.o $(LIBACL) +acl_test: $(HFILES) $(ACLTEST_OBJECTS) + $(CCF) -o $@ $(LDFLAGS) $(ACLTEST_OBJECTS) $(LDLIBS) diff --git a/src/acl_test.c b/src/acl_test.c new file mode 100644 index 000000000..4f66a9b75 --- /dev/null +++ b/src/acl_test.c @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2001 Silicon Graphics, Inc. All Rights Reserved. + * + * This prog is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This prog is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this prog with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this prog; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +/* + * Test our various libacl functions. + * Use IRIX semantics or Linux semantics if pertinent. + */ + +#include "global.h" + +#include +#include + +char *prog; +int irixsemantics = 0; + +void usage(void) +{ + fprintf(stderr, "usage: %s\n" + " -i - use irix semantics\n" + ,prog); + +} + +void +print_err(char *msg) +{ + printf("%s: %s: %s\n", prog, msg, strerror(errno)); +} + +void +dump_ace(acl_entry_t ace) +{ + printf("", + ace->ae_tag, ace->ae_id, ace->ae_perm); +} + +void +dump_acl(acl_t acl) +{ + int i; + printf("ACL[n=%d]: ", acl->acl_cnt); + for (i=0;iacl_cnt;i++) { + acl_entry_t ace = &acl->acl_entry[i]; + printf("%d: ", i); + dump_ace(ace); + printf(" "); + } + printf("\n"); + +} + +void +dump_acl_by_entry(acl_t acl) +{ + int sts, i; + acl_entry_t ace; + + printf("Get 1st entry on filled ACL\n"); + sts = acl_get_entry(acl, ACL_FIRST_ENTRY, &ace); + printf("acl_get_entry -> %d\n", sts); + if (sts > 0) { + printf("1: "); dump_ace(ace); printf("\n"); + } + + for(i=2;i<=acl->acl_cnt+2;i++) { + printf("Get %dth entry on filled ACL\n", i); + sts = acl_get_entry(acl, ACL_NEXT_ENTRY, &ace); + printf("acl_get_entry -> %d\n", sts); + if (sts > 0) { + printf("%d: ",i); dump_ace(ace); printf("\n"); + } + } +} + +/* + * create a full acl with entries with known bogus values + */ +acl_t +create_filled_acl(void) +{ + acl_t acl; + int i; + + acl = acl_init(ACL_MAX_ENTRIES); + + for(i=0;iacl_entry[i]; + ace->ae_tag = i; + ace->ae_id = i+1; + ace->ae_perm = i+2; + acl->acl_cnt++; + } + return acl; +} + +int +main(int argc, char **argv) +{ + int c, i; + acl_t acl1, acl2, acl3; + acl_entry_t ace1; + + prog = basename(argv[0]); + + while ((c = getopt(argc, argv, "i")) != -1) { + switch (c) { + case 'i': + irixsemantics = 1; + break; + case '?': + usage(); + return 1; + } + } + + if (irixsemantics) { + acl_set_compat(ACL_COMPAT_IRIXGET); + } + + /* ---------------------------------------------- */ + printf("*** test out creating an ACL ***\n"); + + printf("Test acl_init(ACL_MAX_ENTRIES+1)\n"); + acl1 = acl_init(ACL_MAX_ENTRIES+1); + if (acl1 == NULL) { + print_err("acl_init(max+1)"); + } + printf("Test acl_init(-1)\n"); + acl1 = acl_init(-1); + if (acl1 == NULL) { + print_err("acl_init(-1)"); + } + printf("Test acl_init(0)\n"); + acl1 = acl_init(0); + if (acl1 == NULL) { + print_err("acl_init(0)"); + } + + printf("Test acl_create_entry(NULL, ...)\n"); + if (acl_create_entry(NULL, &ace1) == -1) { + print_err("acl_create_entry(NULL,ace1)"); + } + printf("Test acl_create_entry(..., NULL)\n"); + if (acl_create_entry(&acl1, NULL) == -1) { + print_err("acl_create_entry(NULL,ace1)"); + } + printf("Test acl_create_entry(acl1, ace1)\n"); + acl1 = NULL; + if (acl_create_entry(&acl1, &ace1) == -1) { + print_err("acl_create_entry(*null,ace1)"); + } + + acl_free(acl1); + acl1 = acl_init(0); + for (i=0;i<=ACL_MAX_ENTRIES+1;i++) { + printf("%d: creating ace\n", i); + if (acl_create_entry(&acl1, &ace1) == -1) { + print_err("acl_create_entry"); + } + dump_acl(acl1); + } + + /* ---------------------------------------------- */ + printf("*** test out getting ACEs ***\n"); + + dump_acl_by_entry(acl1); + + printf("dump empty ACL\n"); + acl2 = acl_init(0); + if (acl2 == NULL) { + print_err("acl_init(0)"); + } + dump_acl_by_entry(acl2); + + printf("fill an ACL with known bogus values\n"); + acl3 = create_filled_acl(); + dump_acl_by_entry(acl3); + + /* ---------------------------------------------- */ + + return 0; +}