summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x057122
-rw-r--r--057.out17
-rw-r--r--group1
-rw-r--r--include/builddefs.in2
-rw-r--r--src/Makefile6
-rw-r--r--src/acl_get.c183
6 files changed, 329 insertions, 2 deletions
diff --git a/057 b/057
new file mode 100755
index 00000000..be993405
--- /dev/null
+++ b/057
@@ -0,0 +1,122 @@
+#! /bin/sh
+# XFS QA Test No. 057
+# $Id: 1.1 $
+#
+# Test out the different acl_get semantics
+#
+#-----------------------------------------------------------------------
+# 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
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+_cleanup()
+{
+ rm -f $tmp.*
+ rm -rf $TEST_DIR/$seq.dir1
+}
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+acl_get=$here/src/acl_get
+
+_get_file()
+{
+ _file=$1
+
+ ls -ln $_file | awk '{ print $1, $3, $4, $NF }'
+ echo ""
+
+ echo "access, default, irix-semantics"
+ $acl_get -adi $_file
+ echo ""
+
+ echo "access, default, linux-semantics"
+ $acl_get -ad $_file
+ echo ""
+
+ echo "access, fd, irix-semantics"
+ $acl_get -afi $_file
+ echo ""
+
+ echo "access, fd, linux-semantics"
+ $acl_get -af $_file
+ echo ""
+}
+
+_acl_on()
+{
+ # test if acl_get syscall is operational
+ # and hence the ACL config has been turned on
+ touch syscalltest
+ if $acl_get -l syscalltest 2>&1 | tee -a $here/$seq.full \
+ | grep 'Function not implemented' >/dev/null
+ then
+ cd $here
+ _notrun "requires kernel ACL support"
+ fi
+}
+
+# real QA test starts here
+rm -f $seq.full
+
+_need_to_be_root
+
+[ -x $acl_get ] || _notrun "$acl_get command not found"
+
+# get dir
+cd $TEST_DIR
+rm -rf $seq.dir1
+mkdir $seq.dir1
+cd $seq.dir1
+
+_acl_on
+
+touch file1
+chmod 752 file1
+_get_file file1
+
+
+
+# success, all done
+status=0
+exit
diff --git a/057.out b/057.out
new file mode 100644
index 00000000..eb9bbc79
--- /dev/null
+++ b/057.out
@@ -0,0 +1,17 @@
+QA output created by 057
+-rwxr-x-w- 0 0 file1
+
+access, default, irix-semantics
+file1: access irix-empty
+file1: default irix-empty
+
+access, default, linux-semantics
+file1: access u::rwx,g::r-x,o::-w-
+file1: default linux-empty
+
+access, fd, irix-semantics
+file1: access irix-empty
+
+access, fd, linux-semantics
+file1: access u::rwx,g::r-x,o::-w-
+
diff --git a/group b/group
index dfe889b1..fa6ee39b 100644
--- a/group
+++ b/group
@@ -105,3 +105,4 @@ auto dxm@sgi.com
054 quota auto
055 xfsdump auto
056 xfsdump auto
+057 acl auto
diff --git a/include/builddefs.in b/include/builddefs.in
index 0d333d5e..4687c9db 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -46,7 +46,7 @@ LIBGDBM = @libgdbm@
LIBUUID = @libuuid@
LIBHANDLE = @libhdl@
HAVE_DB = @have_db@
-CPPFLAGS = -I/usr/include/xfs -I/usr/include/attr
+CPPFLAGS = -I/usr/include/xfs -I/usr/include/attr -I/usr/include/acl
BUILDRULES = $(TOPDIR)/include/buildrules
diff --git a/src/Makefile b/src/Makefile
index 061ef20f..201c5fb3 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -33,7 +33,7 @@
TOPDIR = ..
include $(TOPDIR)/include/builddefs
-TARGETS = alloc bstat devzero dirstress fault feature fsstress \
+TARGETS = alloc acl_get bstat devzero dirstress fault feature fsstress \
fill fill2 holes ioctl loggen lstat64 nametest permname \
randholes truncfile usemem runas
ifeq ($(HAVE_DB), true)
@@ -79,3 +79,7 @@ bstat: $(HFILES) $(BSTAT_OBJECTS)
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)
diff --git a/src/acl_get.c b/src/acl_get.c
new file mode 100644
index 00000000..ca9e87b4
--- /dev/null
+++ b/src/acl_get.c
@@ -0,0 +1,183 @@
+/*
+ * 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/
+ */
+
+/*
+ * Get an access or default acl on a file
+ * using IRIX semantics or Linux semantics
+ */
+
+#include "global.h"
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <acl.h>
+
+char *prog;
+
+void usage(void)
+{
+ fprintf(stderr, "usage: %s [-a] [-d] [-f] [-i] path\n"
+ "flags:\n"
+ " -a - get access ACL\n"
+ " -d - get default ACL\n"
+ " -f - get access ACL using file descriptor\n"
+ " -i - use irix semantics\n"
+ ,prog);
+
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ int c;
+ char *file;
+ int getaccess = 0;
+ int getdefault = 0;
+ int irixsemantics = 0;
+ int usefd = 0;
+ int fd = -1;
+ acl_t acl;
+ char *buf_acl;
+
+ prog = basename(argv[0]);
+
+ while ((c = getopt(argc, argv, "adif")) != -1) {
+ switch (c) {
+ case 'a':
+ getaccess = 1;
+ break;
+ case 'd':
+ getdefault = 1;
+ break;
+ case 'i':
+ irixsemantics = 1;
+ break;
+ case 'f':
+ usefd = 1;
+ break;
+ case '?':
+ usage();
+ return 1;
+ }
+ }
+
+ if (getdefault && usefd) {
+ fprintf(stderr, "%s: -f and -d are not compatible\n", prog);
+ return 1;
+ }
+
+ /* need path */
+ if (optind == argc) {
+ usage();
+ exit(1);
+ }
+ else {
+ file = argv[optind];
+ }
+
+ if (irixsemantics) {
+ acl_set_compat(ACL_COMPAT_IRIXGET);
+ }
+
+ if (usefd) {
+ fd = open(file, O_RDONLY);
+ if (fd < 0) {
+ fprintf (stderr, "%s: error opening \"%s\": %s\n",
+ prog, file, strerror(errno));
+ usage();
+ return 1;
+
+ }
+ }
+
+ if (getaccess) {
+ if (usefd) {
+ acl = acl_get_fd(fd);
+ }
+ else {
+ acl = acl_get_file(file, ACL_TYPE_ACCESS);
+ }
+ if (acl == NULL) {
+ fprintf (stderr, "%s: error getting access ACL on \"%s\": %s\n",
+ prog, file, strerror(errno));
+ return 0;
+ }
+ if (irixsemantics && acl->acl_cnt == ACL_NOT_PRESENT) {
+ buf_acl = strdup("irix-empty");
+ }
+ else {
+ buf_acl = acl_to_short_text (acl, (ssize_t *) NULL);
+ if (buf_acl == NULL) {
+ fprintf (stderr, "%s: error converting ACL to short text "
+ "for file \"%s\": %s\n",
+ prog, file, strerror(errno));
+ return 0;
+ }
+ }
+ printf("%s: access %s\n", file, buf_acl);
+ acl_free(acl);
+ acl_free(buf_acl);
+ }
+
+ if (getdefault) {
+ acl = acl_get_file(file, ACL_TYPE_DEFAULT);
+ if (acl == NULL) {
+ fprintf (stderr, "%s: error getting default ACL on \"%s\": %s\n",
+ prog, file, strerror(errno));
+ return 0;
+ }
+ if (irixsemantics && acl->acl_cnt == ACL_NOT_PRESENT) {
+ buf_acl = strdup("irix-empty");
+ }
+ else if (!irixsemantics && acl->acl_cnt == 0) {
+ buf_acl = strdup("linux-empty");
+ }
+ else {
+ buf_acl = acl_to_short_text (acl, (ssize_t *) NULL);
+ if (buf_acl == NULL) {
+ fprintf (stderr, "%s: error converting ACL to short text "
+ "for file \"%s\": %s\n",
+ prog, file, strerror(errno));
+ return 0;
+ }
+ }
+ printf("%s: default %s\n", file, buf_acl);
+ acl_free(acl);
+ acl_free(buf_acl);
+ }
+
+ return 0;
+}