acl/0013-modernize-build-system.patch
Marcus Meissner 5439477a49 Accepting request 347209 from home:jeff_mahoney:branches:Base:System
- Update to git snapshot dated 21 Sep 2015.
  - Added:
    * 0001-Install-the-libraries-to-the-appropriate-directory.patch
    * 0002-setfacl.1-fix-typo-inclu-de-include.patch
    * 0003-test-fix-insufficient-quoting-of.patch
    * 0004-Makefile-rename-configure.in-to-configure.ac.patch
    * 0005-Bad-markup-in-acl.5-page.patch
    * 0006-.gitignore-ignore-and-config.h.in.patch
    * 0007-Use-autoreconf-rather-than-autoconf-to-regenerate-th.patch
    * 0008-libacl-Make-sure-that-acl_from_text-always-sets-errn.patch
    * 0009-libacl-fix-SIGSEGV-of-getfacl-e-on-overly-long-group.patch
    * 0010-punt-debian-rpm-packaging-logic.patch
    * 0011-move-gettext-logic-into-misc.h.patch
    * 0012-test-make-running-parallel-out-of-tree-safe.patch
    * 0013-modernize-build-system.patch
    * 0014-po-regenerate-files-after-move.patch
    * 0015-build-drop-aclincludedir-use-pkgincludedir.patch
    * 0016-build-make-use-of-an-aux-dir-to-stow-away-helper-scr.patch
    * 0017-build-ship-a-pkgconfig-file-for-libacl.patch
    * 0018-read_acl_-comments-seq-rename-line-to-lineno.patch
    * 0019-read_acl_-comments-seq-switch-to-next_line.patch
    * 0020-telldir-return-value-and-seekdir-second-parameters-a.patch
    * 0021-mark-libmisc-funcs-as-hidden-so-they-are-not-exporte.patch
    * 0022-add-__acl_-prefixes-to-internal-symbols.patch
    * 0023-cp.test-Check-permissions-of-the-right-file.patch
    * 0024-libacl-acl_set_file-Remove-unnecesary-racy-check.patch
    * 0025-fix-compilation-with-latest-xattr-git.patch
    * 0026-getfacl-Fix-memory-leak.patch
    * 0027-Fix-the-display-block-nesting-in-acl.5.patch
    * 0028-setfacl-man-page-Minor-wording-improvements.patch

OBS-URL: https://build.opensuse.org/request/show/347209
OBS-URL: https://build.opensuse.org/package/show/Base:System/acl?expand=0&rev=43
2015-12-03 14:58:36 +00:00

9835 lines
240 KiB
Diff

From c8f23c92177c5a82ab3699b1b0d4acbee9afb770 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Fri, 10 Jan 2014 10:07:41 -0500
Subject: [PATCH 13/34] modernize build system
This deletes the hand rolled build system and replaces it entirely
with autotools. The overall diffstat shows that this is a clear
win, and it makes the package build/install like every other autotool
package out there which makes the lives of distro maintainers a lot
easier.
This should also be faster by virtue of using a non-recursive build.
Things to note:
- to generate autotools:
./autogen.sh
- to see full compile output:
make V=1
- to build specific targets:
make attr getfattr ...
- to run tests:
make check
- to create a release:
make distcheck -j
Other non-developer things:
- man pages are no longer compressed as this is uncommon in the
autotools world and distros don't need it anyways (they already
handle it automatically for most pakages)
- the minor # of the shared library is now based on the package
version so it'll be much bigger ... this isn't a problem, and
is actually a bugfix (older releases didn't change when they
should have)
(Again, this is all using the standard autotool targets.)
---
.gitignore | 48 +--
Makefile | 115 -------
Makefile.am | 32 ++
Makepkgs | 80 -----
VERSION | 7 -
autogen.sh | 4 +
chacl/Makefile | 35 ---
chacl/chacl.c | 354 ---------------------
configure.ac | 60 ++--
doc/Makefile | 42 ---
doc/Makemodule.am | 10 +
doc/TODO | 2 -
examples/Makefile | 30 +-
examples/Makefile.examples | 9 -
examples/Makemodule.am | 7 +
getfacl/Makefile | 36 ---
getfacl/getfacl.c | 747 ---------------------------------------------
getfacl/user_group.c | 59 ----
getfacl/user_group.h | 31 --
include/Makefile | 40 ---
include/Makemodule.am | 10 +
include/builddefs.in | 94 ------
include/buildmacros | 160 ----------
include/buildrules | 104 -------
include/config.h.in | 46 ---
include/install-sh | 365 ----------------------
libacl/Makefile | 68 -----
libacl/Makemodule.am | 81 +++++
libmisc/Makefile | 31 --
libmisc/Makemodule.am | 8 +
m4/.gitignore | 3 +
m4/Makefile | 34 ---
m4/manual_format.m4 | 31 --
m4/multilib.m4 | 43 ---
m4/package_globals.m4 | 61 ----
m4/package_utilies.m4 | 95 ------
man/Makefile | 41 ---
man/Makemodule.am | 3 +
man/man1/Makefile | 35 ---
man/man1/Makemodule.am | 4 +
man/man3/Makefile | 35 ---
man/man3/Makemodule.am | 40 +++
man/man5/Makefile | 35 ---
man/man5/Makemodule.am | 2 +
package/Makefile | 60 ----
package/tar/Makefile | 36 ---
po/.gitignore | 12 +
po/LINGUAS | 3 +
po/Makefile | 42 ---
po/Makevars | 41 +++
po/update-potfiles | 13 +
setfacl/Makefile | 36 ---
setfacl/do_set.c | 528 --------------------------------
setfacl/do_set.h | 36 ---
setfacl/parse.c | 594 -----------------------------------
setfacl/parse.h | 85 ------
setfacl/sequence.c | 162 ----------
setfacl/sequence.h | 115 -------
setfacl/setfacl.c | 669 ----------------------------------------
test/.gitignore | 1 +
test/Makefile | 50 ---
test/Makemodule.am | 27 ++
test/root/getfacl.test | 4 +
test/root/permissions.test | 3 +-
test/root/restore.test | 4 +
test/root/setfacl.test | 4 +
test/run | 8 +
tools/Makemodule.am | 23 ++
tools/chacl.c | 354 +++++++++++++++++++++
tools/do_set.c | 528 ++++++++++++++++++++++++++++++++
tools/do_set.h | 36 +++
tools/getfacl.c | 747 +++++++++++++++++++++++++++++++++++++++++++++
tools/parse.c | 594 +++++++++++++++++++++++++++++++++++
tools/parse.h | 85 ++++++
tools/sequence.c | 162 ++++++++++
tools/sequence.h | 115 +++++++
tools/setfacl.c | 669 ++++++++++++++++++++++++++++++++++++++++
tools/user_group.c | 59 ++++
tools/user_group.h | 31 ++
79 files changed, 3798 insertions(+), 5315 deletions(-)
delete mode 100644 Makefile
create mode 100644 Makefile.am
delete mode 100755 Makepkgs
delete mode 100644 VERSION
create mode 100755 autogen.sh
delete mode 100644 chacl/Makefile
delete mode 100644 chacl/chacl.c
delete mode 100644 doc/Makefile
create mode 100644 doc/Makemodule.am
delete mode 100644 examples/Makefile.examples
create mode 100644 examples/Makemodule.am
delete mode 100644 getfacl/Makefile
delete mode 100644 getfacl/getfacl.c
delete mode 100644 getfacl/user_group.c
delete mode 100644 getfacl/user_group.h
delete mode 100644 include/Makefile
create mode 100644 include/Makemodule.am
delete mode 100644 include/builddefs.in
delete mode 100644 include/buildmacros
delete mode 100644 include/buildrules
delete mode 100644 include/config.h.in
delete mode 100755 include/install-sh
delete mode 100644 libacl/Makefile
create mode 100644 libacl/Makemodule.am
delete mode 100644 libmisc/Makefile
create mode 100644 libmisc/Makemodule.am
create mode 100644 m4/.gitignore
delete mode 100644 m4/Makefile
delete mode 100644 m4/manual_format.m4
delete mode 100644 m4/multilib.m4
delete mode 100644 m4/package_globals.m4
delete mode 100644 m4/package_utilies.m4
delete mode 100644 man/Makefile
create mode 100644 man/Makemodule.am
delete mode 100644 man/man1/Makefile
create mode 100644 man/man1/Makemodule.am
delete mode 100644 man/man3/Makefile
create mode 100644 man/man3/Makemodule.am
delete mode 100644 man/man5/Makefile
create mode 100644 man/man5/Makemodule.am
delete mode 100644 package/Makefile
delete mode 100644 package/tar/Makefile
create mode 100644 po/.gitignore
create mode 100644 po/LINGUAS
delete mode 100644 po/Makefile
create mode 100644 po/Makevars
create mode 100755 po/update-potfiles
delete mode 100644 setfacl/Makefile
delete mode 100644 setfacl/do_set.c
delete mode 100644 setfacl/do_set.h
delete mode 100644 setfacl/parse.c
delete mode 100644 setfacl/parse.h
delete mode 100644 setfacl/sequence.c
delete mode 100644 setfacl/sequence.h
delete mode 100644 setfacl/setfacl.c
create mode 100644 test/.gitignore
delete mode 100644 test/Makefile
create mode 100644 test/Makemodule.am
create mode 100644 tools/Makemodule.am
create mode 100644 tools/chacl.c
create mode 100644 tools/do_set.c
create mode 100644 tools/do_set.h
create mode 100644 tools/getfacl.c
create mode 100644 tools/parse.c
create mode 100644 tools/parse.h
create mode 100644 tools/sequence.c
create mode 100644 tools/sequence.h
create mode 100644 tools/setfacl.c
create mode 100644 tools/user_group.c
create mode 100644 tools/user_group.h
diff --git a/.gitignore b/.gitignore
index 71009b9..d907d15 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,36 +1,46 @@
+*~
*.la
*.lo
*.mo
*.o
-*[-.]manifest
+.dirstamp
+.deps/
.libs/
-/.census
+
/Logs/
+
/acl-*
+/chacl
+/getfacl
+/setfacl
+
+/ABOUT-NLS
/aclocal.m4
/autom4te.cache/
-/chacl/chacl
+/ar-lib
+/config.cache
/config.guess
/config.log
+/config.rpath
/config.status
/config.sub
/configure
-/doc/CHANGES.gz
-/getfacl/getfacl
+/compile
+/depcomp
+/install-sh
+/libtool
+/ltmain.sh
+/m4/
+/missing
+/test-driver
+Makefile
+Makefile.in
+stamp-h1
+
+*.log
+*.trs
+
/include/acl
-/include/builddefs
/include/config.h
+/include/config.h.in
/include/sys
-/libtool
-/ltmain.sh
-/po/acl.pot
-/setfacl/setfacl
-acl-*.tar.gz
-install-sh
-m4/libtool.m4
-m4/ltoptions.m4
-m4/ltsugar.m4
-m4/ltversion.m4
-m4/lt~obsolete.m4
-config.h.in
-*~
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 235736e..0000000
--- a/Makefile
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = .
-HAVE_BUILDDEFS = $(shell test -f $(TOPDIR)/include/builddefs && echo yes || echo no)
-
-ifeq ($(HAVE_BUILDDEFS), yes)
-include $(TOPDIR)/include/builddefs
-endif
-
-CONFIGURE = \
- aclocal.m4 \
- configure config.guess config.sub \
- ltmain.sh m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 \
- m4/ltversion.m4 m4/lt~obsolete.m4
-LSRCFILES = \
- configure.ac Makepkgs install-sh exports README VERSION \
- $(CONFIGURE)
-
-LDIRT = config.log .dep config.status config.cache confdefs.h conftest* \
- Logs/* built .census install.* install-dev.* install-lib.* *.gz
-
-LIB_SUBDIRS = include libmisc libacl
-TOOL_SUBDIRS = getfacl setfacl chacl m4 man doc po test examples package
-
-SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS)
-
-default: include/builddefs include/config.h
-ifeq ($(HAVE_BUILDDEFS), no)
- $(MAKE) -C . $@
-else
- $(MAKE) $(SUBDIRS)
-endif
-
-# tool/lib dependencies
-libacl: libmisc
-getfacl setfacl chacl: libacl
-
-ifeq ($(HAVE_BUILDDEFS), yes)
-include $(BUILDRULES)
-else
-clean: # if configure hasn't run, nothing to clean
-endif
-
-# Recent versions of libtool require the -i option for copying auxiliary
-# files (config.sub, config.guess, install-sh, ltmain.sh), while older
-# versions will copy those files anyway, and don't understand -i.
-LIBTOOLIZE_INSTALL = `libtoolize -n -i >/dev/null 2>/dev/null && echo -i`
-
-configure include/builddefs:
- libtoolize -c $(LIBTOOLIZE_INSTALL) -f
- cp include/install-sh .
- aclocal -I m4
- autoconf
- ./configure \
- --prefix=/ \
- --exec-prefix=/ \
- --sbindir=/bin \
- --bindir=/usr/bin \
- --libdir=/lib \
- --libexecdir=/usr/lib \
- --enable-lib64=yes \
- --includedir=/usr/include \
- --mandir=/usr/share/man \
- --datadir=/usr/share \
- $$LOCAL_CONFIGURE_OPTIONS
- touch .census
-
-include/config.h: include/builddefs
-## Recover from the removal of $@
- @if test -f $@; then :; else \
- rm -f include/builddefs; \
- $(MAKE) $(AM_MAKEFLAGS) include/builddefs; \
- fi
-
-install: default $(addsuffix -install,$(SUBDIRS))
- $(INSTALL) -m 755 -d $(PKG_DOC_DIR)
- $(INSTALL) -m 644 README $(PKG_DOC_DIR)
-
-install-dev: default $(addsuffix -install-dev,$(SUBDIRS))
-
-install-lib: default $(addsuffix -install-lib,$(SUBDIRS))
-
-%-install:
- $(MAKE) -C $* install
-
-%-install-lib:
- $(MAKE) -C $* install-lib
-
-%-install-dev:
- $(MAKE) -C $* install-dev
-
-realclean distclean: clean
- rm -f $(LDIRT) $(CONFIGURE)
- rm -f include/builddefs include/config.h install-sh libtool
- rm -rf autom4te.cache Logs
-
-.PHONY: tests root-tests nfs-tests
-tests root-tests nfs-tests: default
- $(MAKE) -C test/ $@
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..40d6ae5
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,32 @@
+ACLOCAL_AMFLAGS = -I m4
+
+EXTRA_DIST = \
+ exports
+
+SUBDIRS = po
+
+AM_CPPFLAGS = \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -DLOCALEDIR=\"$(localedir)\"
+
+aclincludedir = $(includedir)/acl
+sysincludedir = $(includedir)/sys
+
+aclinclude_HEADERS =
+sysinclude_HEADERS =
+bin_PROGRAMS =
+lib_LTLIBRARIES =
+noinst_HEADERS =
+noinst_LTLIBRARIES =
+dist_doc_DATA =
+dist_man_MANS =
+
+include doc/Makemodule.am
+include examples/Makemodule.am
+include include/Makemodule.am
+include libacl/Makemodule.am
+include libmisc/Makemodule.am
+include man/Makemodule.am
+include test/Makemodule.am
+include tools/Makemodule.am
diff --git a/Makepkgs b/Makepkgs
deleted file mode 100755
index 52368f4..0000000
--- a/Makepkgs
+++ /dev/null
@@ -1,80 +0,0 @@
-#! /bin/sh
-#
-# Copyright (C) 2001, 2002, 2003 Silicon Graphics, Inc. All rights reserved.
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-LOGDIR=Logs
-
-verbose=false
-
-MAKE=${MAKE:-make}
-test ! -z "$MAKE" && make=$MAKE
-
-for opt in $*
-do
- case "$opt" in
- clean)
- ;; # ignored, kept for backward compatibility
- verbose)
- verbose=true ;;
- *)
- echo "Usage: Makepkgs [verbose]"; exit 1 ;;
- esac
-done
-
-# start with a clean manifest
-test ! -d $LOGDIR && mkdir $LOGDIR
-rm -rf $LOGDIR/* > /dev/null 2>&1
-
-# build Debian packages, cleans itself before starting
-SUDO=${SUDO:-sudo}
-test ! -z "$SUDO" && sudo=$SUDO
-
-# build packages - manual clean before starting
-echo "== clean, log is $LOGDIR/clean"
-if $verbose ; then
- $MAKE clean 2>&1 | tee $LOGDIR/clean
-else
- $MAKE clean > $LOGDIR/clean 2>&1 || exit 1
-fi
-
-echo
-echo "== configure, log is $LOGDIR/configure"
-rm -f .census # force configure to run here
-if $verbose ; then
- $MAKE configure 2>&1 | tee $LOGDIR/configure
-else
- $MAKE configure > $LOGDIR/configure 2>&1 || exit 1
-fi
-
-echo
-echo "== default, log is $LOGDIR/default"
-if $verbose ; then
- $MAKE default 2>&1 | tee $LOGDIR/default
-else
- $MAKE default > $LOGDIR/default 2>&1 || exit 1
-fi
-
-echo
-echo "== dist, log is $LOGDIR/dist"
-[ ! -f .census ] && touch .census
-if $verbose ; then
- $MAKE -C package dist 2>&1 | tee $LOGDIR/dist
-else
- $MAKE -C package dist > $LOGDIR/dist 2>&1 || exit 1
- grep '^Wrote:' $LOGDIR/dist | sed -e 's/\.\.\/\.\.\///'
-fi
-
-exit 0
diff --git a/VERSION b/VERSION
deleted file mode 100644
index 245aaf4..0000000
--- a/VERSION
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# This file is used by configure to get version information
-#
-PKG_MAJOR=2
-PKG_MINOR=2
-PKG_REVISION=52
-PKG_BUILD=1
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..a98a3c5
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,4 @@
+#!/bin/sh -ex
+po/update-potfiles
+autopoint --force
+exec autoreconf -f -i
diff --git a/chacl/Makefile b/chacl/Makefile
deleted file mode 100644
index 33858d6..0000000
--- a/chacl/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-LTCOMMAND = chacl
-CFILES = chacl.c
-
-LLDLIBS = $(LIBACL) $(LIBATTR)
-LTDEPENDENCIES = $(LIBACL)
-
-default: $(LTCOMMAND)
-
-include $(BUILDRULES)
-
-install: default
- $(INSTALL) -m 755 -d $(PKG_BIN_DIR)
- $(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_BIN_DIR)
-install-dev install-lib:
diff --git a/chacl/chacl.c b/chacl/chacl.c
deleted file mode 100644
index 525a7ff..0000000
--- a/chacl/chacl.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <libgen.h>
-#include <stdio.h>
-#include <errno.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/acl.h>
-#include <acl/libacl.h>
-#include "misc.h"
-
-static int acl_delete_file (const char * path, acl_type_t type);
-static int list_acl(char *file);
-static int set_acl(acl_t acl, acl_t dacl, const char *fname);
-static int walk_dir(acl_t acl, acl_t dacl, const char *fname);
-
-static char *program;
-static int rflag;
-
-static void
-usage(void)
-{
- fprintf(stderr, _("Usage:\n"));
- fprintf(stderr, _("\t%s acl pathname...\n"), program);
- fprintf(stderr, _("\t%s -b acl dacl pathname...\n"), program);
- fprintf(stderr, _("\t%s -d dacl pathname...\n"), program);
- fprintf(stderr, _("\t%s -R pathname...\n"), program);
- fprintf(stderr, _("\t%s -D pathname...\n"), program);
- fprintf(stderr, _("\t%s -B pathname...\n"), program);
- fprintf(stderr, _("\t%s -l pathname...\t[not IRIX compatible]\n"),
- program);
- fprintf(stderr, _("\t%s -r pathname...\t[not IRIX compatible]\n"),
- program);
- exit(1);
-}
-
-int
-main(int argc, char *argv[])
-{
- char *file;
- int switch_flag = 0; /* ensure only one switch is used */
- int args_required = 2;
- int failed = 0; /* exit status */
- int c; /* For use by getopt(3) */
- int dflag = 0; /* a Default ACL is desired */
- int bflag = 0; /* a both ACLs are desired */
- int Rflag = 0; /* set to true to remove an acl */
- int Dflag = 0; /* set to true to remove default acls */
- int Bflag = 0; /* set to true to remove both acls */
- int lflag = 0; /* set to true to list acls */
- acl_t acl = NULL; /* File ACL */
- acl_t dacl = NULL; /* Directory Default ACL */
-
- program = basename(argv[0]);
-
- setlocale(LC_CTYPE, "");
- setlocale(LC_MESSAGES, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- /* parse arguments */
- while ((c = getopt(argc, argv, "bdlRDBr")) != -1) {
- if (switch_flag)
- usage();
- switch_flag = 1;
-
- switch (c) {
- case 'b':
- bflag = 1;
- args_required = 3;
- break;
- case 'd':
- dflag = 1;
- args_required = 2;
- break;
- case 'R':
- Rflag = 1;
- args_required = 1;
- break;
- case 'D':
- Dflag = 1;
- args_required = 1;
- break;
- case 'B':
- Bflag = 1;
- args_required = 1;
- break;
- case 'l':
- lflag = 1;
- args_required = 1;
- break;
- case 'r':
- rflag = 1;
- args_required = 1;
- break;
- default:
- usage();
- break;
- }
- }
-
- /* if not enough arguments quit */
- if ((argc - optind) < args_required)
- usage();
-
- /* list the acls */
- if (lflag) {
- for (; optind < argc; optind++) {
- file = argv[optind];
- if (!list_acl(file))
- failed++;
- }
- return(failed);
- }
-
- /* remove the acls */
- if (Rflag || Dflag || Bflag) {
- for (; optind < argc; optind++) {
- file = argv[optind];
- if (!Dflag &&
- (acl_delete_file(file, ACL_TYPE_ACCESS) == -1)) {
- fprintf(stderr, _(
- "%s: error removing access acl on \"%s\": %s\n"),
- program, file, strerror(errno));
- failed++;
- }
- if (!Rflag &&
- (acl_delete_file(file, ACL_TYPE_DEFAULT) == -1)) {
- fprintf(stderr, _(
- "%s: error removing default acl on \"%s\": %s\n"),
- program, file, strerror(errno));
- failed++;
- }
- }
- return(failed);
- }
-
- /* file access acl */
- if (! dflag) {
- acl = acl_from_text(argv[optind]);
- failed = acl_check(acl, &c);
- if (failed < 0) {
- fprintf(stderr, "%s: %s - %s\n",
- program, argv[optind], strerror(errno));
- return 1;
- }
- else if (failed > 0) {
- fprintf(stderr, _(
- "%s: access ACL '%s': %s at entry %d\n"),
- program, argv[optind], acl_error(failed), c);
- return 1;
- }
- optind++;
- }
-
-
- /* directory default acl */
- if (bflag || dflag) {
- dacl = acl_from_text(argv[optind]);
- failed = acl_check(dacl, &c);
- if (failed < 0) {
- fprintf(stderr, "%s: %s - %s\n",
- program, argv[optind], strerror(errno));
- return 1;
- }
- else if (failed > 0) {
- fprintf(stderr, _(
- "%s: access ACL '%s': %s at entry %d\n"),
- program, argv[optind], acl_error(failed), c);
- return 1;
- }
- optind++;
- }
-
- /* place acls on files */
- for (; optind < argc; optind++)
- failed += set_acl(acl, dacl, argv[optind]);
-
- if (acl)
- acl_free(acl);
- if (dacl)
- acl_free(dacl);
-
- return(failed);
-}
-
-/*
- * deletes an access acl or directory default acl if one exists
- */
-static int
-acl_delete_file(const char *path, acl_type_t type)
-{
- int error = 0;
-
- /* converts access ACL to a minimal ACL */
- if (type == ACL_TYPE_ACCESS) {
- acl_t acl;
- acl_entry_t entry;
- acl_tag_t tag;
-
- acl = acl_get_file(path, ACL_TYPE_ACCESS);
- if (!acl)
- return -1;
- error = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry);
- while (error == 1) {
- acl_get_tag_type(entry, &tag);
- switch(tag) {
- case ACL_USER:
- case ACL_GROUP:
- case ACL_MASK:
- acl_delete_entry(acl, entry);
- break;
- }
- error = acl_get_entry(acl, ACL_NEXT_ENTRY, &entry);
- }
- if (!error)
- error = acl_set_file(path, ACL_TYPE_ACCESS, acl);
- } else
- error = acl_delete_def_file(path);
- return(error);
-}
-
-/*
- * lists the acl for a file/dir in short text form
- * return 0 on failure
- * return 1 on success
- */
-static int
-list_acl(char *file)
-{
- acl_t acl = NULL;
- acl_t dacl = NULL;
- char *acl_text, *dacl_text = NULL;
-
- if ((acl = acl_get_file(file, ACL_TYPE_ACCESS)) == NULL) {
- fprintf(stderr, _("%s: cannot get access ACL on '%s': %s\n"),
- program, file, strerror(errno));
- return 0;
- }
- if ((dacl = acl_get_file(file, ACL_TYPE_DEFAULT)) == NULL &&
- (errno != EACCES)) { /* EACCES given if not a directory */
- fprintf(stderr, _("%s: cannot get default ACL on '%s': %s\n"),
- program, file, strerror(errno));
- return 0;
- }
- acl_text = acl_to_any_text(acl, NULL, ',', TEXT_ABBREVIATE);
- if (acl_text == NULL) {
- fprintf(stderr, _("%s: cannot get access ACL text on "
- "'%s': %s\n"), program, file, strerror(errno));
- return 0;
- }
- if (acl_entries(dacl) > 0) {
- dacl_text = acl_to_any_text(dacl, NULL, ',', TEXT_ABBREVIATE);
- if (dacl_text == NULL) {
- fprintf(stderr, _("%s: cannot get default ACL text on "
- "'%s': %s\n"), program, file, strerror(errno));
- return 0;
- }
- }
- if (dacl_text) {
- printf("%s [%s/%s]\n", file, acl_text, dacl_text);
- acl_free(dacl_text);
- } else
- printf("%s [%s]\n", file, acl_text);
- acl_free(acl_text);
- acl_free(acl);
- acl_free(dacl);
- return 1;
-}
-
-static int
-set_acl(acl_t acl, acl_t dacl, const char *fname)
-{
- int failed = 0;
-
- if (rflag)
- failed += walk_dir(acl, dacl, fname);
-
- /* set regular acl */
- if (acl && acl_set_file(fname, ACL_TYPE_ACCESS, acl) == -1) {
- fprintf(stderr, _("%s: cannot set access acl on \"%s\": %s\n"),
- program, fname, strerror(errno));
- failed++;
- }
- /* set default acl */
- if (dacl && acl_set_file(fname, ACL_TYPE_DEFAULT, dacl) == -1) {
- fprintf(stderr, _("%s: cannot set default acl on \"%s\": %s\n"),
- program, fname, strerror(errno));
- failed++;
- }
-
- return(failed);
-}
-
-static int
-walk_dir(acl_t acl, acl_t dacl, const char *fname)
-{
- int failed = 0;
- DIR *dir;
- struct dirent64 *d;
- char *name;
-
- if ((dir = opendir(fname)) == NULL) {
- if (errno != ENOTDIR) {
- fprintf(stderr, _("%s: opendir failed: %s\n"),
- program, strerror(errno));
- return(1);
- }
- return(0); /* got a file, not an error */
- }
-
- while ((d = readdir64(dir)) != NULL) {
- /* skip "." and ".." entries */
- if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0)
- continue;
-
- name = malloc(strlen(fname) + strlen(d->d_name) + 2);
- if (name == NULL) {
- fprintf(stderr, _("%s: malloc failed: %s\n"),
- program, strerror(errno));
- exit(1);
- }
- sprintf(name, "%s/%s", fname, d->d_name);
-
- failed += set_acl(acl, dacl, name);
- free(name);
- }
- closedir(dir);
-
- return(failed);
-}
diff --git a/configure.ac b/configure.ac
index 7af2e8d..1ca2a3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,37 +13,53 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-AC_INIT(include/acl.h)
+
+AC_INIT([acl], [2.2.53], [acl-devel@nongnu.org])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_HEADER(include/config.h)
+AC_CONFIG_HEADER([include/config.h])
AC_PREFIX_DEFAULT(/usr)
-AC_PROG_LIBTOOL
+AM_INIT_AUTOMAKE([-Wall foreign 1.11 dist-xz subdir-objects])
+AM_SILENT_RULES([yes])
+
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_USE_SYSTEM_EXTENSIONS
+AC_FUNC_GCC_VISIBILITY
+
+AM_PROG_AR
+LT_INIT
-AC_ARG_ENABLE(shared,
-[ --enable-shared=[yes/no] Enable use of shared libraries [default=yes]],,
- enable_shared=yes)
-AC_SUBST(enable_shared)
+AM_GNU_GETTEXT_VERSION([0.18.2])
+AM_GNU_GETTEXT([external])
-AC_ARG_ENABLE(gettext,
-[ --enable-gettext=[yes/no] Enable alternate language support [default=yes]],,
- enable_gettext=yes)
-AC_SUBST(enable_gettext)
+AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug], [Enable extra debugging])])
+AS_IF([test "x$enable_debug" = "xyes"],
+ [CPPFLAGS="$CPPFLAGS -DDEBUG"],
+ [CPPFLAGS="$CPPFLAGS -DNDEBUG"])
-AC_ARG_ENABLE(lib64,
-[ --enable-lib64=[yes/no] Enable lib64 support [default=no]],,
- enable_lib64=no)
-AC_SUBST(enable_lib64)
+dnl Automatically increment the revision for every release.
+LT_REVISION=$(echo "${PACKAGE_VERSION}" | tr -d .)
+AC_SUBST(LT_REVISION)
-AC_PACKAGE_GLOBALS(acl)
-AC_PACKAGE_UTILITIES(acl)
AC_PACKAGE_NEED_ATTR_XATTR_H
AC_PACKAGE_NEED_ATTR_ERROR_H
-AC_MULTILIB($enable_lib64)
AC_PACKAGE_NEED_GETXATTR_LIBATTR
-AC_MANUAL_FORMAT
-
-AC_FUNC_GCC_VISIBILITY
-AC_OUTPUT(include/builddefs)
+AC_CONFIG_COMMANDS([include/acl],
+ [dnl
+ rm -rf include/acl
+ $as_ln_s "$ac_abs_top_srcdir/include" include/acl
+ ])
+AC_CONFIG_COMMANDS([include/sys],
+ [dnl
+ rm -rf include/sys
+ $as_ln_s "$ac_abs_top_srcdir/include" include/sys
+ ])
+AC_CONFIG_FILES([
+ Makefile
+ po/Makefile.in
+])
+AC_OUTPUT
diff --git a/doc/Makefile b/doc/Makefile
deleted file mode 100644
index a08e403..0000000
--- a/doc/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-LSRCFILES = extensions.txt libacl.txt TODO PORTING CHANGES COPYING COPYING.LGPL INSTALL \
- old-acl.5
-LDIRT = *.gz
-
-default: CHANGES.gz
-
-include $(BUILDRULES)
-
-CHANGES.gz:
- $(ZIP) --best -c < CHANGES > $@
-
-install: default
- $(INSTALL) -m 755 -d $(PKG_DOC_DIR)
- $(INSTALL) -m 644 PORTING CHANGES.gz $(PKG_DOC_DIR)
-ifeq ($(PKG_DISTRIBUTION), debian)
- $(INSTALL) -S CHANGES.gz $(PKG_DOC_DIR)/changelog.gz
-else
- $(INSTALL) -m 644 COPYING COPYING.LGPL $(PKG_DOC_DIR)
-endif
-
-install-dev install-lib:
diff --git a/doc/Makemodule.am b/doc/Makemodule.am
new file mode 100644
index 0000000..1b9c165
--- /dev/null
+++ b/doc/Makemodule.am
@@ -0,0 +1,10 @@
+dist_doc_DATA += \
+ doc/extensions.txt \
+ doc/CHANGES \
+ doc/COPYING \
+ doc/COPYING.LGPL \
+ doc/libacl.txt \
+ doc/PORTING
+
+EXTRA_DIST += \
+ doc/TODO
diff --git a/doc/TODO b/doc/TODO
index 9c23d69..b376a65 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,4 +1,2 @@
-- include po (gettext stuff) in packages and build process
-- fix build process
- check documentation
- add manual pages for POSIX functions
diff --git a/examples/Makefile b/examples/Makefile
index c6aa124..74642ca 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,27 +1,9 @@
-#
-# Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
+CFLAGS = -g -Wall -I../include
+LDFLAGS = -lacl
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
+PROGS = get-acl copy-acl set-acl copyperm
-LSRCFILES = README Makefile.examples get-acl.c set-acl.c copy-acl.c copyperm.c
-LDIRT = get-acl set-acl copy-acl
+all: $(PROGS)
-include $(BUILDRULES)
-
-default install install-dev install-lib:
+clean:
+ rm -f $(PROGS)
diff --git a/examples/Makefile.examples b/examples/Makefile.examples
deleted file mode 100644
index b33c2a5..0000000
--- a/examples/Makefile.examples
+++ /dev/null
@@ -1,9 +0,0 @@
-CFLAGS = -g -Wall
-LDFLAGS = -lacl
-
-PROGS = get-acl copy-acl set-acl copyperm
-
-all: $(PROGS)
-
-clean:
- rm -f $(PROGS)
diff --git a/examples/Makemodule.am b/examples/Makemodule.am
new file mode 100644
index 0000000..e18991a
--- /dev/null
+++ b/examples/Makemodule.am
@@ -0,0 +1,7 @@
+EXTRA_DIST += \
+ examples/copy-acl.c \
+ examples/copyperm.c \
+ examples/get-acl.c \
+ examples/Makefile \
+ examples/README \
+ examples/set-acl.c
diff --git a/getfacl/Makefile b/getfacl/Makefile
deleted file mode 100644
index 7fbafda..0000000
--- a/getfacl/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-LTCOMMAND = getfacl
-CFILES = getfacl.c user_group.c
-HFILES = user_group.h
-
-LLDLIBS = $(LIBMISC) $(LIBACL) $(LIBATTR)
-LTDEPENDENCIES = $(LIBMISC) $(LIBACL)
-
-default: $(LTCOMMAND)
-
-include $(BUILDRULES)
-
-install: default
- $(INSTALL) -m 755 -d $(PKG_BIN_DIR)
- $(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_BIN_DIR)
-install-dev install-lib:
diff --git a/getfacl/getfacl.c b/getfacl/getfacl.c
deleted file mode 100644
index 22cc1c7..0000000
--- a/getfacl/getfacl.c
+++ /dev/null
@@ -1,747 +0,0 @@
-/*
- File: getfacl.c
- (Linux Access Control List Management)
-
- Copyright (C) 1999-2002
- Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA.
-*/
-
-#include "config.h"
-#include <stdio.h>
-#include <errno.h>
-#include <sys/acl.h>
-#include <acl/libacl.h>
-
-#include <limits.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <libgen.h>
-#include <getopt.h>
-#include "misc.h"
-#include "user_group.h"
-#include "walk_tree.h"
-
-#define POSIXLY_CORRECT_STR "POSIXLY_CORRECT"
-
-#if !POSIXLY_CORRECT
-# define CMD_LINE_OPTIONS "aceEsRLPtpndvh"
-#endif
-#define POSIXLY_CMD_LINE_OPTIONS "d"
-
-struct option long_options[] = {
-#if !POSIXLY_CORRECT
- { "access", 0, 0, 'a' },
- { "omit-header", 0, 0, 'c' },
- { "all-effective", 0, 0, 'e' },
- { "no-effective", 0, 0, 'E' },
- { "skip-base", 0, 0, 's' },
- { "recursive", 0, 0, 'R' },
- { "logical", 0, 0, 'L' },
- { "physical", 0, 0, 'P' },
- { "tabular", 0, 0, 't' },
- { "absolute-names", 0, 0, 'p' },
- { "numeric", 0, 0, 'n' },
-#endif
- { "default", 0, 0, 'd' },
- { "version", 0, 0, 'v' },
- { "help", 0, 0, 'h' },
- { NULL, 0, 0, 0 }
-};
-
-const char *progname;
-const char *cmd_line_options;
-
-int walk_flags = WALK_TREE_DEREFERENCE_TOPLEVEL;
-int opt_print_acl;
-int opt_print_default_acl;
-int opt_strip_leading_slash = 1;
-int opt_comments = 1; /* include comments */
-int opt_skip_base; /* skip files that only have the base entries */
-int opt_tabular; /* tabular output format (alias `showacl') */
-#if POSIXLY_CORRECT
-const int posixly_correct = 1; /* Posix compatible behavior! */
-#else
-int posixly_correct; /* Posix compatible behavior? */
-#endif
-int had_errors;
-int absolute_warning; /* Absolute path warning was issued */
-int print_options = TEXT_SOME_EFFECTIVE;
-int opt_numeric; /* don't convert id's to symbolic names */
-
-
-static const char *xquote(const char *str, const char *quote_chars)
-{
- const char *q = quote(str, quote_chars);
- if (q == NULL) {
- fprintf(stderr, "%s: %s\n", progname, strerror(errno));
- exit(1);
- }
- return q;
-}
-
-struct name_list {
- struct name_list *next;
- char name[0];
-};
-
-void free_list(struct name_list *names)
-{
- struct name_list *next;
-
- while (names) {
- next = names->next;
- free(names);
- names = next;
- }
-}
-
-struct name_list *get_list(const struct stat *st, acl_t acl)
-{
- struct name_list *first = NULL, *last = NULL;
- acl_entry_t ent;
- int ret = 0;
-
- if (acl != NULL)
- ret = acl_get_entry(acl, ACL_FIRST_ENTRY, &ent);
- if (ret != 1)
- return NULL;
- while (ret > 0) {
- acl_tag_t e_type;
- const id_t *id_p;
- const char *name = "";
- int len;
-
- acl_get_tag_type(ent, &e_type);
- switch(e_type) {
- case ACL_USER_OBJ:
- name = user_name(st->st_uid, opt_numeric);
- break;
-
- case ACL_USER:
- id_p = acl_get_qualifier(ent);
- if (id_p != NULL)
- name = user_name(*id_p, opt_numeric);
- break;
-
- case ACL_GROUP_OBJ:
- name = group_name(st->st_gid, opt_numeric);
- break;
-
- case ACL_GROUP:
- id_p = acl_get_qualifier(ent);
- if (id_p != NULL)
- name = group_name(*id_p, opt_numeric);
- break;
- }
- name = xquote(name, "\t\n\r");
- len = strlen(name);
- if (last == NULL) {
- first = last = (struct name_list *)
- malloc(sizeof(struct name_list) + len + 1);
- } else {
- last->next = (struct name_list *)
- malloc(sizeof(struct name_list) + len + 1);
- last = last->next;
- }
- if (last == NULL) {
- free_list(first);
- return NULL;
- }
- last->next = NULL;
- strcpy(last->name, name);
-
- ret = acl_get_entry(acl, ACL_NEXT_ENTRY, &ent);
- }
- return first;
-}
-
-int max_name_length(struct name_list *names)
-{
- int max_len = 0;
- while (names != NULL) {
- struct name_list *next = names->next;
- int len = strlen(names->name);
-
- if (len > max_len)
- max_len = len;
- names = next;
- }
- return max_len;
-}
-
-int names_width;
-
-struct acl_perm_def {
- acl_tag_t tag;
- char c;
-};
-
-struct acl_perm_def acl_perm_defs[] = {
- { ACL_READ, 'r' },
- { ACL_WRITE, 'w' },
- { ACL_EXECUTE, 'x' },
- { 0, 0 }
-};
-
-#define ACL_PERMS (sizeof(acl_perm_defs) / sizeof(struct acl_perm_def) - 1)
-
-void acl_perm_str(acl_entry_t entry, char *str)
-{
- acl_permset_t permset;
- int n;
-
- acl_get_permset(entry, &permset);
- for (n = 0; n < (int) ACL_PERMS; n++) {
- str[n] = (acl_get_perm(permset, acl_perm_defs[n].tag) ?
- acl_perm_defs[n].c : '-');
- }
- str[n] = '\0';
-}
-
-void acl_mask_perm_str(acl_t acl, char *str)
-{
- acl_entry_t entry;
-
- str[0] = '\0';
- if (acl_get_entry(acl, ACL_FIRST_ENTRY, &entry) != 1)
- return;
- for(;;) {
- acl_tag_t tag;
-
- acl_get_tag_type(entry, &tag);
- if (tag == ACL_MASK) {
- acl_perm_str(entry, str);
- return;
- }
- if (acl_get_entry(acl, ACL_NEXT_ENTRY, &entry) != 1)
- return;
- }
-}
-
-void apply_mask(char *perm, const char *mask)
-{
- while (*perm) {
- if (*mask == '-' && *perm >= 'a' && *perm <= 'z')
- *perm = *perm - 'a' + 'A';
- perm++;
- if (*mask)
- mask++;
- }
-}
-
-int show_line(FILE *stream, struct name_list **acl_names, acl_t acl,
- acl_entry_t *acl_ent, const char *acl_mask,
- struct name_list **dacl_names, acl_t dacl,
- acl_entry_t *dacl_ent, const char *dacl_mask)
-{
- acl_tag_t tag_type;
- const char *tag, *name;
- char acl_perm[ACL_PERMS+1], dacl_perm[ACL_PERMS+1];
-
- if (acl) {
- acl_get_tag_type(*acl_ent, &tag_type);
- name = (*acl_names)->name;
- } else {
- acl_get_tag_type(*dacl_ent, &tag_type);
- name = (*dacl_names)->name;
- }
-
- switch(tag_type) {
- case ACL_USER_OBJ:
- tag = "USER";
- break;
- case ACL_USER:
- tag = "user";
- break;
- case ACL_GROUP_OBJ:
- tag = "GROUP";
- break;
- case ACL_GROUP:
- tag = "group";
- break;
- case ACL_MASK:
- tag = "mask";
- break;
- case ACL_OTHER:
- tag = "other";
- break;
- default:
- return -1;
- }
-
- memset(acl_perm, ' ', ACL_PERMS);
- acl_perm[ACL_PERMS] = '\0';
- if (acl_ent) {
- acl_perm_str(*acl_ent, acl_perm);
- if (tag_type != ACL_USER_OBJ && tag_type != ACL_OTHER &&
- tag_type != ACL_MASK)
- apply_mask(acl_perm, acl_mask);
- }
- memset(dacl_perm, ' ', ACL_PERMS);
- dacl_perm[ACL_PERMS] = '\0';
- if (dacl_ent) {
- acl_perm_str(*dacl_ent, dacl_perm);
- if (tag_type != ACL_USER_OBJ && tag_type != ACL_OTHER &&
- tag_type != ACL_MASK)
- apply_mask(dacl_perm, dacl_mask);
- }
-
- fprintf(stream, "%-5s %*s %*s %*s\n",
- tag, -names_width, name,
- -(int)ACL_PERMS, acl_perm,
- -(int)ACL_PERMS, dacl_perm);
-
- if (acl_names) {
- acl_get_entry(acl, ACL_NEXT_ENTRY, acl_ent);
- (*acl_names) = (*acl_names)->next;
- }
- if (dacl_names) {
- acl_get_entry(dacl, ACL_NEXT_ENTRY, dacl_ent);
- (*dacl_names) = (*dacl_names)->next;
- }
- return 0;
-}
-
-int do_show(FILE *stream, const char *path_p, const struct stat *st,
- acl_t acl, acl_t dacl)
-{
- struct name_list *acl_names = get_list(st, acl),
- *first_acl_name = acl_names;
- struct name_list *dacl_names = get_list(st, dacl),
- *first_dacl_name = dacl_names;
-
- int acl_names_width = max_name_length(acl_names);
- int dacl_names_width = max_name_length(dacl_names);
- acl_entry_t acl_ent;
- acl_entry_t dacl_ent;
- char acl_mask[ACL_PERMS+1], dacl_mask[ACL_PERMS+1];
- int ret;
-
- names_width = 8;
- if (acl_names_width > names_width)
- names_width = acl_names_width;
- if (dacl_names_width > names_width)
- names_width = dacl_names_width;
-
- acl_mask[0] = '\0';
- if (acl) {
- acl_mask_perm_str(acl, acl_mask);
- ret = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_ent);
- if (ret == 0)
- acl = NULL;
- if (ret < 0)
- return ret;
- }
- dacl_mask[0] = '\0';
- if (dacl) {
- acl_mask_perm_str(dacl, dacl_mask);
- ret = acl_get_entry(dacl, ACL_FIRST_ENTRY, &dacl_ent);
- if (ret == 0)
- dacl = NULL;
- if (ret < 0)
- return ret;
- }
- fprintf(stream, "# file: %s\n", xquote(path_p, "\n\r"));
- while (acl_names != NULL || dacl_names != NULL) {
- acl_tag_t acl_tag, dacl_tag;
-
- if (acl)
- acl_get_tag_type(acl_ent, &acl_tag);
- if (dacl)
- acl_get_tag_type(dacl_ent, &dacl_tag);
-
- if (acl && (!dacl || acl_tag < dacl_tag)) {
- show_line(stream, &acl_names, acl, &acl_ent, acl_mask,
- NULL, NULL, NULL, NULL);
- continue;
- } else if (dacl && (!acl || dacl_tag < acl_tag)) {
- show_line(stream, NULL, NULL, NULL, NULL,
- &dacl_names, dacl, &dacl_ent, dacl_mask);
- continue;
- } else {
- if (acl_tag == ACL_USER || acl_tag == ACL_GROUP) {
- id_t *acl_id_p = NULL, *dacl_id_p = NULL;
- if (acl_ent)
- acl_id_p = acl_get_qualifier(acl_ent);
- if (dacl_ent)
- dacl_id_p = acl_get_qualifier(dacl_ent);
-
- if (acl && (!dacl || *acl_id_p < *dacl_id_p)) {
- show_line(stream, &acl_names, acl,
- &acl_ent, acl_mask,
- NULL, NULL, NULL, NULL);
- continue;
- } else if (dacl &&
- (!acl || *dacl_id_p < *acl_id_p)) {
- show_line(stream, NULL, NULL, NULL,
- NULL, &dacl_names, dacl,
- &dacl_ent, dacl_mask);
- continue;
- }
- }
- show_line(stream, &acl_names, acl, &acl_ent, acl_mask,
- &dacl_names, dacl, &dacl_ent, dacl_mask);
- }
- }
-
- free_list(first_acl_name);
- free_list(first_dacl_name);
-
- return 0;
-}
-
-/*
- * Create an ACL from the file permission bits
- * of the file PATH_P.
- */
-static acl_t
-acl_get_file_mode(const char *path_p)
-{
- struct stat st;
-
- if (stat(path_p, &st) != 0)
- return NULL;
- return acl_from_mode(st.st_mode);
-}
-
-static const char *
-flagstr(mode_t mode)
-{
- static char str[4];
-
- str[0] = (mode & S_ISUID) ? 's' : '-';
- str[1] = (mode & S_ISGID) ? 's' : '-';
- str[2] = (mode & S_ISVTX) ? 't' : '-';
- str[3] = '\0';
- return str;
-}
-
-int do_print(const char *path_p, const struct stat *st, int walk_flags, void *unused)
-{
- const char *default_prefix = NULL;
- acl_t acl = NULL, default_acl = NULL;
- int error = 0;
-
- if (walk_flags & WALK_TREE_FAILED) {
- fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
- strerror(errno));
- return 1;
- }
-
- /*
- * Symlinks can never have ACLs, so when doing a physical walk, we
- * skip symlinks altogether, and when doing a half-logical walk, we
- * skip all non-toplevel symlinks.
- */
- if ((walk_flags & WALK_TREE_SYMLINK) &&
- ((walk_flags & WALK_TREE_PHYSICAL) ||
- !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL))))
- return 0;
-
- if (opt_print_acl) {
- acl = acl_get_file(path_p, ACL_TYPE_ACCESS);
- if (acl == NULL && (errno == ENOSYS || errno == ENOTSUP))
- acl = acl_get_file_mode(path_p);
- if (acl == NULL)
- goto fail;
- }
-
- if (opt_print_default_acl && S_ISDIR(st->st_mode)) {
- default_acl = acl_get_file(path_p, ACL_TYPE_DEFAULT);
- if (default_acl == NULL) {
- if (errno != ENOSYS && errno != ENOTSUP)
- goto fail;
- } else if (acl_entries(default_acl) == 0) {
- acl_free(default_acl);
- default_acl = NULL;
- }
- }
-
- if (opt_skip_base &&
- (!acl || acl_equiv_mode(acl, NULL) == 0) && !default_acl)
- return 0;
-
- if (opt_print_acl && opt_print_default_acl)
- default_prefix = "default:";
-
- if (opt_strip_leading_slash) {
- if (*path_p == '/') {
- if (!absolute_warning) {
- fprintf(stderr, _("%s: Removing leading "
- "'/' from absolute path names\n"),
- progname);
- absolute_warning = 1;
- }
- while (*path_p == '/')
- path_p++;
- } else if (*path_p == '.' && *(path_p+1) == '/')
- while (*++path_p == '/')
- /* nothing */ ;
- if (*path_p == '\0')
- path_p = ".";
- }
-
- if (opt_tabular) {
- if (do_show(stdout, path_p, st, acl, default_acl) != 0)
- goto fail;
- } else {
- if (opt_comments) {
- printf("# file: %s\n", xquote(path_p, "\n\r"));
- printf("# owner: %s\n",
- xquote(user_name(st->st_uid, opt_numeric), " \t\n\r"));
- printf("# group: %s\n",
- xquote(group_name(st->st_gid, opt_numeric), " \t\n\r"));
- if ((st->st_mode & (S_ISVTX | S_ISUID | S_ISGID)) && !posixly_correct)
- printf("# flags: %s\n", flagstr(st->st_mode));
- }
- if (acl != NULL) {
- char *acl_text = acl_to_any_text(acl, NULL, '\n',
- print_options);
- if (!acl_text)
- goto fail;
- if (puts(acl_text) < 0) {
- acl_free(acl_text);
- goto fail;
- }
- acl_free(acl_text);
- }
- if (default_acl != NULL) {
- char *acl_text = acl_to_any_text(default_acl,
- default_prefix, '\n',
- print_options);
- if (!acl_text)
- goto fail;
- if (puts(acl_text) < 0) {
- acl_free(acl_text);
- goto fail;
- }
- acl_free(acl_text);
- }
- }
- if (acl || default_acl || opt_comments)
- printf("\n");
-
-cleanup:
- if (acl)
- acl_free(acl);
- if (default_acl)
- acl_free(default_acl);
- return error;
-
-fail:
- fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
- strerror(errno));
- error = -1;
- goto cleanup;
-}
-
-
-void help(void)
-{
- printf(_("%s %s -- get file access control lists\n"),
- progname, VERSION);
- printf(_("Usage: %s [-%s] file ...\n"),
- progname, cmd_line_options);
-#if !POSIXLY_CORRECT
- if (posixly_correct) {
-#endif
- printf(_(
-" -d, --default display the default access control list\n"));
-#if !POSIXLY_CORRECT
- } else {
- printf(_(
-" -a, --access display the file access control list only\n"
-" -d, --default display the default access control list only\n"
-" -c, --omit-header do not display the comment header\n"
-" -e, --all-effective print all effective rights\n"
-" -E, --no-effective print no effective rights\n"
-" -s, --skip-base skip files that only have the base entries\n"
-" -R, --recursive recurse into subdirectories\n"
-" -L, --logical logical walk, follow symbolic links\n"
-" -P, --physical physical walk, do not follow symbolic links\n"
-" -t, --tabular use tabular output format\n"
-" -n, --numeric print numeric user/group identifiers\n"
-" -p, --absolute-names don't strip leading '/' in pathnames\n"));
- }
-#endif
- printf(_(
-" -v, --version print version and exit\n"
-" -h, --help this help text\n"));
-}
-
-int main(int argc, char *argv[])
-{
- int opt;
- char *line;
-
- progname = basename(argv[0]);
-
-#if POSIXLY_CORRECT
- cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
-#else
- if (getenv(POSIXLY_CORRECT_STR))
- posixly_correct = 1;
- if (!posixly_correct)
- cmd_line_options = CMD_LINE_OPTIONS;
- else
- cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
-#endif
-
- setlocale(LC_CTYPE, "");
- setlocale(LC_MESSAGES, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- /* Align `#effective:' comments to column 40 for tty's */
- if (!posixly_correct && isatty(fileno(stdout)))
- print_options |= TEXT_SMART_INDENT;
-
- while ((opt = getopt_long(argc, argv, cmd_line_options,
- long_options, NULL)) != -1) {
- switch (opt) {
- case 'a': /* acl only */
- if (posixly_correct)
- goto synopsis;
- opt_print_acl = 1;
- break;
-
- case 'd': /* default acl only */
- opt_print_default_acl = 1;
- break;
-
- case 'c': /* no comments */
- if (posixly_correct)
- goto synopsis;
- opt_comments = 0;
- break;
-
- case 'e': /* all #effective comments */
- if (posixly_correct)
- goto synopsis;
- print_options |= TEXT_ALL_EFFECTIVE;
- break;
-
- case 'E': /* no #effective comments */
- if (posixly_correct)
- goto synopsis;
- print_options &= ~(TEXT_SOME_EFFECTIVE |
- TEXT_ALL_EFFECTIVE);
- break;
-
- case 'R': /* recursive */
- if (posixly_correct)
- goto synopsis;
- walk_flags |= WALK_TREE_RECURSIVE;
- break;
-
- case 'L': /* follow all symlinks */
- if (posixly_correct)
- goto synopsis;
- walk_flags |= WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE;
- walk_flags &= ~WALK_TREE_PHYSICAL;
- break;
-
- case 'P': /* skip all symlinks */
- if (posixly_correct)
- goto synopsis;
- walk_flags |= WALK_TREE_PHYSICAL;
- walk_flags &= ~(WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE |
- WALK_TREE_DEREFERENCE_TOPLEVEL);
- break;
-
- case 's': /* skip files with only base entries */
- if (posixly_correct)
- goto synopsis;
- opt_skip_base = 1;
- break;
-
- case 'p':
- if (posixly_correct)
- goto synopsis;
- opt_strip_leading_slash = 0;
- break;
-
- case 't':
- if (posixly_correct)
- goto synopsis;
- opt_tabular = 1;
- break;
-
- case 'n': /* numeric */
- opt_numeric = 1;
- print_options |= TEXT_NUMERIC_IDS;
- break;
-
- case 'v': /* print version */
- printf("%s " VERSION "\n", progname);
- return 0;
-
- case 'h': /* help */
- help();
- return 0;
-
- case ':': /* option missing */
- case '?': /* unknown option */
- default:
- goto synopsis;
- }
- }
-
- if (!(opt_print_acl || opt_print_default_acl)) {
- opt_print_acl = 1;
- if (!posixly_correct)
- opt_print_default_acl = 1;
- }
-
- if ((optind == argc) && !posixly_correct)
- goto synopsis;
-
- do {
- if (optind == argc ||
- strcmp(argv[optind], "-") == 0) {
- while ((line = next_line(stdin)) != NULL) {
- if (*line == '\0')
- continue;
-
- had_errors += walk_tree(line, walk_flags, 0,
- do_print, NULL);
- }
- if (!feof(stdin)) {
- fprintf(stderr, _("%s: Standard input: %s\n"),
- progname, strerror(errno));
- had_errors++;
- }
- } else
- had_errors += walk_tree(argv[optind], walk_flags, 0,
- do_print, NULL);
- optind++;
- } while (optind < argc);
-
- return had_errors ? 1 : 0;
-
-synopsis:
- fprintf(stderr, _("Usage: %s [-%s] file ...\n"),
- progname, cmd_line_options);
- fprintf(stderr, _("Try `%s --help' for more information.\n"),
- progname);
- return 2;
-}
-
diff --git a/getfacl/user_group.c b/getfacl/user_group.c
deleted file mode 100644
index 61fa0c3..0000000
--- a/getfacl/user_group.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- File: user_group.c
- (Linux Access Control List Management)
-
- Copyright (C) 1999, 2000
- Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA.
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "user_group.h"
-
-
-const char *
-user_name(uid_t uid, int numeric)
-{
- struct passwd *passwd = numeric ? NULL : getpwuid(uid);
- static char uid_str[22];
- int ret;
-
- if (passwd != NULL)
- return passwd->pw_name;
- ret = snprintf(uid_str, sizeof(uid_str), "%ld", (long)uid);
- if (ret < 1 || (size_t)ret >= sizeof(uid_str))
- return "?";
- return uid_str;
-}
-
-
-const char *
-group_name(gid_t gid, int numeric)
-{
- struct group *group = numeric ? NULL : getgrgid(gid);
- static char gid_str[22];
- int ret;
-
- if (group != NULL)
- return group->gr_name;
- ret = snprintf(gid_str, sizeof(gid_str), "%ld", (long)gid);
- if (ret < 1 || (size_t)ret >= sizeof(gid_str))
- return "?";
- return gid_str;
-}
-
diff --git a/getfacl/user_group.h b/getfacl/user_group.h
deleted file mode 100644
index aad5846..0000000
--- a/getfacl/user_group.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- File: user_group.h
- (Linux Access Control List Management)
-
- Copyright (C) 1999 by Andreas Gruenbacher
- <a.gruenbacher@computer.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-
-const char *
-user_name(uid_t uid, int numeric);
-const char *
-group_name(gid_t uid, int numeric);
-
diff --git a/include/Makefile b/include/Makefile
deleted file mode 100644
index 328a61d..0000000
--- a/include/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-HFILES = acl.h libacl.h acl_ea.h misc.h walk_tree.h
-LSRCFILES = builddefs.in buildmacros buildrules config.h.in install-sh
-LDIRT = sys acl
-
-default: sys acl
-
-sys acl:
- $(LN_S) . $@
-
-include $(BUILDRULES)
-
-install-dev: default
- $(INSTALL) -m 755 -d $(PKG_INC_DIR)
- $(INSTALL) -m 755 -d $(PKG_INC_DIR)/sys
- $(INSTALL) -m 644 acl.h $(PKG_INC_DIR)/sys/acl.h
- $(INSTALL) -m 755 -d $(PKG_INC_DIR)/acl
- $(INSTALL) -m 644 libacl.h $(PKG_INC_DIR)/acl/libacl.h
-
-install install-lib:
diff --git a/include/Makemodule.am b/include/Makemodule.am
new file mode 100644
index 0000000..2596f5e
--- /dev/null
+++ b/include/Makemodule.am
@@ -0,0 +1,10 @@
+aclinclude_HEADERS += \
+ include/libacl.h
+
+sysinclude_HEADERS += \
+ include/acl.h
+
+noinst_HEADERS += \
+ include/acl_ea.h \
+ include/misc.h \
+ include/walk_tree.h
diff --git a/include/builddefs.in b/include/builddefs.in
deleted file mode 100644
index 9ed15b4..0000000
--- a/include/builddefs.in
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-# Copyright (c) 2002-2006 Silicon Graphics, Inc. All Rights Reserved.
-#
-# @configure_input@
-#
-
-ifndef _BUILDDEFS_INCLUDED_
-_BUILDDEFS_INCLUDED_ = 1
-
-DEBUG = @debug_build@
-OPTIMIZER = @opt_build@
-MALLOCLIB = @malloc_lib@
-LOADERFLAGS = @LDFLAGS@
-
-LIBACL = $(TOPDIR)/libacl/libacl.la
-LIBATTR = @libattr@
-LIBMISC = $(TOPDIR)/libmisc/libmisc.la
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-top_builddir = @top_builddir@
-datarootdir = @datarootdir@
-
-PKG_NAME = @pkg_name@
-PKG_USER = @pkg_user@
-PKG_GROUP = @pkg_group@
-PKG_RELEASE = @pkg_release@
-PKG_VERSION = @pkg_version@
-PKG_PLATFORM = @pkg_platform@
-PKG_DISTRIBUTION= @pkg_distribution@
-PKG_BIN_DIR = @bindir@
-PKG_SBIN_DIR = @sbindir@
-PKG_LIB_DIR = @libdir@@libdirsuffix@
-PKG_DEVLIB_DIR = @libdir@@libdirsuffix@
-PKG_INC_DIR = @includedir@
-PKG_MAN_DIR = @mandir@
-PKG_DOC_DIR = @datadir@/doc/@pkg_name@
-PKG_LOCALE_DIR = @datadir@/locale
-
-CC = @cc@
-AWK = @awk@
-SED = @sed@
-TAR = @tar@
-ZIP = @zip@
-MAKE = @make@
-ECHO = @echo@
-SORT = @sort@
-LN_S = @LN_S@
-SHELL = @SHELL@
-LIBTOOL = @LIBTOOL@
-MAKEDEPEND = @makedepend@
-
-MSGFMT = @msgfmt@
-MSGMERGE = @msgmerge@
-XGETTEXT = @xgettext@
-
-ENABLE_SHARED = @enable_shared@
-ENABLE_GETTEXT = @enable_gettext@
-
-HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
-
-ifneq "$(findstring $(PKG_PLATFORM), linux gnu gnu/kfreebsd gnu/knetbsd)" ""
-PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-endif
-
-ifeq ($(PKG_PLATFORM),linux)
-DEPENDFLAGS = -D__linux__
-endif
-ifeq ($(PKG_PLATFORM),darwin)
-DEPENDFLAGS = -D__APPLE__
-endif
-ifeq ($(PKG_PLATFORM),irix)
-DEPENDFLAGS = -D__sgi__
-endif
-ifeq ($(PKG_PLATFORM),freebsd)
-DEPENDFLAGS = -D__FreeBSD__
-endif
-
-GCFLAGS = $(OPTIMIZER) $(DEBUG) -funsigned-char -fno-strict-aliasing -Wall \
- -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
- -DPACKAGE=\"$(PKG_NAME)\" -I$(TOPDIR)/include
-
-# Global, Platform, Local CFLAGS
-CFLAGS += $(GCFLAGS) $(PCFLAGS) $(LCFLAGS)
-
-include $(TOPDIR)/include/buildmacros
-
-endif
-
-#
-# For targets that should always be rebuilt,
-# define a target that is never up-to-date.
-# Targets needing this should depend on $(_FORCE)
-_FORCE = __force_build
diff --git a/include/buildmacros b/include/buildmacros
deleted file mode 100644
index 9e81bb8..0000000
--- a/include/buildmacros
+++ /dev/null
@@ -1,160 +0,0 @@
-#
-# Copyright (c) 2002-2003 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-BUILDRULES = $(TOPDIR)/include/buildrules
-
-# LCFLAGS, LLDFLAGS, LLDLIBS, LSRCFILES and LDIRT may be specified in
-# user Makefiles. Note: LSRCFILES is anything other than Makefile, $(CFILES)
-# $(CXXFILES), or $(HFILES) and is used to construct the manifest list
-# during the "dist" phase (packaging).
-
-LDFLAGS += $(LOADERFLAGS) $(LLDFLAGS)
-LTLDFLAGS += $(LOADERFLAGS)
-LDLIBS = $(LLDLIBS) $(PLDLIBS) $(MALLOCLIB)
-
-MAKEOPTS = --no-print-directory
-SRCFILES = Makefile $(HFILES) $(CFILES) $(LSRCFILES) $(LFILES) $(YFILES)
-
-DEPDIRT = dep dep.bak
-MANDIRT = *.[1-9].gz
-PODIRT = *.tmpo *.mo
-CDIRT = $(OBJECTS) $(LTOBJECTS) $(LTCOMMAND) $(LTLIBRARY)
-DIRT = $(LDIRT) $(DEPDIRT) $(MANDIRT) $(PODIRT) $(CDIRT)
-
-OBJECTS = $(ASFILES:.s=.o) \
- $(CFILES:.c=.o) \
- $(LFILES:.l=.o) \
- $(YFILES:%.y=%.tab.o)
-
-INSTALL = $(TOPDIR)/include/install-sh -o $(PKG_USER) -g $(PKG_GROUP)
-
-IMAGES_DIR = $(TOPDIR)/all-images
-DIST_DIR = $(TOPDIR)/dist
-
-CCF = $(CC) $(CFLAGS) $(CPPFLAGS)
-MAKEF = $(MAKE) $(MAKEOPTS)
-CXXF = $(CXX) $(CXXFLAGS)
-
-# For libtool.
-LIBNAME = $(basename $(LTLIBRARY))
-LTOBJECTS = $(OBJECTS:.o=.lo)
-LTVERSION = $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
-
-LTLINK = $(LIBTOOL) --mode=link $(CC)
-LTEXEC = $(LIBTOOL) --mode=execute
-LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CCF)
-
-ifeq ($(ENABLE_SHARED),yes)
-LTLDFLAGS += -rpath $(PKG_LIB_DIR)
-LTLDFLAGS += -version-info $(LTVERSION)
-endif
-
-ifeq ($(ENABLE_SHARED),yes)
-INSTALL_LTLIB = \
- cd $(TOPDIR)/$(LIBNAME)/.libs; \
- ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
- ../$(INSTALL) -m 644 -T so_dot_version $(LIBNAME).lai $(PKG_LIB_DIR); \
- ../$(INSTALL) -T so_dot_current $(LIBNAME).lai $(PKG_LIB_DIR)
-endif
-
-# Libtool thinks the static and shared libs should be in the same dir, so
-# make the static lib appear in the place we chose as rpath (using the two
-# symlinks below).
-# Other things want the shared libs to appear in /usr/lib, else they'll
-# link with the static libs there. So, another symlink to get the .so into
-# /usr/lib.
-ifeq ($(ENABLE_SHARED),yes)
-INSTALL_LTLIB_DEV = \
- cd $(TOPDIR)/$(LIBNAME)/.libs; \
- ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \
- ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR); \
- ../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_DEVLIB_DIR)/$(LIBNAME).la ; \
- ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
- ../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_LIB_DIR); \
- if test "x$(PKG_DEVLIB_DIR)" != "x$(PKG_LIB_DIR)" ; then \
- ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).a $(PKG_LIB_DIR)/$(LIBNAME).a; \
- ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).la $(PKG_LIB_DIR)/$(LIBNAME).la; \
- ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).so $(PKG_DEVLIB_DIR)/$(LIBNAME).so; \
- fi
-else
-INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)
-endif
-
-INSTALL_LTLIB_STATIC = \
- cd $(TOPDIR)/$(LIBNAME)/.libs; \
- ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR);
-
-INSTALL_MAN = \
- @for d in $(MAN_PAGES); do \
- first=true; \
- for m in `$(AWK) \
- '/^\.S[h|H] NAME/ {ok=1; next} ok {print; exit}' $$d \
- | $(SED) \
- -e 's/^\.Nm //' -e 's/,/ /g' -e 's/\\-.*//' \
- -e 's/\\\f[0-9]//g' -e 's/ / /g;q'`; \
- do \
- [ -z "$$m" -o "$$m" = "\\" ] && continue; \
- t=$(MAN_DEST)/$$m.$(MAN_SECTION); \
- if $$first; then \
- if $(HAVE_ZIPPED_MANPAGES); then \
- $(ZIP) -9 -c $$d > $$d.gz; _sfx=.gz; \
- fi; \
- u=$$m.$(MAN_SECTION)$$_sfx; \
- echo $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx;\
- $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx; \
- else \
- echo $(INSTALL) -S $$u $${t}$$_sfx; \
- $(INSTALL) -S $$u $${t}$$_sfx; \
- fi; \
- first=false; \
- done; \
- done
-
-ifeq ($(ENABLE_GETTEXT),yes)
-INSTALL_LINGUAS = \
- @for l in $(LINGUAS) ""; do \
- if test -f "$$l.mo" ; then \
- ldir=$(PKG_LOCALE_DIR)/$$l/LC_MESSAGES; \
- $(INSTALL) -m 755 -d $$ldir; \
- $(INSTALL) -m 644 $$l.mo $$ldir/$(PKG_NAME).mo; \
- fi; \
- done
-endif
-
-MAN_MAKERULE = \
- @for f in *.[12345678] ""; do \
- if test ! -z "$$f"; then \
- $(ZIP) --best -c < $$f > $$f.gz; \
- fi; \
- done
-
-DIST_MAKERULE = \
- $(MAKEF) -C build dist
-
-SOURCE_MAKERULE = \
- @test -z "$$DIR" && DIR="."; \
- for f in $(SRCFILES) ""; do \
- test -z "$$f" && break; \
- test -L "$$f" || $(ECHO) $$DIR/$$f; \
- done; \
- for d in `echo $(SUBDIRS)` ""; do \
- test -z "$$d" && break; \
- if test -d "$$d"; then \
- $(MAKEF) DIR=$$DIR/$$d -C $$d $@ || exit $$?; \
- fi; \
- done
diff --git a/include/buildrules b/include/buildrules
deleted file mode 100644
index 159d70c..0000000
--- a/include/buildrules
+++ /dev/null
@@ -1,104 +0,0 @@
-#
-# Copyright (c) 1999, 2001-2003 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-ifndef _BUILDRULES_INCLUDED_
-_BUILDRULES_INCLUDED_ = 1
-
-include $(TOPDIR)/include/builddefs
-
-clean clobber : $(addsuffix -clean,$(SUBDIRS))
- rm -f $(DIRT)
- @rm -fr .libs
-
-%-clean:
- $(MAKE) -C $* clean
-
-# Never blow away subdirs
-ifdef SUBDIRS
-.PRECIOUS: $(SUBDIRS)
-.PHONY: $(SUBDIRS)
-
-$(SUBDIRS):
- $(MAKE) -C $@
-endif
-
-#
-# Standard targets
-#
-
-ifdef LTCOMMAND
-$(LTCOMMAND) : $(SUBDIRS) $(OBJECTS) $(LTDEPENDENCIES)
- $(LTLINK) -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS)
-endif
-
-ifdef LTLIBRARY
-$(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS)
- $(LTLINK) $(LTLDFLAGS) -o $(LTLIBRARY) $(LTOBJECTS) $(LTLIBS)
-
-%.lo: %.c
- $(LTCOMPILE) -c $<
-endif
-
-ifdef POTHEAD
-%.pot: $(XGETTEXTFILES)
- $(XGETTEXT) --language=C --keyword=_ -o $@ $(XGETTEXTFILES)
-
-# Generate temp .po files, to check whether translations need updating.
-# Not by default, due to gettext output differences between versions.
-%.po: $(POTHEAD)
-# $(MSGMERGE) -o $@.tmpo $@ $(POTHEAD)
-# if ! diff $@.tmpo $@ >/dev/null; then echo "$@ dated, see $@.tmpo"; fi
-
-%.mo: %.po
- $(MSGFMT) -o $@ $<
-endif
-
-source :
- $(SOURCE_MAKERULE)
-
-endif # _BUILDRULES_INCLUDED_
-
-$(_FORCE):
-
-.PHONY : depend
-
-DEPENDSCRIPT := $(MAKEDEPEND) $(DEPENDFLAGS) -f - -- $(CFLAGS) -- $(CFILES) | \
- $(SED) -e 's,`pwd`,$(TOPDIR),g' \
- -e 's, */[^ ]*,,g' \
- -e '/^[^ ]*: *$$/d' \
- -e '/^ *$$/d'
-
-ifdef LTLIBRARY
-DEPENDSCRIPT := $(DEPENDSCRIPT) | $(SED) -e 's,^\([^:]*\)\.o,\1.lo,'
-endif
-
-depend : $(CFILES) $(HFILES) $(addsuffix -depend,$(SUBDIRS))
- $(DEPENDSCRIPT) > .dep
- test -s .dep || rm -f .dep
-
-%-depend:
- $(MAKE) -C $* depend
-
-# Include dep, but only if it exists
-ifeq ($(shell test -f .dep && echo .dep), .dep)
-include .dep
-else
-ifdef LTLIBRARY
-$(LTOBJECTS): $(HFILES)
-else
-$(OBJECTS): $(HFILES)
-endif
-endif
diff --git a/include/config.h.in b/include/config.h.in
deleted file mode 100644
index 6a720ac..0000000
--- a/include/config.h.in
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @configure_input@
- */
-
-/* Define if you have the attr/error_context.h header */
-#undef HAVE_ATTR_ERROR_CONTEXT_H
-
-/* Define if you want Posix compliant getfacl and setfacl utilities
- without extensions */
-#undef POSIXLY_CORRECT
-
-/* The number of bytes in a int. */
-#undef SIZEOF_INT
-
-/* The number of bytes in a long. */
-#undef SIZEOF_LONG
-
-/* The number of bytes in a short. */
-#undef SIZEOF_SHORT
-
-/* Define if you have attribute((visibility(hidden))) in gcc. */
-#undef HAVE_VISIBILITY_ATTRIBUTE
-
-/* Define if you want gettext (I18N) support */
-#undef ENABLE_GETTEXT
-
-/* On GNU/kFreeBSD, ENODATA is not defined in the system headers */
-#include <errno.h>
-#ifndef ENODATA
-# define ENODATA ENOATTR
-#endif
diff --git a/include/install-sh b/include/install-sh
deleted file mode 100755
index 3c9d49b..0000000
--- a/include/install-sh
+++ /dev/null
@@ -1,365 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# This script emulates bsd install and also recognises
-# two environment variables, with the following semantics :-
-#
-# $DIST_MANIFEST - if set, the name of the file to append manifest
-# information in the following format:
-# File : f mode owner group src target
-# Directory: d mode owner group target
-# Symlink : l linkval target
-#
-# $DIST_ROOT - if set, prepend to target
-#
-# The sematics of all combinations of these two variables
-# are as follows:
-#
-# $DIST_MANIFEST? $DIST_ROOT? | Copy? Append Manifest?
-# -----------------------------+--------------------------
-# not set not set | yes no
-# not set set | yes no
-# set not set | no yes
-# set set | yes yes
-#
-_usage() {
- echo "Usage: $prog [-o owner] [-g group] [-m mode] -d directory"
- echo "or $prog [-D] [-o owner] [-g group] [-m mode] file directory/file"
- echo "or $prog [-o owner] [-g group] [-m mode] file [file ...] directory"
- echo "or $prog -S file target (creates \"target\" symlink)"
- echo "or $prog -T lt_arg [-o owner] [-g group] [-m mode] libtool.lai directory"
- echo ""
- echo "The \$DIST_MANIFEST and \$DIST_ROOT environment variables affect the"
- echo "behaviour of this command - see comments in the script."
- echo "The -D flag is only available for the second usage, and causes"
- echo "the target directory to be created before installing the file."
- echo ""
- exit 1
-}
-
-_chown ()
-{
- _st=255
- if [ $# -eq 3 ] ; then
- chown $1:$2 $3
- _st=$?
- if [ $_st -ne 0 ] ; then
- if [ $REAL_UID != '0' ] ; then
- if [ ! -f $DIST_ROOT/.chown.quiet ] ; then
- echo '==============================================='
- echo Ownership of files under ${DIST_ROOT:-/}
- echo cannot be changed
- echo '==============================================='
- if [ -n "$DIST_ROOT" ] ; then
- touch $DIST_ROOT/.chown.quiet
- fi
- fi
- _st=0
- fi
- fi
- fi
-
- return $_st
-}
-
-
-_manifest ()
-{
- echo $* | sed -e 's/\/\//\//g' >>${DIST_MANIFEST:-/dev/null}
-}
-
-prog=`basename $0`
-HERE=`pwd`
-dflag=false
-Dflag=false
-Sflag=false
-Tflag=false
-DIRMODE=755
-FILEMODE=644
-OWNER=`id -u`
-GROUP=`id -g`
-REAL_UID=$OWNER
-
-# default is to install and don't append manifest
-INSTALL=true
-MANIFEST=:
-
-: ${DIST_ROOT:=${DESTDIR}}
-
-[ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false
-[ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest"
-
-[ $# -eq 0 ] && _usage
-
-if $INSTALL
-then
- CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown
-else
- CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true
-fi
-
-[ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true
-
-while getopts "Dcm:d:S:o:g:T:" c $*
-do
- case $c in
- c)
- ;;
- g)
- GROUP=$OPTARG
- ;;
- o)
- OWNER=$OPTARG
- ;;
- m)
- DIRMODE=`expr $OPTARG`
- FILEMODE=$DIRMODE
- ;;
- D)
- Dflag=true
- ;;
- S)
- symlink=$OPTARG
- Sflag=true
- ;;
- d)
- dir=$DIST_ROOT/$OPTARG
- dflag=true
- ;;
- T)
- lt_install=$OPTARG
- Tflag=true
- ;;
- *)
- _usage
- ;;
- esac
-done
-
-shift `expr $OPTIND - 1`
-
-status=0
-if $dflag
-then
- #
- # first usage
- #
- $MKDIR -p $dir
- status=$?
- if [ $status -eq 0 ]
- then
- $CHMOD $DIRMODE $dir
- status=$?
- fi
- if [ $status -eq 0 ]
- then
- $CHOWN $OWNER $GROUP $dir
- status=$?
- fi
- $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
-elif $Sflag
-then
- #
- # fourth usage (symlink)
- #
- if [ $# -ne 1 ]
- then
- _usage
- else
- target=$DIST_ROOT/$1
- fi
- $LN -s -f $symlink $target
- status=$?
- $MANIFEST l $symlink ${target#$DIST_ROOT}
-elif $Tflag
-then
- #
- # -T (install libs built by libtool)
- #
- if [ $# -ne 2 ]
- then
- _usage
- else
- libtool_lai=$1
- # source the libtool variables
- if [ ! -f $libtool_lai ]
- then
- echo "$prog: Unable to find libtool library file $libtool_lai"
- exit 2
- fi
- . ./$libtool_lai
- target=$DIST_ROOT/$2
- fi
- case $lt_install in
- so_dot_version)
- # Loop until we find libfoo.so.x.y.z, then break out.
- for solib in $library_names
- do
- # does it have enough parts? libfoo.so.x.y.z == 5
- cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
- if [ $cnt -eq 5 ]
- then
- install_name=$target/$solib
- $CP $solib $install_name
- status=$?
- $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$solib ${install_name#$DIST_ROOT}
- break
- fi
- done
- ;;
-
- so_*)
- case $lt_install in
- so_dot_current)
- # ln -s libfoo.so.x.y.z to libfoo.so.x
- from_parts=5 # libfoo.so.x.y.z
- to_parts=3 # libfoo.so.x
- ;;
- so_base)
- # ln -s libfoo.so.x to libfoo.so
- from_parts=3 # libfoo.so.x
- to_parts=2 # libfoo.so
- ;;
- *)
- echo "$prog: -T $lt_install invalid"
- exit 2
- ;;
- esac
-
- # Loop until we find the names, then break out.
- for solib in $library_names
- do
- # does it have enough parts?
- cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
- if [ $cnt -eq $from_parts ]
- then
- from_name=$solib
- elif [ $cnt -eq $to_parts ]
- then
- to_name=$solib
- fi
-
- if [ -n "$from_name" ] && [ -n "$to_name" ]
- then
- install_name=$target/$to_name
- $LN -s -f $from_name $install_name
- status=$?
- $MANIFEST l $from_name ${install_name#$DIST_ROOT}
- break
- fi
- done
- ;;
- old_lib)
- install_name=$target/$old_library
- $CP $old_library $install_name
- status=$?
- $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$old_library ${install_name#$DIST_ROOT}
- ;;
- *)
- echo "$prog: -T $lt_install invalid"
- exit 2
- ;;
- esac
-
- case $lt_install in
- old_lib|so_dot_version)
- if [ $status -eq 0 ]
- then
- $CHMOD $FILEMODE $install_name
- $CHOWN $OWNER $GROUP $install_name
- fi
- ;;
- esac
-
-else
- list=""
- dir=""
- if [ $# -eq 2 ]
- then
- #
- # second usage
- #
- f=$1
- dir=$DIST_ROOT/$2
- if $Dflag
- then
- mkdir -p `dirname $dir`
- fi
- $CP $f $dir
- status=$?
- if [ $status -eq 0 ]
- then
- if [ -f $dir/$f ]
- then
- $CHMOD $FILEMODE $dir/$f
- status=$?
- if [ $status -eq 0 ]
- then
- $CHOWN $OWNER $GROUP $dir/$f
- status=$?
- fi
- $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
- else
- $CHMOD $FILEMODE $dir
- status=$?
- if [ $status -eq 0 ]
- then
- $CHOWN $OWNER $GROUP $dir
- status=$?
- fi
- $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
- fi
- fi
- else
- #
- # third usage
- #
- n=1
- while [ $# -gt 0 ]
- do
- if [ $# -gt 1 ]
- then
- list="$list $1"
- else
- dir=$DIST_ROOT/$1
- fi
- shift
- done
-
- # echo DIR=$dir list=\"$list\"
- for f in $list
- do
- $CP $f $dir
- status=$?
- if [ $status -eq 0 ]
- then
- $CHMOD $FILEMODE $dir/$f
- status=$?
- if [ $status -eq 0 ]
- then
- $CHOWN $OWNER $GROUP $dir/$f
- status=$?
- fi
- $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
- fi
- [ $status -ne 0 ] && break
- done
- fi
-fi
-
-exit $status
diff --git a/libacl/Makefile b/libacl/Makefile
deleted file mode 100644
index 6befcd4..0000000
--- a/libacl/Makefile
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-
-LTLDFLAGS += -Wl,--version-script,$(TOPDIR)/exports
-include $(TOPDIR)/include/builddefs
-
-LTLIBRARY = libacl.la
-LTLIBS = -lattr $(LIBMISC)
-LTDEPENDENCIES = $(LIBMISC)
-LT_CURRENT = 2
-LT_REVISION = 0
-LT_AGE = 1
-
-CFILES = $(POSIX_CFILES) $(LIBACL_CFILES) $(INTERNAL_CFILES) \
- perm_copy_fd.c perm_copy_file.c
-HFILES = libobj.h libacl.h byteorder.h __acl_from_xattr.h __acl_to_xattr.h \
- perm_copy.h __acl_extended_file.h
-
-LCFLAGS = -include perm_copy.h
-
-POSIX_CFILES = \
- acl_add_perm.c acl_calc_mask.c acl_clear_perms.c acl_copy_entry.c \
- acl_copy_ext.c acl_copy_int.c acl_create_entry.c acl_delete_def_file.c \
- acl_delete_entry.c acl_delete_perm.c acl_dup.c acl_free.c \
- acl_from_text.c acl_get_entry.c acl_get_fd.c acl_get_file.c \
- acl_get_perm.c acl_get_permset.c acl_get_qualifier.c \
- acl_get_tag_type.c acl_init.c acl_set_fd.c acl_set_file.c \
- acl_set_permset.c acl_set_qualifier.c acl_set_tag_type.c acl_to_text.c \
- acl_valid.c acl_size.c
-
-LIBACL_CFILES = \
- acl_to_any_text.c acl_entries.c acl_check.c acl_error.c acl_cmp.c \
- acl_extended_fd.c acl_extended_file.c acl_equiv_mode.c acl_from_mode.c \
- acl_extended_file_nofollow.c __acl_extended_file.c
-
-INTERNAL_CFILES = \
- __acl_to_any_text.c __acl_to_xattr.c __acl_from_xattr.c \
- __acl_reorder_obj_p.c __libobj.c __apply_mask_to_mode.c
-
-
-default: $(LTLIBRARY)
-
-include $(BUILDRULES)
-
-install:
-
-install-dev: default
- $(INSTALL_LTLIB_DEV)
-
-install-lib: default
- $(INSTALL_LTLIB)
diff --git a/libacl/Makemodule.am b/libacl/Makemodule.am
new file mode 100644
index 0000000..c35214c
--- /dev/null
+++ b/libacl/Makemodule.am
@@ -0,0 +1,81 @@
+lib_LTLIBRARIES += libacl.la
+
+# No other library exports version info, otherwise we'd have to add
+# "libacl_" prefix to all these variables.
+LT_CURRENT = 2
+# The configure script will set this for us automatically.
+#LT_REVISION =
+LT_AGE = 1
+LTVERSION = $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+
+CFILES = $(POSIX_CFILES) $(LIBACL_CFILES) $(INTERNAL_CFILES) \
+ libacl/perm_copy_fd.c \
+ libacl/perm_copy_file.c
+HFILES = \
+ libacl/libobj.h \
+ libacl/libacl.h \
+ libacl/byteorder.h \
+ libacl/__acl_from_xattr.h \
+ libacl/__acl_to_xattr.h \
+ libacl/perm_copy.h \
+ libacl/__acl_extended_file.h
+
+POSIX_CFILES = \
+ libacl/acl_add_perm.c \
+ libacl/acl_calc_mask.c \
+ libacl/acl_clear_perms.c \
+ libacl/acl_copy_entry.c \
+ libacl/acl_copy_ext.c \
+ libacl/acl_copy_int.c \
+ libacl/acl_create_entry.c \
+ libacl/acl_delete_def_file.c \
+ libacl/acl_delete_entry.c \
+ libacl/acl_delete_perm.c \
+ libacl/acl_dup.c \
+ libacl/acl_free.c \
+ libacl/acl_from_text.c \
+ libacl/acl_get_entry.c \
+ libacl/acl_get_fd.c \
+ libacl/acl_get_file.c \
+ libacl/acl_get_perm.c \
+ libacl/acl_get_permset.c \
+ libacl/acl_get_qualifier.c \
+ libacl/acl_get_tag_type.c \
+ libacl/acl_init.c \
+ libacl/acl_set_fd.c \
+ libacl/acl_set_file.c \
+ libacl/acl_set_permset.c \
+ libacl/acl_set_qualifier.c \
+ libacl/acl_set_tag_type.c \
+ libacl/acl_size.c \
+ libacl/acl_to_text.c \
+ libacl/acl_valid.c
+
+LIBACL_CFILES = \
+ libacl/acl_check.c \
+ libacl/acl_cmp.c \
+ libacl/acl_entries.c \
+ libacl/acl_equiv_mode.c \
+ libacl/acl_error.c \
+ libacl/acl_extended_fd.c \
+ libacl/acl_extended_file.c \
+ libacl/acl_extended_file_nofollow.c \
+ libacl/acl_from_mode.c \
+ libacl/acl_to_any_text.c \
+ libacl/__acl_extended_file.c
+
+INTERNAL_CFILES = \
+ libacl/__acl_from_xattr.c \
+ libacl/__acl_reorder_obj_p.c \
+ libacl/__acl_to_any_text.c \
+ libacl/__acl_to_xattr.c \
+ libacl/__apply_mask_to_mode.c \
+ libacl/__libobj.c
+
+libacl_la_DEPENDENCIES = exports libmisc.la
+libacl_la_SOURCES = $(CFILES) $(HFILES)
+libacl_la_LIBADD = -lattr libmisc.la
+libacl_la_CFLAGS = $(AM_CFLAGS) -include $(srcdir)/libacl/perm_copy.h
+libacl_la_LDFLAGS = \
+ -Wl,--version-script,$(top_srcdir)/exports \
+ -version-info $(LTVERSION)
diff --git a/libmisc/Makefile b/libmisc/Makefile
deleted file mode 100644
index e64a287..0000000
--- a/libmisc/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved.
-# Copyright (C) 2009 Andreas Gruenbacher <agruen@suse.de>
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-LTLIBRARY = libmisc.la
-LTLDFLAGS =
-
-CFILES = quote.c unquote.c high_water_alloc.c next_line.c walk_tree.c
-
-default: $(LTLIBRARY)
-install install-dev install-lib:
-
-include $(BUILDRULES)
-
diff --git a/libmisc/Makemodule.am b/libmisc/Makemodule.am
new file mode 100644
index 0000000..d784622
--- /dev/null
+++ b/libmisc/Makemodule.am
@@ -0,0 +1,8 @@
+noinst_LTLIBRARIES += libmisc.la
+
+libmisc_la_SOURCES = \
+ libmisc/high_water_alloc.c \
+ libmisc/next_line.c \
+ libmisc/quote.c \
+ libmisc/unquote.c \
+ libmisc/walk_tree.c
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..73d27ec
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,3 @@
+!.gitignore
+!package_attrdev.m4
+!visibility_hidden.m4
diff --git a/m4/Makefile b/m4/Makefile
deleted file mode 100644
index 9748f11..0000000
--- a/m4/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-LSRCFILES = \
- manual_format.m4 \
- package_attrdev.m4 \
- package_globals.m4 \
- package_utilies.m4 \
- visibility_hidden.m4 \
- multilib.m4
-
-default:
-
-include $(BUILDRULES)
-
-install install-dev install-lib: default
diff --git a/m4/manual_format.m4 b/m4/manual_format.m4
deleted file mode 100644
index 34aa466..0000000
--- a/m4/manual_format.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl Copyright (C) 2003 Silicon Graphics, Inc.
-dnl
-dnl This program is free software: you can redistribute it and/or modify it
-dnl under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation, either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Find format of installed man pages.
-# Always gzipped on Debian, but not Redhat pre-7.0.
-# We don't deal with bzip2'd man pages, which Mandrake uses,
-# someone will send us a patch sometime hopefully. :-)
-#
-AC_DEFUN([AC_MANUAL_FORMAT],
- [ have_zipped_manpages=false
- for d in ${prefix}/share/man ${prefix}/man ; do
- if test -f $d/man1/man.1.gz
- then
- have_zipped_manpages=true
- break
- fi
- done
- AC_SUBST(have_zipped_manpages)
- ])
diff --git a/m4/multilib.m4 b/m4/multilib.m4
deleted file mode 100644
index 8d991d8..0000000
--- a/m4/multilib.m4
+++ /dev/null
@@ -1,43 +0,0 @@
-# The AC_MULTILIB macro was extracted and modified from
-# gettext-0.15's AC_LIB_PREPARE_MULTILIB macro in the lib-prefix.m4 file
-# so that the correct paths can be used for 64-bit libraries.
-#
-dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-dnl From Bruno Haible.
-
-dnl AC_MULTILIB creates a variable libdirsuffix, containing
-dnl the suffix of the libdir, either "" or "64".
-dnl Only do this if the given enable parameter is "yes".
-AC_DEFUN([AC_MULTILIB],
-[
- dnl There is no formal standard regarding lib and lib64. The current
- dnl practice is that on a system supporting 32-bit and 64-bit instruction
- dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit
- dnl libraries go under $prefix/lib. We determine the compiler's default
- dnl mode by looking at the compiler's library search path. If at least
- dnl of its elements ends in /lib64 or points to a directory whose absolute
- dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the
- dnl default, namely "lib".
- enable_lib64="$1"
- libdirsuffix=""
- searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
- if test "$enable_lib64" = "yes" -a -n "$searchpath"; then
- save_IFS="${IFS= }"; IFS=":"
- for searchdir in $searchpath; do
- if test -d "$searchdir"; then
- case "$searchdir" in
- */lib64/ | */lib64 ) libdirsuffix=64 ;;
- *) searchdir=`cd "$searchdir" && pwd`
- case "$searchdir" in
- */lib64 ) libdirsuffix=64 ;;
- esac ;;
- esac
- fi
- done
- IFS="$save_IFS"
- fi
- AC_SUBST(libdirsuffix)
-])
diff --git a/m4/package_globals.m4 b/m4/package_globals.m4
deleted file mode 100644
index e5c2418..0000000
--- a/m4/package_globals.m4
+++ /dev/null
@@ -1,61 +0,0 @@
-dnl Copyright (C) 2003, 2005, 2006, 2007 Silicon Graphics, Inc.
-dnl
-dnl This program is free software: you can redistribute it and/or modify it
-dnl under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation, either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Generic macro, sets up all of the global packaging variables.
-# The following environment variables may be set to override defaults:
-# DEBUG OPTIMIZER MALLOCLIB PLATFORM DISTRIBUTION INSTALL_USER INSTALL_GROUP
-# BUILD_VERSION
-#
-AC_DEFUN([AC_PACKAGE_GLOBALS],
- [ pkg_name="$1"
- AC_SUBST(pkg_name)
-
- AC_PROG_CC
-
- . ./VERSION
- pkg_version=${PKG_MAJOR}.${PKG_MINOR}.${PKG_REVISION}
- AC_SUBST(pkg_version)
- pkg_release=$PKG_BUILD
- test -z "$BUILD_VERSION" || pkg_release="$BUILD_VERSION"
- AC_SUBST(pkg_release)
-
- DEBUG=${DEBUG:-'-DDEBUG'} dnl -DNDEBUG
- debug_build="$DEBUG"
- AC_SUBST(debug_build)
-
- OPTIMIZER=${OPTIMIZER:-'-g -O2'}
- opt_build="$OPTIMIZER"
- AC_SUBST(opt_build)
-
- MALLOCLIB=${MALLOCLIB:-''} dnl /usr/lib/libefence.a
- malloc_lib="$MALLOCLIB"
- AC_SUBST(malloc_lib)
-
- pkg_user=`id -u -n`
- test -z "$INSTALL_USER" || pkg_user="$INSTALL_USER"
- AC_SUBST(pkg_user)
-
- pkg_group=`id -g -n`
- test -z "$INSTALL_GROUP" || pkg_group="$INSTALL_GROUP"
- AC_SUBST(pkg_group)
-
- pkg_distribution=`uname -s`
- test -z "$DISTRIBUTION" || pkg_distribution="$DISTRIBUTION"
- AC_SUBST(pkg_distribution)
-
- pkg_platform=`uname -s | tr 'A-Z' 'a-z' | sed -e 's/irix64/irix/'`
- test -z "$PLATFORM" || pkg_platform="$PLATFORM"
- AC_SUBST(pkg_platform)
- ])
diff --git a/m4/package_utilies.m4 b/m4/package_utilies.m4
deleted file mode 100644
index e372a6b..0000000
--- a/m4/package_utilies.m4
+++ /dev/null
@@ -1,95 +0,0 @@
-dnl Copyright (C) 2003, 2004, 2005, 2006, 2007 Silicon Graphics, Inc.
-dnl
-dnl This program is free software: you can redistribute it and/or modify it
-dnl under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation, either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Check for specified utility (env var) - if unset, fail.
-#
-AC_DEFUN([AC_PACKAGE_NEED_UTILITY],
- [ if test -z "$2"; then
- echo
- echo FATAL ERROR: $3 does not seem to be installed.
- echo $1 cannot be built without a working $4 installation.
- exit 1
- fi
- ])
-
-#
-# Generic macro, sets up all of the global build variables.
-# The following environment variables may be set to override defaults:
-# CC MAKE LIBTOOL TAR ZIP MAKEDEPEND AWK SED ECHO SORT
-# MSGFMT MSGMERGE XGETTEXT
-#
-AC_DEFUN([AC_PACKAGE_UTILITIES],
- [ AC_PROG_CC
- cc="$CC"
- AC_SUBST(cc)
- AC_PACKAGE_NEED_UTILITY($1, "$cc", cc, [C compiler])
-
- search_path="$PATH$PATH_SEPARATOR/usr/freeware/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR/usr/local/bin"
-
- AC_PATH_PROGS(MAKE, gmake make,, $search_path)
- make=$MAKE
- AC_SUBST(make)
- AC_PACKAGE_NEED_UTILITY($1, "$make", make, [GNU make])
-
- AC_PATH_PROG(TAR, tar,, $search_path)
- tar=$TAR
- AC_SUBST(tar)
-
- AC_PATH_PROG(ZIP, gzip,, $search_path)
- zip=$ZIP
- AC_SUBST(zip)
-
- AC_PATH_PROG(MAKEDEPEND, makedepend, /bin/true)
- makedepend=$MAKEDEPEND
- AC_SUBST(makedepend)
-
- AC_PATH_PROG(AWK, awk,, $search_path)
- awk=$AWK
- AC_SUBST(awk)
-
- AC_PATH_PROG(SED, sed,, $search_path)
- sed=$SED
- AC_SUBST(sed)
-
- AC_PATH_PROG(ECHO, echo,, $search_path)
- echo=$ECHO
- AC_SUBST(echo)
-
- AC_PATH_PROG(SORT, sort,, $search_path)
- sort=$SORT
- AC_SUBST(sort)
-
- dnl check if symbolic links are supported
- AC_PROG_LN_S
-
- if test "$enable_gettext" = yes; then
- AC_PATH_PROG(MSGFMT, msgfmt,, $search_path)
- msgfmt=$MSGFMT
- AC_SUBST(msgfmt)
- AC_PACKAGE_NEED_UTILITY($1, "$msgfmt", msgfmt, gettext)
-
- AC_PATH_PROG(MSGMERGE, msgmerge,, $search_path)
- msgmerge=$MSGMERGE
- AC_SUBST(msgmerge)
- AC_PACKAGE_NEED_UTILITY($1, "$msgmerge", msgmerge, gettext)
-
- AC_PATH_PROG(XGETTEXT, xgettext,, $search_path)
- xgettext=$XGETTEXT
- AC_SUBST(xgettext)
- AC_PACKAGE_NEED_UTILITY($1, "$xgettext", xgettext, gettext)
-
- AC_DEFINE([ENABLE_GETTEXT], 1, [enable gettext])
- fi
- ])
diff --git a/man/Makefile b/man/Makefile
deleted file mode 100644
index a2e7546..0000000
--- a/man/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-SUBDIRS = man1 man3 man5
-
-default : $(SUBDIRS)
-
-install : $(addsuffix -install,$(SUBDIRS))
-
-install-dev : $(addsuffix -install-dev,$(SUBDIRS))
-
-install-lib: $(addsuffix -install-lib,$(SUBDIRS))
-
-%-install:
- $(MAKE) -C $* install
-
-%-install-dev:
- $(MAKE) -C $* install-dev
-
-%-install-lib:
- $(MAKE) -C $* install-lib
-
-include $(BUILDRULES)
diff --git a/man/Makemodule.am b/man/Makemodule.am
new file mode 100644
index 0000000..c18576c
--- /dev/null
+++ b/man/Makemodule.am
@@ -0,0 +1,3 @@
+include man/man1/Makemodule.am
+include man/man3/Makemodule.am
+include man/man5/Makemodule.am
diff --git a/man/man1/Makefile b/man/man1/Makefile
deleted file mode 100644
index 2fd48eb..0000000
--- a/man/man1/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ../..
-include $(TOPDIR)/include/builddefs
-
-MAN_SECTION = 1
-
-MAN_PAGES = $(shell echo *.$(MAN_SECTION))
-MAN_DEST = $(PKG_MAN_DIR)/man$(MAN_SECTION)
-LSRCFILES = $(MAN_PAGES)
-
-default : $(MAN_PAGES)
-
-include $(BUILDRULES)
-
-install : default
- $(INSTALL) -m 755 -d $(MAN_DEST)
- $(INSTALL_MAN)
-install-dev install-lib:
diff --git a/man/man1/Makemodule.am b/man/man1/Makemodule.am
new file mode 100644
index 0000000..f80e26a
--- /dev/null
+++ b/man/man1/Makemodule.am
@@ -0,0 +1,4 @@
+dist_man_MANS += \
+ man/man1/chacl.1 \
+ man/man1/getfacl.1 \
+ man/man1/setfacl.1
diff --git a/man/man3/Makefile b/man/man3/Makefile
deleted file mode 100644
index c00f02d..0000000
--- a/man/man3/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ../..
-include $(TOPDIR)/include/builddefs
-
-MAN_SECTION = 3
-
-MAN_PAGES = $(shell echo *.$(MAN_SECTION))
-MAN_DEST = $(PKG_MAN_DIR)/man$(MAN_SECTION)
-LSRCFILES = $(MAN_PAGES)
-
-default : $(MAN_PAGES)
-
-include $(BUILDRULES)
-
-install-dev : default
- $(INSTALL) -m 755 -d $(MAN_DEST)
- $(INSTALL_MAN)
-install install-lib:
diff --git a/man/man3/Makemodule.am b/man/man3/Makemodule.am
new file mode 100644
index 0000000..c0c4825
--- /dev/null
+++ b/man/man3/Makemodule.am
@@ -0,0 +1,40 @@
+dist_man_MANS += \
+ man/man3/acl_add_perm.3 \
+ man/man3/acl_calc_mask.3 \
+ man/man3/acl_check.3 \
+ man/man3/acl_clear_perms.3 \
+ man/man3/acl_cmp.3 \
+ man/man3/acl_copy_entry.3 \
+ man/man3/acl_copy_ext.3 \
+ man/man3/acl_copy_int.3 \
+ man/man3/acl_create_entry.3 \
+ man/man3/acl_delete_def_file.3 \
+ man/man3/acl_delete_entry.3 \
+ man/man3/acl_delete_perm.3 \
+ man/man3/acl_dup.3 \
+ man/man3/acl_entries.3 \
+ man/man3/acl_equiv_mode.3 \
+ man/man3/acl_error.3 \
+ man/man3/acl_extended_fd.3 \
+ man/man3/acl_extended_file.3 \
+ man/man3/acl_extended_file_nofollow.3 \
+ man/man3/acl_free.3 \
+ man/man3/acl_from_mode.3 \
+ man/man3/acl_from_text.3 \
+ man/man3/acl_get_entry.3 \
+ man/man3/acl_get_fd.3 \
+ man/man3/acl_get_file.3 \
+ man/man3/acl_get_perm.3 \
+ man/man3/acl_get_permset.3 \
+ man/man3/acl_get_qualifier.3 \
+ man/man3/acl_get_tag_type.3 \
+ man/man3/acl_init.3 \
+ man/man3/acl_set_fd.3 \
+ man/man3/acl_set_file.3 \
+ man/man3/acl_set_permset.3 \
+ man/man3/acl_set_qualifier.3 \
+ man/man3/acl_set_tag_type.3 \
+ man/man3/acl_size.3 \
+ man/man3/acl_to_any_text.3 \
+ man/man3/acl_to_text.3 \
+ man/man3/acl_valid.3
diff --git a/man/man5/Makefile b/man/man5/Makefile
deleted file mode 100644
index 51de8d9..0000000
--- a/man/man5/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ../..
-include $(TOPDIR)/include/builddefs
-
-MAN_SECTION = 5
-
-MAN_PAGES = $(shell echo *.$(MAN_SECTION))
-MAN_DEST = $(PKG_MAN_DIR)/man$(MAN_SECTION)
-LSRCFILES = $(MAN_PAGES)
-
-default : $(MAN_PAGES)
-
-include $(BUILDRULES)
-
-install : default
- $(INSTALL) -m 755 -d $(MAN_DEST)
- $(INSTALL_MAN)
-install-dev install-lib:
diff --git a/man/man5/Makemodule.am b/man/man5/Makemodule.am
new file mode 100644
index 0000000..7d053b8
--- /dev/null
+++ b/man/man5/Makemodule.am
@@ -0,0 +1,2 @@
+dist_man_MANS += \
+ man/man5/acl.5
diff --git a/package/Makefile b/package/Makefile
deleted file mode 100644
index 6f5aa69..0000000
--- a/package/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-MANIFEST=src-manifest
-SRCTAR=$(PKG_NAME)-$(PKG_VERSION).src.tar.gz
-
-LDIRT = *-manifest *.gz $(TOPDIR)/$(PKG_NAME)-*
-
-# for clean and clobber
-SUBDIRS = tar
-
-# nothing to build here (it's all packaging)
-default install install-dev install-lib:
-
-include $(BUILDRULES)
-
-# Symlink in the TOPDIR is used to pack files relative to
-# product-version directory.
-$(MANIFEST) : $(_FORCE)
- @if [ ! -L $(TOPDIR)/$(PKG_NAME)-$(PKG_VERSION) ] ; then \
- $(LN_S) . $(TOPDIR)/$(PKG_NAME)-$(PKG_VERSION) ; \
- fi
- @CDIR=`pwd`; cd $(TOPDIR); \
- $(MAKE) --no-print-directory source | \
- sed -e 's/^\./$(PKG_NAME)-$(PKG_VERSION)/' > $$CDIR/$@ ;\
- if [ $$? -ne 0 ] ; then \
- exit 1; \
- else \
- unset TAPE; \
- $(TAR) -T $$CDIR/$@ -cf - | $(ZIP) --best > $$CDIR/$(SRCTAR); \
- echo Wrote: $$CDIR/$(SRCTAR); \
- fi
-
-dist : default $(MANIFEST)
- @DIST_MANIFEST=`pwd`/bin-manifest; DIST_ROOT=/tmp/$$$$; \
- export DIST_MANIFEST DIST_ROOT; \
- rm -f $$DIST_MANIFEST; \
- echo === install === && $(MAKE) -C $(TOPDIR) install || exit $$?; \
- if [ -x $(TAR) ]; then \
- ( echo "=== tar ===" && $(MAKEF) -C tar $@ || exit $$? ); \
- fi; \
- test -z "$$KEEP_DIST_ROOT" || rm -rf $$DIST_ROOT; echo Done
diff --git a/package/tar/Makefile b/package/tar/Makefile
deleted file mode 100644
index 31c8f92..0000000
--- a/package/tar/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ../..
-include $(TOPDIR)/include/builddefs
-
-BINTAR=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-LDIRT = *.gz
-
-default install install-dev install-lib:
-
-include $(BUILDRULES)
-
-dist : default
- @HERE=`pwd`; cd $${DIST_ROOT:-/}; \
- $(SORT) -u $$HERE/../bin-manifest | $(AWK) ' \
- $$1 == "f" { printf (".%s\n", $$6); } \
- $$1 == "d" { next; } \
- $$1 == "l" { printf (".%s\n", $$3); }' \
- | $(TAR) -T - -cf - | $(ZIP) --best > $$HERE/$(BINTAR)
- @echo Wrote: `pwd`/$(BINTAR)
diff --git a/po/.gitignore b/po/.gitignore
new file mode 100644
index 0000000..8fe225b
--- /dev/null
+++ b/po/.gitignore
@@ -0,0 +1,12 @@
+*.gmo
+*.sed
+*.sin
+acl.pot
+Makefile.in.in
+Makevars.template
+POTFILES
+POTFILES.in
+Rules-quot
+en@boldquot.*
+en@quot.*
+stamp-po
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 0000000..a1950c5
--- /dev/null
+++ b/po/LINGUAS
@@ -0,0 +1,3 @@
+de es fr gl pl sv
+en@boldquot
+en@quot
diff --git a/po/Makefile b/po/Makefile
deleted file mode 100644
index 7cd5b61..0000000
--- a/po/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-POTHEAD = $(PKG_NAME).pot
-LINGUAS ?= de es fr gl pl sv
-LSRCFILES = $(LINGUAS:%=%.po) $(POTHEAD)
-LDIRT = $(POTHEAD)
-
-XGETTEXTFILES = $(TOPDIR)/chacl/chacl.c \
- $(TOPDIR)/setfacl/do_set.c \
- $(TOPDIR)/setfacl/setfacl.c \
- $(TOPDIR)/getfacl/getfacl.c \
- $(TOPDIR)/libacl/acl_error.c \
- $(TOPDIR)/libacl/perm_copy_fd.c \
- $(TOPDIR)/libacl/perm_copy_file.c
-
-default: $(POTHEAD) $(LINGUAS:%=%.mo)
-
-include $(BUILDRULES)
-
-install: default
- $(INSTALL_LINGUAS)
-
-install-dev install-lib:
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..4b17ab3
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,41 @@
+# Makefile variables for PO directory in any package using GNU gettext.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
+# package. (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.) Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright. The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Silicon Graphics, Inc.
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+# in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+# understood.
+# - Strings which make invalid assumptions about notation of date, time or
+# money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS = $(PACKAGE_BUGREPORT)
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used. It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
diff --git a/po/update-potfiles b/po/update-potfiles
new file mode 100755
index 0000000..271da7e
--- /dev/null
+++ b/po/update-potfiles
@@ -0,0 +1,13 @@
+#!/bin/sh -e
+
+(
+echo "# updated automatically by $0"
+echo
+find \
+ include \
+ libacl \
+ libmisc \
+ tools \
+ -name '*.[ch]' \
+ | grep -v include/config.h
+) > po/POTFILES.in
diff --git a/setfacl/Makefile b/setfacl/Makefile
deleted file mode 100644
index c44e7c0..0000000
--- a/setfacl/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-LTCOMMAND = setfacl
-CFILES = setfacl.c do_set.c sequence.c parse.c
-HFILES = sequence.h parse.h do_set.h
-
-LLDLIBS = $(LIBMISC) $(LIBACL) $(LIBATTR)
-LTDEPENDENCIES = $(LIBMISC) $(LIBACL)
-
-default: $(LTCOMMAND)
-
-include $(BUILDRULES)
-
-install: default
- $(INSTALL) -m 755 -d $(PKG_BIN_DIR)
- $(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_BIN_DIR)
-install-dev install-lib:
diff --git a/setfacl/do_set.c b/setfacl/do_set.c
deleted file mode 100644
index 60da837..0000000
--- a/setfacl/do_set.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- File: do_set.c
- (Linux Access Control List Management)
-
- Copyright (C) 1999, 2000
- Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "config.h"
-#include <stdio.h>
-#include <errno.h>
-#include <sys/acl.h>
-#include <acl/libacl.h>
-
-#include <stdlib.h>
-#include <string.h>
-#include <getopt.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <ftw.h>
-#include "misc.h"
-#include "sequence.h"
-#include "do_set.h"
-#include "parse.h"
-#include "walk_tree.h"
-
-
-extern const char *progname;
-extern int opt_recalculate;
-extern int opt_test;
-extern int print_options;
-
-acl_entry_t
-find_entry(
- acl_t acl,
- acl_tag_t type,
- id_t id)
-{
- acl_entry_t ent;
- acl_tag_t e_type;
- id_t *e_id_p;
-
- if (acl_get_entry(acl, ACL_FIRST_ENTRY, &ent) != 1)
- return NULL;
-
- for(;;) {
- acl_get_tag_type(ent, &e_type);
- if (type == e_type) {
- if (id != ACL_UNDEFINED_ID) {
- e_id_p = acl_get_qualifier(ent);
- if (e_id_p == NULL)
- return NULL;
- if (*e_id_p == id) {
- acl_free(e_id_p);
- return ent;
- }
- acl_free(e_id_p);
- } else {
- return ent;
- }
- }
- if (acl_get_entry(acl, ACL_NEXT_ENTRY, &ent) != 1)
- return NULL;
- }
-}
-
-int
-has_execute_perms(
- acl_t acl)
-{
- acl_entry_t ent;
-
- if (acl_get_entry(acl, ACL_FIRST_ENTRY, &ent) != 1)
- return 0;
-
- for(;;) {
- acl_permset_t permset;
-
- acl_get_permset(ent, &permset);
- if (acl_get_perm(permset, ACL_EXECUTE) != 0)
- return 1;
-
- if (acl_get_entry(acl, ACL_NEXT_ENTRY, &ent) != 1)
- return 0;
- }
-}
-
-int
-clone_entry(
- acl_t from_acl,
- acl_tag_t from_type,
- acl_t *to_acl,
- acl_tag_t to_type)
-{
- acl_entry_t from_entry, to_entry;
- from_entry = find_entry(from_acl, from_type, ACL_UNDEFINED_ID);
- if (from_entry) {
- if (acl_create_entry(to_acl, &to_entry) != 0)
- return -1;
- acl_copy_entry(to_entry, from_entry);
- acl_set_tag_type(to_entry, to_type);
- return 0;
- } else {
- return 1;
- }
-}
-
-
-void
-print_test(
- FILE *file,
- const char *path_p,
- const struct stat *st,
- const acl_t acl,
- const acl_t default_acl)
-{
- char *acl_text, *default_acl_text;
-
- acl_text = acl_to_any_text(acl, NULL, ',', TEXT_ABBREVIATE);
- default_acl_text =
- acl_to_any_text(default_acl, "d:", ',', TEXT_ABBREVIATE);
- fprintf(file, "%s: %s,%s\n", path_p,
- acl_text ? acl_text : "*",
- default_acl_text ? default_acl_text : "*");
- acl_free(acl_text);
- acl_free(default_acl_text);
-}
-
-
-static void
-set_perm(
- acl_entry_t ent,
- mode_t perm)
-{
- acl_permset_t set;
-
- acl_get_permset(ent, &set);
- if (perm & CMD_PERM_READ)
- acl_add_perm(set, ACL_READ);
- else
- acl_delete_perm(set, ACL_READ);
- if (perm & CMD_PERM_WRITE)
- acl_add_perm(set, ACL_WRITE);
- else
- acl_delete_perm(set, ACL_WRITE);
- if (perm & CMD_PERM_EXECUTE)
- acl_add_perm(set, ACL_EXECUTE);
- else
- acl_delete_perm(set, ACL_EXECUTE);
-}
-
-
-static int
-retrieve_acl(
- const char *path_p,
- acl_type_t type,
- const struct stat *st,
- acl_t *old_acl,
- acl_t *acl)
-{
- if (*acl)
- return 0;
- *acl = NULL;
- if (type == ACL_TYPE_ACCESS || S_ISDIR(st->st_mode)) {
- *old_acl = acl_get_file(path_p, type);
- if (*old_acl == NULL && (errno == ENOSYS || errno == ENOTSUP)) {
- if (type == ACL_TYPE_DEFAULT)
- *old_acl = acl_init(0);
- else
- *old_acl = acl_from_mode(st->st_mode);
- }
- } else
- *old_acl = acl_init(0);
- if (*old_acl == NULL)
- return -1;
- *acl = acl_dup(*old_acl);
- if (*acl == NULL)
- return -1;
- return 0;
-}
-
-
-static int
-remove_extended_entries(
- acl_t acl)
-{
- acl_entry_t ent, group_obj;
- acl_permset_t mask_permset, group_obj_permset;
- acl_tag_t tag;
- int error;
-
- /*
- * Removing the ACL_MASK entry from the ACL results in
- * increased permissions for the owning group if the
- * ACL_GROUP_OBJ entry contains permissions not contained
- * in the ACL_MASK entry. We remove these permissions from
- * the ACL_GROUP_OBJ entry to avoid that.
- *
- * After removing the ACL, the file owner and the owning group
- * therefore have the same permissions as before.
- */
-
- ent = find_entry(acl, ACL_MASK, ACL_UNDEFINED_ID);
- group_obj = find_entry(acl, ACL_GROUP_OBJ, ACL_UNDEFINED_ID);
- if (ent && group_obj) {
- if (!acl_get_permset(ent, &mask_permset) &&
- !acl_get_permset(group_obj, &group_obj_permset)) {
- if (!acl_get_perm(mask_permset, ACL_READ))
- acl_delete_perm(group_obj_permset, ACL_READ);
- if (!acl_get_perm(mask_permset, ACL_WRITE))
- acl_delete_perm(group_obj_permset, ACL_WRITE);
- if (!acl_get_perm(mask_permset, ACL_EXECUTE))
- acl_delete_perm(group_obj_permset, ACL_EXECUTE);
- }
- }
-
- error = acl_get_entry(acl, ACL_FIRST_ENTRY, &ent);
- while (error == 1) {
- acl_get_tag_type(ent, &tag);
- switch(tag) {
- case ACL_USER:
- case ACL_GROUP:
- case ACL_MASK:
- acl_delete_entry(acl, ent);
- break;
- default:
- break;
- }
-
- error = acl_get_entry(acl, ACL_NEXT_ENTRY, &ent);
- }
- if (error < 0)
- return -1;
- return 0;
-}
-
-
-#define RETRIEVE_ACL(type) do { \
- error = retrieve_acl(path_p, type, st, old_xacl, xacl); \
- if (error) \
- goto fail; \
- } while(0)
-
-int
-do_set(
- const char *path_p,
- const struct stat *st,
- int walk_flags,
- void *arg)
-{
- struct do_set_args *args = arg;
- acl_t old_acl = NULL, old_default_acl = NULL;
- acl_t acl = NULL, default_acl = NULL;
- acl_t *xacl, *old_xacl;
- acl_entry_t ent;
- cmd_t cmd;
- int which_entry;
- int errors = 0, error;
- char *acl_text;
- int acl_modified = 0, default_acl_modified = 0;
- int acl_mask_provided = 0, default_acl_mask_provided = 0;
-
- if (walk_flags & WALK_TREE_FAILED) {
- fprintf(stderr, "%s: %s: %s\n", progname, path_p, strerror(errno));
- return 1;
- }
-
- /*
- * Symlinks can never have ACLs, so when doing a physical walk, we
- * skip symlinks altogether, and when doing a half-logical walk, we
- * skip all non-toplevel symlinks.
- */
- if ((walk_flags & WALK_TREE_SYMLINK) &&
- ((walk_flags & WALK_TREE_PHYSICAL) ||
- !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL))))
- return 0;
-
- /* Execute the commands in seq (read ACLs on demand) */
- error = seq_get_cmd(args->seq, SEQ_FIRST_CMD, &cmd);
- if (error == 0)
- return 0;
- while (error == 1) {
- mode_t perm = cmd->c_perm;
-
- if (cmd->c_type == ACL_TYPE_ACCESS) {
- xacl = &acl;
- old_xacl = &old_acl;
- acl_modified = 1;
- if (cmd->c_tag == ACL_MASK)
- acl_mask_provided = 1;
- } else {
- xacl = &default_acl;
- old_xacl = &old_default_acl;
- default_acl_modified = 1;
- if (cmd->c_tag == ACL_MASK)
- default_acl_mask_provided = 1;
- }
-
- RETRIEVE_ACL(cmd->c_type);
-
- /* Check for `X', and replace with `x' as appropriate. */
- if (perm & CMD_PERM_COND_EXECUTE) {
- perm &= ~CMD_PERM_COND_EXECUTE;
- if (S_ISDIR(st->st_mode) || has_execute_perms(*xacl))
- perm |= CMD_PERM_EXECUTE;
- }
-
- switch(cmd->c_cmd) {
- case CMD_ENTRY_REPLACE:
- ent = find_entry(*xacl, cmd->c_tag, cmd->c_id);
- if (!ent) {
- if (acl_create_entry(xacl, &ent) != 0)
- goto fail;
- acl_set_tag_type(ent, cmd->c_tag);
- if (cmd->c_id != ACL_UNDEFINED_ID)
- acl_set_qualifier(ent,
- &cmd->c_id);
- }
- set_perm(ent, perm);
- break;
-
- case CMD_REMOVE_ENTRY:
- ent = find_entry(*xacl, cmd->c_tag, cmd->c_id);
- if (ent)
- acl_delete_entry(*xacl, ent);
- else
- /* ignore */;
- break;
-
- case CMD_REMOVE_EXTENDED_ACL:
- remove_extended_entries(acl);
- break;
-
- case CMD_REMOVE_ACL:
- acl_free(*xacl);
- *xacl = acl_init(5);
- if (!*xacl)
- goto fail;
- break;
-
- default:
- errno = EINVAL;
- goto fail;
- }
-
- error = seq_get_cmd(args->seq, SEQ_NEXT_CMD, &cmd);
- }
-
- if (error < 0)
- goto fail;
-
- /* Try to fill in missing entries */
- if (default_acl && acl_entries(default_acl) != 0) {
- xacl = &acl;
- old_xacl = &old_acl;
-
- if (!find_entry(default_acl, ACL_USER_OBJ, ACL_UNDEFINED_ID)) {
- if (!acl)
- RETRIEVE_ACL(ACL_TYPE_ACCESS);
- clone_entry(acl, ACL_USER_OBJ,
- &default_acl, ACL_USER_OBJ);
- }
- if (!find_entry(default_acl, ACL_GROUP_OBJ, ACL_UNDEFINED_ID)) {
- if (!acl)
- RETRIEVE_ACL(ACL_TYPE_ACCESS);
- clone_entry(acl, ACL_GROUP_OBJ,
- &default_acl, ACL_GROUP_OBJ);
- }
- if (!find_entry(default_acl, ACL_OTHER, ACL_UNDEFINED_ID)) {
- if (!acl)
- RETRIEVE_ACL(ACL_TYPE_ACCESS);
- clone_entry(acl, ACL_OTHER,
- &default_acl, ACL_OTHER);
- }
- }
-
- /* update mask entries and check if ACLs are valid */
- if (acl && acl_modified) {
- if (acl_equiv_mode(acl, NULL) != 0) {
- if (!acl_mask_provided &&
- !find_entry(acl, ACL_MASK, ACL_UNDEFINED_ID))
- clone_entry(acl, ACL_GROUP_OBJ,
- &acl, ACL_MASK);
- if (opt_recalculate != -1 &&
- (!acl_mask_provided || opt_recalculate == 1))
- acl_calc_mask(&acl);
- }
-
- error = acl_check(acl, &which_entry);
- if (error < 0)
- goto fail;
- if (error > 0) {
- acl_text = acl_to_any_text(acl, NULL, ',', 0);
- fprintf(stderr, _("%s: %s: Malformed access ACL "
- "`%s': %s at entry %d\n"), progname, path_p,
- acl_text, acl_error(error), which_entry+1);
- acl_free(acl_text);
- errors++;
- goto cleanup;
- }
- }
-
- if (default_acl && acl_entries(default_acl) != 0 &&
- default_acl_modified) {
- if (acl_equiv_mode(default_acl, NULL) != 0) {
- if (!default_acl_mask_provided &&
- !find_entry(default_acl,ACL_MASK,ACL_UNDEFINED_ID))
- clone_entry(default_acl, ACL_GROUP_OBJ,
- &default_acl, ACL_MASK);
- if (opt_recalculate != -1 &&
- (!default_acl_mask_provided ||
- opt_recalculate == 1))
- acl_calc_mask(&default_acl);
- }
-
- error = acl_check(default_acl, &which_entry);
- if (error < 0)
- goto fail;
- if (error > 0) {
- acl_text = acl_to_any_text(default_acl, NULL, ',', 0);
- fprintf(stderr, _("%s: %s: Malformed default ACL "
- "`%s': %s at entry %d\n"),
- progname, path_p, acl_text,
- acl_error(error), which_entry+1);
- acl_free(acl_text);
- errors++;
- goto cleanup;
- }
- }
-
- /* Only directores can have default ACLs */
- if (default_acl && !S_ISDIR(st->st_mode) && (walk_flags & WALK_TREE_RECURSIVE)) {
- /* In recursive mode, ignore default ACLs for files */
- acl_free(default_acl);
- default_acl = NULL;
- }
-
- /* check which ACLs have changed */
- if (acl && old_acl && acl_cmp(old_acl, acl) == 0) {
- acl_free(acl);
- acl = NULL;
- }
- if ((default_acl && old_default_acl &&
- acl_cmp(old_default_acl, default_acl) == 0)) {
- acl_free(default_acl);
- default_acl = NULL;
- }
-
- /* update the file system */
- if (opt_test) {
- print_test(stdout, path_p, st,
- acl, default_acl);
- goto cleanup;
- }
- if (acl) {
- int equiv_mode;
- mode_t mode = 0;
-
- equiv_mode = acl_equiv_mode(acl, &mode);
-
- if (acl_set_file(path_p, ACL_TYPE_ACCESS, acl) != 0) {
- if (errno == ENOSYS || errno == ENOTSUP) {
- if (equiv_mode != 0)
- goto fail;
- else if (chmod(path_p, mode) != 0)
- goto fail;
- } else
- goto fail;
- }
- args->mode = mode;
- }
- if (default_acl) {
- if (S_ISDIR(st->st_mode)) {
- if (acl_entries(default_acl) == 0) {
- if (acl_delete_def_file(path_p) != 0 &&
- errno != ENOSYS && errno != ENOTSUP)
- goto fail;
- } else {
- if (acl_set_file(path_p, ACL_TYPE_DEFAULT,
- default_acl) != 0)
- goto fail;
- }
- } else {
- if (acl_entries(default_acl) != 0) {
- fprintf(stderr, _("%s: %s: Only directories "
- "can have default ACLs\n"),
- progname, path_p);
- errors++;
- goto cleanup;
- }
- }
- }
-
- error = 0;
-
-cleanup:
- if (acl)
- acl_free(acl);
- if (old_acl)
- acl_free(old_acl);
- if (default_acl)
- acl_free(default_acl);
- if (old_default_acl)
- acl_free(old_default_acl);
- return errors;
-
-fail:
- fprintf(stderr, "%s: %s: %s\n", progname, path_p, strerror(errno));
- errors++;
- goto cleanup;
-}
-
diff --git a/setfacl/do_set.h b/setfacl/do_set.h
deleted file mode 100644
index 2ea25a8..0000000
--- a/setfacl/do_set.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- File: do_set.h
- (Linux Access Control List Management)
-
- Copyright (C) 2009 by Andreas Gruenbacher
- <a.gruenbacher@computer.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __DO_SET_H
-#define __DO_SET_H
-
-#include "sequence.h"
-
-struct do_set_args {
- seq_t seq;
- mode_t mode;
-};
-
-extern int do_set(const char *path_p, const struct stat *stat_p, int flags,
- void *arg);
-
-#endif /* __DO_SET_H */
diff --git a/setfacl/parse.c b/setfacl/parse.c
deleted file mode 100644
index e7e6add..0000000
--- a/setfacl/parse.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- File: parse.c
- (Linux Access Control List Management)
-
- Copyright (C) 1999, 2000
- Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pwd.h>
-#include <grp.h>
-#include "sys/acl.h"
-
-#include "sequence.h"
-#include "parse.h"
-#include "misc.h"
-
-#define SKIP_WS(x) ({ \
- while (*(x)==' ' || *(x)=='\t' || *(x)=='\n' || *(x)=='\r') \
- (x)++; \
- })
-
-
-static int
-skip_tag_name(
- const char **text_p,
- const char *token)
-{
- size_t len = strlen(token);
- const char *text = *text_p;
-
- SKIP_WS(text);
- if (strncmp(text, token, len) == 0) {
- text += len;
- goto delimiter;
- }
- if (*text == *token) {
- text++;
- goto delimiter;
- }
- return 0;
-
-delimiter:
- SKIP_WS(text);
- if (*text == ':') {
- *text_p = text+1;
- return 1;
- }
- if (*text == ',' || *text == '\0') {
- *text_p = text;
- return 1;
- }
- return 0;
-}
-
-
-static char *
-get_token(
- const char **text_p)
-{
- char *token = NULL, *t;
- const char *bp, *ep;
-
- bp = *text_p;
- SKIP_WS(bp);
- ep = bp;
-
- while (*ep!='\0' && *ep!='\r' && *ep!='\n' && *ep!=':' && *ep!=',')
- ep++;
- if (ep == bp)
- goto after_token;
- token = (char*)malloc(ep - bp + 1);
- if (token == NULL)
- goto after_token;
- memcpy(token, bp, ep - bp);
-
- /* Trim trailing whitespace */
- t = token + (ep - bp - 1);
- while (t >= token &&
- (*t==' ' || *t=='\t' || *t=='\n' || *t=='\r'))
- t--;
- *(t+1) = '\0';
-
-after_token:
- if (*ep == ':')
- ep++;
- *text_p = ep;
- return token;
-}
-
-
-static int
-get_id(
- const char *token,
- id_t *id_p)
-{
- char *ep;
- long l;
- l = strtol(token, &ep, 0);
- if (*ep != '\0')
- return -1;
- if (l < 0) {
- /*
- Negative values are interpreted as 16-bit numbers,
- so that id -2 maps to 65534 (nobody/nogroup), etc.
- */
- l &= 0xFFFF;
- }
- *id_p = l;
- return 0;
-}
-
-
-static int
-get_uid(
- const char *token,
- uid_t *uid_p)
-{
- struct passwd *passwd;
-
- if (get_id(token, (id_t *)uid_p) == 0)
- goto accept;
- passwd = getpwnam(token);
- if (passwd) {
- *uid_p = passwd->pw_uid;
- goto accept;
- }
- return -1;
-
-accept:
- return 0;
-}
-
-
-static int
-get_gid(
- const char *token,
- gid_t *gid_p)
-{
- struct group *group;
-
- if (get_id(token, (id_t *)gid_p) == 0)
- goto accept;
- group = getgrnam(token);
- if (group) {
- *gid_p = group->gr_gid;
- goto accept;
- }
- return -1;
-
-accept:
- return 0;
-}
-
-
-/*
- Parses the next acl entry in text_p.
-
- Returns:
- -1 on error, 0 on success.
-*/
-
-cmd_t
-parse_acl_cmd(
- const char **text_p,
- int seq_cmd,
- int parse_mode)
-{
- cmd_t cmd = cmd_init();
- char *str;
- const char *backup;
- int error, perm_chars;
- if (!cmd)
- return NULL;
-
- cmd->c_cmd = seq_cmd;
- if (parse_mode & SEQ_PROMOTE_ACL)
- cmd->c_type = ACL_TYPE_DEFAULT;
- else
- cmd->c_type = ACL_TYPE_ACCESS;
- cmd->c_id = ACL_UNDEFINED_ID;
- cmd->c_perm = 0;
-
- if (parse_mode & SEQ_PARSE_DEFAULT) {
- /* check for default acl entry */
- backup = *text_p;
- if (skip_tag_name(text_p, "default")) {
- if (parse_mode & SEQ_PROMOTE_ACL) {
- /* if promoting from acl to default acl and
- a default acl entry is found, fail. */
- *text_p = backup;
- goto fail;
- }
- cmd->c_type = ACL_TYPE_DEFAULT;
- }
- }
-
- /* parse acl entry type */
- switch (**text_p) {
- case 'u': /* user */
- skip_tag_name(text_p, "user");
-
-user_entry:
- backup = *text_p;
- str = get_token(text_p);
- if (str) {
- cmd->c_tag = ACL_USER;
- error = get_uid(unquote(str), &cmd->c_id);
- free(str);
- if (error) {
- *text_p = backup;
- goto fail;
- }
- } else {
- cmd->c_tag = ACL_USER_OBJ;
- }
- break;
-
- case 'g': /* group */
- if (!skip_tag_name(text_p, "group"))
- goto user_entry;
-
- backup = *text_p;
- str = get_token(text_p);
- if (str) {
- cmd->c_tag = ACL_GROUP;
- error = get_gid(unquote(str), &cmd->c_id);
- free(str);
- if (error) {
- *text_p = backup;
- goto fail;
- }
- } else {
- cmd->c_tag = ACL_GROUP_OBJ;
- }
- break;
-
- case 'o': /* other */
- if (!skip_tag_name(text_p, "other"))
- goto user_entry;
- /* skip empty entry qualifier field (this field may
- be missing for compatibility with Solaris.) */
- SKIP_WS(*text_p);
- if (**text_p == ':')
- (*text_p)++;
- cmd->c_tag = ACL_OTHER;
- break;
-
- case 'm': /* mask */
- if (!skip_tag_name(text_p, "mask"))
- goto user_entry;
- /* skip empty entry qualifier field (this field may
- be missing for compatibility with Solaris.) */
- SKIP_WS(*text_p);
- if (**text_p == ':')
- (*text_p)++;
- cmd->c_tag = ACL_MASK;
- break;
-
- default: /* assume "user:" */
- goto user_entry;
- }
-
- SKIP_WS(*text_p);
- if (**text_p == ',' || **text_p == '\0') {
- if (parse_mode & SEQ_PARSE_NO_PERM)
- return cmd;
- else
- goto fail;
- }
- if (!(parse_mode & SEQ_PARSE_WITH_PERM))
- return cmd;
-
- /* parse permissions */
- SKIP_WS(*text_p);
- if (**text_p >= '0' && **text_p <= '7') {
- cmd->c_perm = 0;
- while (**text_p == '0')
- (*text_p)++;
- if (**text_p >= '1' && **text_p <= '7') {
- cmd->c_perm = (*(*text_p)++ - '0');
- }
-
- return cmd;
- }
-
- for (perm_chars=0; perm_chars<3; perm_chars++, (*text_p)++) {
- switch(**text_p) {
- case 'r': /* read */
- if (cmd->c_perm & CMD_PERM_READ)
- goto fail;
- cmd->c_perm |= CMD_PERM_READ;
- break;
-
- case 'w': /* write */
- if (cmd->c_perm & CMD_PERM_WRITE)
- goto fail;
- cmd->c_perm |= CMD_PERM_WRITE;
- break;
-
- case 'x': /* execute */
- if (cmd->c_perm & CMD_PERM_EXECUTE)
- goto fail;
- cmd->c_perm |= CMD_PERM_EXECUTE;
- break;
-
- case 'X': /* execute only if directory or some
- entries already have execute permissions
- set */
- if (cmd->c_perm & CMD_PERM_COND_EXECUTE)
- goto fail;
- cmd->c_perm |= CMD_PERM_COND_EXECUTE;
- break;
-
- case '-':
- /* ignore */
- break;
-
- default:
- if (perm_chars == 0)
- goto fail;
- return cmd;
- }
- }
- if (perm_chars != 3)
- goto fail;
- return cmd;
-
-fail:
- cmd_free(cmd);
- return NULL;
-}
-
-
-/*
- Parse a comma-separated list of acl entries.
-
- which is set to the index of the first character that was not parsed,
- or -1 in case of success.
-*/
-int
-parse_acl_seq(
- seq_t seq,
- const char *text_p,
- int *which,
- int seq_cmd,
- int parse_mode)
-{
- const char *initial_text_p = text_p;
- cmd_t cmd;
-
- if (which)
- *which = -1;
-
- while (*text_p != '\0') {
- cmd = parse_acl_cmd(&text_p, seq_cmd, parse_mode);
- if (cmd == NULL) {
- errno = EINVAL;
- goto fail;
- }
- if (seq_append(seq, cmd) != 0) {
- cmd_free(cmd);
- goto fail;
- }
- SKIP_WS(text_p);
- if (*text_p != ',')
- break;
- text_p++;
- }
-
- if (*text_p != '\0') {
- errno = EINVAL;
- goto fail;
- }
-
- return 0;
-
-fail:
- if (which)
- *which = (text_p - initial_text_p);
- return -1;
-}
-
-
-
-int
-read_acl_comments(
- FILE *file,
- int *line,
- char **path_p,
- uid_t *uid_p,
- gid_t *gid_p,
- mode_t *flags)
-{
- int c;
- /*
- Max PATH_MAX bytes even for UTF-8 path names and additional 9
- bytes for "# file: ". Not a good solution but for now it is the
- best I can do without too much impact on the code. [tw]
- */
- char linebuf[(4*PATH_MAX)+9];
- char *cp;
- char *p;
- int comments_read = 0;
-
- if (path_p)
- *path_p = NULL;
- if (uid_p)
- *uid_p = ACL_UNDEFINED_ID;
- if (gid_p)
- *gid_p = ACL_UNDEFINED_ID;
- if (flags)
- *flags = 0;
-
- for(;;) {
- c = fgetc(file);
- if (c == EOF)
- break;
- if (c==' ' || c=='\t' || c=='\r' || c=='\n') {
- if (c=='\n')
- (*line)++;
- continue;
- }
- if (c != '#') {
- ungetc(c, file);
- break;
- }
- if (line)
- (*line)++;
-
- if (fgets(linebuf, sizeof(linebuf), file) == NULL)
- break;
-
- comments_read = 1;
-
- p = strrchr(linebuf, '\0');
- while (p > linebuf &&
- (*(p-1)=='\r' || *(p-1)=='\n')) {
- p--;
- *p = '\0';
- }
-
- cp = linebuf;
- SKIP_WS(cp);
- if (strncmp(cp, "file:", 5) == 0) {
- cp += 5;
- SKIP_WS(cp);
- cp = unquote(cp);
-
- if (path_p) {
- if (*path_p)
- goto fail;
- *path_p = (char*)malloc(strlen(cp)+1);
- if (!*path_p)
- return -1;
- strcpy(*path_p, cp);
- }
- } else if (strncmp(cp, "owner:", 6) == 0) {
- cp += 6;
- SKIP_WS(cp);
-
- if (uid_p) {
- if (*uid_p != ACL_UNDEFINED_ID)
- goto fail;
- if (get_uid(unquote(cp), uid_p) != 0)
- continue;
- }
- } else if (strncmp(cp, "group:", 6) == 0) {
- cp += 6;
- SKIP_WS(cp);
-
- if (gid_p) {
- if (*gid_p != ACL_UNDEFINED_ID)
- goto fail;
- if (get_gid(unquote(cp), gid_p) != 0)
- continue;
- }
- } else if (strncmp(cp, "flags:", 6) == 0) {
- mode_t f = 0;
-
- cp += 6;
- SKIP_WS(cp);
-
- if (cp[0] == 's')
- f |= S_ISUID;
- else if (cp[0] != '-')
- goto fail;
- if (cp[1] == 's')
- f |= S_ISGID;
- else if (cp[1] != '-')
- goto fail;
- if (cp[2] == 't')
- f |= S_ISVTX;
- else if (cp[2] != '-')
- goto fail;
- if (cp[3] != '\0')
- goto fail;
-
- if (flags)
- *flags = f;
- }
- }
- if (ferror(file))
- return -1;
- return comments_read;
-fail:
- if (path_p && *path_p) {
- free(*path_p);
- *path_p = NULL;
- }
- return -EINVAL;
-}
-
-
-int
-read_acl_seq(
- FILE *file,
- seq_t seq,
- int seq_cmd,
- int parse_mode,
- int *line,
- int *which)
-{
- char linebuf[1024];
- const char *cp;
- cmd_t cmd;
-
- if (which)
- *which = -1;
-
- for(;;) {
- if (fgets(linebuf, sizeof(linebuf), file) == NULL)
- break;
- if (line)
- (*line)++;
-
- cp = linebuf;
- SKIP_WS(cp);
- if (*cp == '\0') {
- if (!(parse_mode & SEQ_PARSE_MULTI))
- continue;
- break;
- } else if (*cp == '#') {
- continue;
- }
-
- cmd = parse_acl_cmd(&cp, seq_cmd, parse_mode);
- if (cmd == NULL) {
- errno = EINVAL;
- goto fail;
- }
- if (seq_append(seq, cmd) != 0) {
- cmd_free(cmd);
- goto fail;
- }
-
- SKIP_WS(cp);
- if (*cp != '\0' && *cp != '#') {
- errno = EINVAL;
- goto fail;
- }
- }
-
- if (ferror(file))
- goto fail;
- return 0;
-
-fail:
- if (which)
- *which = (cp - linebuf);
- return -1;
-}
-
diff --git a/setfacl/parse.h b/setfacl/parse.h
deleted file mode 100644
index b2e68b4..0000000
--- a/setfacl/parse.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- File: parse.h
- (Linux Access Control List Management)
-
- Copyright (C) 1999 by Andreas Gruenbacher
- <a.gruenbacher@computer.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __PARSE_H
-#define __PARSE_H
-
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include "sequence.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* parse options */
-
-#define SEQ_PARSE_WITH_PERM (0x0001)
-#define SEQ_PARSE_NO_PERM (0x0002)
-#define SEQ_PARSE_ANY_PERM (0x0001|0x0002)
-
-#define SEQ_PARSE_MULTI (0x0010)
-#define SEQ_PARSE_DEFAULT (0x0020) /* "default:" = default acl */
-
-#define SEQ_PROMOTE_ACL (0x0040) /* promote from acl
- to default acl */
-
-cmd_t
-parse_acl_cmd(
- const char **text_p,
- int seq_cmd,
- int parse_mode);
-int
-parse_acl_seq(
- seq_t seq,
- const char *text_p,
- int *which,
- int seq_cmd,
- int parse_mode);
-int
-read_acl_comments(
- FILE *file,
- int *line,
- char **path_p,
- uid_t *uid_p,
- gid_t *gid_p,
- mode_t *flags);
-int
-read_acl_seq(
- FILE *file,
- seq_t seq,
- int seq_cmd,
- int parse_mode,
- int *line,
- int *which);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* __PARSE_H */
-
diff --git a/setfacl/sequence.c b/setfacl/sequence.c
deleted file mode 100644
index a418b23..0000000
--- a/setfacl/sequence.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- File: sequence.c
- (Linux Access Control List Management)
-
- Copyright (C) 1999, 2000
- Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include <stdlib.h>
-#include "sequence.h"
-
-
-cmd_t
-cmd_init(
- void)
-{
- return (cmd_t)malloc(sizeof(struct cmd_obj));
-}
-
-
-void
-cmd_free(
- cmd_t cmd)
-{
- free(cmd);
-}
-
-
-seq_t
-seq_init(
- void)
-{
- seq_t seq = (seq_t)malloc(sizeof(struct seq_obj));
- if (seq == NULL)
- return NULL;
- seq->s_first = seq->s_last = NULL;
- return seq;
-}
-
-
-int
-seq_free(
- seq_t seq)
-{
- cmd_t cmd = seq->s_first;
- while (cmd) {
- seq->s_first = seq->s_first->c_next;
- cmd_free(cmd);
- cmd = seq->s_first;
- }
- free(seq);
- return 0;
-}
-
-
-int
-seq_empty(
- seq_t seq)
-{
- return (seq->s_first == NULL);
-}
-
-
-int
-seq_append(
- seq_t seq,
- cmd_t cmd)
-{
- cmd->c_next = NULL;
- if (seq->s_first == NULL) {
- seq->s_first = seq->s_last = cmd;
- } else {
- seq->s_last->c_next = cmd;
- seq->s_last = cmd;
- }
- return 0;
-}
-
-
-int
-seq_append_cmd(
- seq_t seq,
- cmd_tag_t cmd,
- acl_type_t type)
-{
- cmd_t cmd_d = cmd_init();
- if (cmd_d == NULL)
- return -1;
- cmd_d->c_cmd = cmd;
- cmd_d->c_type = type;
- if (seq_append(seq, cmd_d) != 0) {
- cmd_free(cmd_d);
- return -1;
- }
- return 0;
-}
-
-
-int
-seq_get_cmd(
- seq_t seq,
- int which,
- cmd_t *cmd)
-{
- if (which == SEQ_FIRST_CMD) {
- if (seq->s_first == NULL)
- return 0;
- if (cmd)
- *cmd = seq->s_first;
- return 1;
- } else if (which == SEQ_NEXT_CMD) {
- if (cmd == NULL)
- return -1;
- if (*cmd) {
- *cmd = (*cmd)->c_next;
- return (*cmd == NULL) ? 0 : 1;
- }
- return 0;
- } else {
- return -1;
- }
-}
-
-
-int
-seq_delete_cmd(
- seq_t seq,
- cmd_t cmd)
-{
- cmd_t prev = seq->s_first;
-
- if (cmd == seq->s_first) {
- seq->s_first = seq->s_first->c_next;
- cmd_free(cmd);
- return 0;
- }
- while (prev != NULL && prev->c_next != cmd)
- prev = prev->c_next;
- if (prev == NULL)
- return -1;
- if (cmd == seq->s_last)
- seq->s_last = prev;
- prev->c_next = cmd->c_next;
- cmd_free(cmd);
- return 0;
-}
-
diff --git a/setfacl/sequence.h b/setfacl/sequence.h
deleted file mode 100644
index c5d7403..0000000
--- a/setfacl/sequence.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- File: sequence.h
- (Linux Access Control List Management)
-
- Copyright (C) 1999 by Andreas Gruenbacher
- <a.gruenbacher@computer.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __SEQUENCE_H
-#define __SEQUENCE_H
-
-
-#include <sys/acl.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef unsigned int cmd_tag_t;
-
-struct cmd_obj {
- cmd_tag_t c_cmd;
- acl_type_t c_type;
- acl_tag_t c_tag;
- uid_t c_id;
- mode_t c_perm;
- struct cmd_obj *c_next;
-};
-
-typedef struct cmd_obj *cmd_t;
-
-struct seq_obj {
- cmd_t s_first;
- cmd_t s_last;
-};
-
-typedef struct seq_obj *seq_t;
-
-/* command types */
-#define CMD_ENTRY_REPLACE (0)
-#define CMD_REMOVE_ENTRY (3)
-#define CMD_REMOVE_EXTENDED_ACL (4)
-#define CMD_REMOVE_ACL (5)
-
-/* constants for permission specifiers */
-#define CMD_PERM_READ (4)
-#define CMD_PERM_WRITE (2)
-#define CMD_PERM_EXECUTE (1)
-#define CMD_PERM_COND_EXECUTE (8)
-
-/* iteration over command sequence */
-#define SEQ_FIRST_CMD (0)
-#define SEQ_NEXT_CMD (1)
-
-/* command sequence manipulation */
-
-cmd_t
-cmd_init(
- void);
-void
-cmd_free(
- cmd_t cmd);
-seq_t
-seq_init(
- void);
-int
-seq_free(
- seq_t seq);
-int
-seq_empty(
- seq_t seq);
-int
-seq_append(
- seq_t seq,
- cmd_t cmd);
-int
-seq_append_cmd(
- seq_t seq,
- cmd_tag_t cmd,
- acl_type_t type);
-int
-seq_get_cmd(
- seq_t seq,
- int which,
- cmd_t *cmd);
-int
-seq_delete_cmd(
- seq_t seq,
- cmd_t cmd);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* __SEQUENCE_H */
-
diff --git a/setfacl/setfacl.c b/setfacl/setfacl.c
deleted file mode 100644
index f6135b7..0000000
--- a/setfacl/setfacl.c
+++ /dev/null
@@ -1,669 +0,0 @@
-/*
- File: setfacl.c
- (Linux Access Control List Management)
-
- Copyright (C) 1999-2002
- Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "config.h"
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <libgen.h>
-#include <getopt.h>
-#include "misc.h"
-#include "sequence.h"
-#include "parse.h"
-#include "do_set.h"
-#include "walk_tree.h"
-
-#define POSIXLY_CORRECT_STR "POSIXLY_CORRECT"
-
-/* '-' stands for `process non-option arguments in loop' */
-#if !POSIXLY_CORRECT
-# define CMD_LINE_OPTIONS "-:bkndvhm:M:x:X:RLP"
-# define CMD_LINE_SPEC "[-bkndRLP] { -m|-M|-x|-X ... } file ..."
-#endif
-#define POSIXLY_CMD_LINE_OPTIONS "-:bkndvhm:M:x:X:"
-#define POSIXLY_CMD_LINE_SPEC "[-bknd] {-m|-M|-x|-X ... } file ..."
-
-struct option long_options[] = {
-#if !POSIXLY_CORRECT
- { "set", 1, 0, 's' },
- { "set-file", 1, 0, 'S' },
-
- { "mask", 0, 0, 'r' },
- { "recursive", 0, 0, 'R' },
- { "logical", 0, 0, 'L' },
- { "physical", 0, 0, 'P' },
- { "restore", 1, 0, 'B' },
- { "test", 0, 0, 't' },
-#endif
- { "modify", 1, 0, 'm' },
- { "modify-file", 1, 0, 'M' },
- { "remove", 1, 0, 'x' },
- { "remove-file", 1, 0, 'X' },
-
- { "default", 0, 0, 'd' },
- { "no-mask", 0, 0, 'n' },
- { "remove-all", 0, 0, 'b' },
- { "remove-default", 0, 0, 'k' },
- { "version", 0, 0, 'v' },
- { "help", 0, 0, 'h' },
- { NULL, 0, 0, 0 },
-};
-
-const char *progname;
-const char *cmd_line_options, *cmd_line_spec;
-
-int walk_flags = WALK_TREE_DEREFERENCE_TOPLEVEL;
-int opt_recalculate; /* recalculate mask entry (0=default, 1=yes, -1=no) */
-int opt_promote; /* promote access ACL to default ACL */
-int opt_test; /* do not write to the file system.
- Print what would happen instead. */
-#if POSIXLY_CORRECT
-const int posixly_correct = 1; /* Posix compatible behavior! */
-#else
-int posixly_correct; /* Posix compatible behavior? */
-#endif
-int chown_error;
-int promote_warning;
-
-
-static const char *xquote(const char *str, const char *quote_chars)
-{
- const char *q = quote(str, quote_chars);
- if (q == NULL) {
- fprintf(stderr, "%s: %s\n", progname, strerror(errno));
- exit(1);
- }
- return q;
-}
-
-int
-has_any_of_type(
- cmd_t cmd,
- acl_type_t acl_type)
-{
- while (cmd) {
- if (cmd->c_type == acl_type)
- return 1;
- cmd = cmd->c_next;
- }
- return 0;
-}
-
-
-#if !POSIXLY_CORRECT
-int
-restore(
- FILE *file,
- const char *filename)
-{
- char *path_p;
- struct stat st;
- uid_t uid;
- gid_t gid;
- mode_t mask, flags;
- struct do_set_args args = { };
- int line = 0, backup_line;
- int error, status = 0;
- int chmod_required = 0;
-
- memset(&st, 0, sizeof(st));
-
- for(;;) {
- backup_line = line;
- error = read_acl_comments(file, &line, &path_p, &uid, &gid,
- &flags);
- if (error < 0) {
- error = -error;
- goto fail;
- }
- if (error == 0)
- return status;
-
- if (path_p == NULL) {
- if (filename) {
- fprintf(stderr, _("%s: %s: No filename found "
- "in line %d, aborting\n"),
- progname, xquote(filename, "\n\r"),
- backup_line);
- } else {
- fprintf(stderr, _("%s: No filename found in "
- "line %d of standard input, "
- "aborting\n"),
- progname, backup_line);
- }
- status = 1;
- goto getout;
- }
-
- if (!(args.seq = seq_init()))
- goto fail_errno;
- if (seq_append_cmd(args.seq, CMD_REMOVE_ACL, ACL_TYPE_ACCESS) ||
- seq_append_cmd(args.seq, CMD_REMOVE_ACL, ACL_TYPE_DEFAULT))
- goto fail_errno;
-
- error = read_acl_seq(file, args.seq, CMD_ENTRY_REPLACE,
- SEQ_PARSE_WITH_PERM |
- SEQ_PARSE_DEFAULT |
- SEQ_PARSE_MULTI,
- &line, NULL);
- if (error != 0) {
- fprintf(stderr, _("%s: %s: %s in line %d\n"),
- progname, xquote(filename, "\n\r"), strerror(errno),
- line);
- status = 1;
- goto getout;
- }
-
- error = stat(path_p, &st);
- if (opt_test && error != 0) {
- fprintf(stderr, "%s: %s: %s\n", progname,
- xquote(path_p, "\n\r"), strerror(errno));
- status = 1;
- }
-
- args.mode = 0;
- error = do_set(path_p, &st, 0, &args);
- if (error != 0) {
- status = 1;
- goto resume;
- }
-
- if (uid != ACL_UNDEFINED_ID && uid != st.st_uid)
- st.st_uid = uid;
- else
- st.st_uid = -1;
- if (gid != ACL_UNDEFINED_ID && gid != st.st_gid)
- st.st_gid = gid;
- else
- st.st_gid = -1;
- if (!opt_test &&
- (st.st_uid != -1 || st.st_gid != -1)) {
- if (chown(path_p, st.st_uid, st.st_gid) != 0) {
- fprintf(stderr, _("%s: %s: Cannot change "
- "owner/group: %s\n"),
- progname, xquote(path_p, "\n\r"),
- strerror(errno));
- status = 1;
- }
-
- /* chown() clears setuid/setgid so force a chmod if
- * S_ISUID/S_ISGID was expected */
- if ((st.st_mode & flags) & (S_ISUID | S_ISGID))
- chmod_required = 1;
- }
-
- mask = S_ISUID | S_ISGID | S_ISVTX;
- if (chmod_required || ((st.st_mode & mask) != (flags & mask))) {
- if (!args.mode)
- args.mode = st.st_mode;
- args.mode &= (S_IRWXU | S_IRWXG | S_IRWXO);
- if (chmod(path_p, flags | args.mode) != 0) {
- fprintf(stderr, _("%s: %s: Cannot change "
- "mode: %s\n"),
- progname, xquote(path_p, "\n\r"),
- strerror(errno));
- status = 1;
- }
- }
-resume:
- if (path_p) {
- free(path_p);
- path_p = NULL;
- }
- if (args.seq) {
- seq_free(args.seq);
- args.seq = NULL;
- }
- }
-
-getout:
- if (path_p) {
- free(path_p);
- path_p = NULL;
- }
- if (args.seq) {
- seq_free(args.seq);
- args.seq = NULL;
- }
- return status;
-
-fail_errno:
- error = errno;
-fail:
- fprintf(stderr, "%s: %s: %s\n", progname, xquote(filename, "\n\r"),
- strerror(error));
- status = 1;
- goto getout;
-}
-#endif
-
-
-void help(void)
-{
- printf(_("%s %s -- set file access control lists\n"),
- progname, VERSION);
- printf(_("Usage: %s %s\n"),
- progname, cmd_line_spec);
- printf(_(
-" -m, --modify=acl modify the current ACL(s) of file(s)\n"
-" -M, --modify-file=file read ACL entries to modify from file\n"
-" -x, --remove=acl remove entries from the ACL(s) of file(s)\n"
-" -X, --remove-file=file read ACL entries to remove from file\n"
-" -b, --remove-all remove all extended ACL entries\n"
-" -k, --remove-default remove the default ACL\n"));
-#if !POSIXLY_CORRECT
- if (!posixly_correct) {
- printf(_(
-" --set=acl set the ACL of file(s), replacing the current ACL\n"
-" --set-file=file read ACL entries to set from file\n"
-" --mask do recalculate the effective rights mask\n"));
- }
-#endif
- printf(_(
-" -n, --no-mask don't recalculate the effective rights mask\n"
-" -d, --default operations apply to the default ACL\n"));
-#if !POSIXLY_CORRECT
- if (!posixly_correct) {
- printf(_(
-" -R, --recursive recurse into subdirectories\n"
-" -L, --logical logical walk, follow symbolic links\n"
-" -P, --physical physical walk, do not follow symbolic links\n"
-" --restore=file restore ACLs (inverse of `getfacl -R')\n"
-" --test test mode (ACLs are not modified)\n"));
- }
-#endif
- printf(_(
-" -v, --version print version and exit\n"
-" -h, --help this help text\n"));
-}
-
-
-int next_file(const char *arg, seq_t seq)
-{
- char *line;
- int errors = 0;
- struct do_set_args args;
-
- args.seq = seq;
-
- if (strcmp(arg, "-") == 0) {
- while ((line = next_line(stdin)))
- errors = walk_tree(line, walk_flags, 0, do_set, &args);
- if (!feof(stdin)) {
- fprintf(stderr, _("%s: Standard input: %s\n"),
- progname, strerror(errno));
- errors = 1;
- }
- } else {
- errors = walk_tree(arg, walk_flags, 0, do_set, &args);
- }
- return errors ? 1 : 0;
-}
-
-
-#define ERRNO_ERROR(s) \
- ({status = (s); goto errno_error; })
-
-
-int main(int argc, char *argv[])
-{
- int opt;
- int saw_files = 0;
- int status = 0;
- FILE *file;
- int which;
- int lineno;
- int error;
- seq_t seq;
- int seq_cmd, parse_mode;
-
- progname = basename(argv[0]);
-
-#if POSIXLY_CORRECT
- cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
- cmd_line_spec = _(POSIXLY_CMD_LINE_SPEC);
-#else
- if (getenv(POSIXLY_CORRECT_STR))
- posixly_correct = 1;
- if (!posixly_correct) {
- cmd_line_options = CMD_LINE_OPTIONS;
- cmd_line_spec = _(CMD_LINE_SPEC);
- } else {
- cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
- cmd_line_spec = _(POSIXLY_CMD_LINE_SPEC);
- }
-#endif
-
- setlocale(LC_CTYPE, "");
- setlocale(LC_MESSAGES, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- seq = seq_init();
- if (!seq)
- ERRNO_ERROR(1);
-
- while ((opt = getopt_long(argc, argv, cmd_line_options,
- long_options, NULL)) != -1) {
- /* we remember the two REMOVE_ACL commands of the set
- operations because we may later need to delete them. */
- cmd_t seq_remove_default_acl_cmd = NULL;
- cmd_t seq_remove_acl_cmd = NULL;
-
- if (opt != '\1' && saw_files) {
- seq_free(seq);
- seq = seq_init();
- if (!seq)
- ERRNO_ERROR(1);
- saw_files = 0;
- }
-
- switch (opt) {
- case 'b': /* remove all extended entries */
- if (seq_append_cmd(seq, CMD_REMOVE_EXTENDED_ACL,
- ACL_TYPE_ACCESS) ||
- seq_append_cmd(seq, CMD_REMOVE_ACL,
- ACL_TYPE_DEFAULT))
- ERRNO_ERROR(1);
- break;
-
- case 'k': /* remove default ACL */
- if (seq_append_cmd(seq, CMD_REMOVE_ACL,
- ACL_TYPE_DEFAULT))
- ERRNO_ERROR(1);
- break;
-
- case 'n': /* do not recalculate mask */
- opt_recalculate = -1;
- break;
-
- case 'r': /* force recalculate mask */
- opt_recalculate = 1;
- break;
-
- case 'd': /* operations apply to default ACL */
- opt_promote = 1;
- break;
-
- case 's': /* set */
- if (seq_append_cmd(seq, CMD_REMOVE_ACL,
- ACL_TYPE_ACCESS))
- ERRNO_ERROR(1);
- seq_remove_acl_cmd = seq->s_last;
- if (seq_append_cmd(seq, CMD_REMOVE_ACL,
- ACL_TYPE_DEFAULT))
- ERRNO_ERROR(1);
- seq_remove_default_acl_cmd = seq->s_last;
-
- seq_cmd = CMD_ENTRY_REPLACE;
- parse_mode = SEQ_PARSE_WITH_PERM;
- goto set_modify_delete;
-
- case 'm': /* modify */
- seq_cmd = CMD_ENTRY_REPLACE;
- parse_mode = SEQ_PARSE_WITH_PERM;
- goto set_modify_delete;
-
- case 'x': /* delete */
- seq_cmd = CMD_REMOVE_ENTRY;
-#if POSIXLY_CORRECT
- parse_mode = SEQ_PARSE_ANY_PERM;
-#else
- if (posixly_correct)
- parse_mode = SEQ_PARSE_ANY_PERM;
- else
- parse_mode = SEQ_PARSE_NO_PERM;
-#endif
- goto set_modify_delete;
-
- set_modify_delete:
- if (!posixly_correct)
- parse_mode |= SEQ_PARSE_DEFAULT;
- if (opt_promote)
- parse_mode |= SEQ_PROMOTE_ACL;
- if (parse_acl_seq(seq, optarg, &which,
- seq_cmd, parse_mode) != 0) {
- if (which < 0 ||
- (size_t) which >= strlen(optarg)) {
- fprintf(stderr, _(
- "%s: Option "
- "-%c incomplete\n"),
- progname, opt);
- } else {
- fprintf(stderr, _(
- "%s: Option "
- "-%c: %s near "
- "character %d\n"),
- progname, opt,
- strerror(errno),
- which+1);
- }
- status = 2;
- goto cleanup;
- }
- break;
-
- case 'S': /* set from file */
- if (seq_append_cmd(seq, CMD_REMOVE_ACL,
- ACL_TYPE_ACCESS))
- ERRNO_ERROR(1);
- seq_remove_acl_cmd = seq->s_last;
- if (seq_append_cmd(seq, CMD_REMOVE_ACL,
- ACL_TYPE_DEFAULT))
- ERRNO_ERROR(1);
- seq_remove_default_acl_cmd = seq->s_last;
-
- seq_cmd = CMD_ENTRY_REPLACE;
- parse_mode = SEQ_PARSE_WITH_PERM;
- goto set_modify_delete_from_file;
-
- case 'M': /* modify from file */
- seq_cmd = CMD_ENTRY_REPLACE;
- parse_mode = SEQ_PARSE_WITH_PERM;
- goto set_modify_delete_from_file;
-
- case 'X': /* delete from file */
- seq_cmd = CMD_REMOVE_ENTRY;
-#if POSIXLY_CORRECT
- parse_mode = SEQ_PARSE_ANY_PERM;
-#else
- if (posixly_correct)
- parse_mode = SEQ_PARSE_ANY_PERM;
- else
- parse_mode = SEQ_PARSE_NO_PERM;
-#endif
- goto set_modify_delete_from_file;
-
- set_modify_delete_from_file:
- if (!posixly_correct)
- parse_mode |= SEQ_PARSE_DEFAULT;
- if (opt_promote)
- parse_mode |= SEQ_PROMOTE_ACL;
- if (strcmp(optarg, "-") == 0) {
- file = stdin;
- } else {
- file = fopen(optarg, "r");
- if (file == NULL) {
- fprintf(stderr, "%s: %s: %s\n",
- progname,
- xquote(optarg, "\n\r"),
- strerror(errno));
- status = 2;
- goto cleanup;
- }
- }
-
- lineno = 0;
- error = read_acl_seq(file, seq, seq_cmd,
- parse_mode, &lineno, NULL);
-
- if (file != stdin) {
- fclose(file);
- }
-
- if (error) {
- if (!errno)
- errno = EINVAL;
-
- if (file != stdin) {
- fprintf(stderr, _(
- "%s: %s in line "
- "%d of file %s\n"),
- progname,
- strerror(errno),
- lineno,
- xquote(optarg, "\n\r"));
- } else {
- fprintf(stderr, _(
- "%s: %s in line "
- "%d of standard "
- "input\n"), progname,
- strerror(errno),
- lineno);
- }
- status = 2;
- goto cleanup;
- }
- break;
-
-
- case '\1': /* file argument */
- if (seq_empty(seq))
- goto synopsis;
- saw_files = 1;
-
- status = next_file(optarg, seq);
- break;
-
- case 'B': /* restore ACL backup */
- saw_files = 1;
-
- if (strcmp(optarg, "-") == 0)
- file = stdin;
- else {
- file = fopen(optarg, "r");
- if (file == NULL) {
- fprintf(stderr, "%s: %s: %s\n",
- progname,
- xquote(optarg, "\n\r"),
- strerror(errno));
- status = 2;
- goto cleanup;
- }
- }
-
- status = restore(file,
- (file == stdin) ? NULL : optarg);
-
- if (file != stdin)
- fclose(file);
- if (status != 0)
- goto cleanup;
- break;
-
- case 'R': /* recursive */
- walk_flags |= WALK_TREE_RECURSIVE;
- break;
-
- case 'L': /* follow symlinks */
- walk_flags |= WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE;
- walk_flags &= ~WALK_TREE_PHYSICAL;
- break;
-
- case 'P': /* do not follow symlinks */
- walk_flags |= WALK_TREE_PHYSICAL;
- walk_flags &= ~(WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE |
- WALK_TREE_DEREFERENCE_TOPLEVEL);
- break;
-
- case 't': /* test mode */
- opt_test = 1;
- break;
-
- case 'v': /* print version and exit */
- printf("%s " VERSION "\n", progname);
- status = 0;
- goto cleanup;
-
- case 'h': /* help! */
- help();
- status = 0;
- goto cleanup;
-
- case ':': /* option missing */
- case '?': /* unknown option */
- default:
- goto synopsis;
- }
- if (seq_remove_acl_cmd) {
- /* This was a set operation. Check if there are
- actually entries of ACL_TYPE_ACCESS; if there
- are none, we need to remove this command! */
- if (!has_any_of_type(seq_remove_acl_cmd->c_next,
- ACL_TYPE_ACCESS))
- seq_delete_cmd(seq, seq_remove_acl_cmd);
- }
- if (seq_remove_default_acl_cmd) {
- /* This was a set operation. Check if there are
- actually entries of ACL_TYPE_DEFAULT; if there
- are none, we need to remove this command! */
- if (!has_any_of_type(seq_remove_default_acl_cmd->c_next,
- ACL_TYPE_DEFAULT))
- seq_delete_cmd(seq, seq_remove_default_acl_cmd);
- }
- }
- while (optind < argc) {
- if(!seq)
- goto synopsis;
- if (seq_empty(seq))
- goto synopsis;
- saw_files = 1;
-
- status = next_file(argv[optind++], seq);
- }
- if (!saw_files)
- goto synopsis;
-
- goto cleanup;
-
-synopsis:
- fprintf(stderr, _("Usage: %s %s\n"),
- progname, cmd_line_spec);
- fprintf(stderr, _("Try `%s --help' for more information.\n"),
- progname);
- status = 2;
- goto cleanup;
-
-errno_error:
- fprintf(stderr, "%s: %s\n", progname, strerror(errno));
- goto cleanup;
-
-cleanup:
- if (seq)
- seq_free(seq);
- return status;
-}
-
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000..e6e5019
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1 @@
+*.dir/
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index d2baac8..0000000
--- a/test/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-TESTS = $(wildcard *.test)
-ROOT = $(wildcard root/*.test)
-NFS = $(wildcard nfs/*.test)
-LSRCFILES = sort-getfacl-output run make-tree $(TESTS) $(ROOT) $(NFS) \
- malformed-restore-double-owner.acl
-
-include $(BUILDRULES)
-
-default install install-dev install-lib:
-
-PATH := $(abspath ../getfacl/):$(abspath ../setfacl/):$(abspath ../chacl/):$(PATH)
-
-tests: $(TESTS)
-root-tests: $(ROOT)
-nfs-tests: $(NFS)
-
-$(TESTS):
- @echo "*** $@ ***"; perl run $@
-
-$(NFS):
- @echo "NFS specific tests"; echo "*** $@ ***"; perl run $@
-
-$(ROOT):
- @echo "Note: Tests must run as root"; echo "*** $@ ***"; perl run $@
-
-.PHONY: $(TESTS) $(NFS) $(ROOT)
-.NOTPARALLEL:
-
-
diff --git a/test/Makemodule.am b/test/Makemodule.am
new file mode 100644
index 0000000..7b8dafe
--- /dev/null
+++ b/test/Makemodule.am
@@ -0,0 +1,27 @@
+XFAIL_TESTS = \
+ test/nfs/nfsacl.test \
+ test/nfs/nfs-dir.test
+TESTS = \
+ test/cp.test \
+ test/getfacl-noacl.test \
+ test/getfacl-recursive.test \
+ test/malformed-restore.test \
+ test/misc.test \
+ test/sbits-restore.test \
+ test/setfacl-X.test \
+ test/utf8-filenames.test \
+ test/root/getfacl.test \
+ test/root/permissions.test \
+ test/root/restore.test \
+ test/root/setfacl.test \
+ $(XFAIL_TESTS)
+
+EXTRA_DIST += \
+ test/make-tree \
+ test/malformed-restore-double-owner.acl \
+ test/run \
+ test/sort-getfacl-output \
+ $(TESTS)
+
+AM_TESTS_ENVIRONMENT = PATH="$(abs_top_builddir):$$PATH";
+TEST_LOG_COMPILER = $(srcdir)/test/run
diff --git a/test/root/getfacl.test b/test/root/getfacl.test
index f84e25d..649ebae 100644
--- a/test/root/getfacl.test
+++ b/test/root/getfacl.test
@@ -1,6 +1,10 @@
Make sure that getfacl always adds at least one space between the permissions
in an acl entry and the effective permissions comment.
+Cry immediately if we are not running as root.
+
+ $ require_root
+
$ umask 022
$ mkdir d
$ groupadd loooooooooooooooooooooooonggroup
diff --git a/test/root/permissions.test b/test/root/permissions.test
index afaf5f0..9b9e3de 100644
--- a/test/root/permissions.test
+++ b/test/root/permissions.test
@@ -9,8 +9,7 @@ listed in parentheses.
Cry immediately if we are not running as root.
- $ id -u
- > 0
+ $ require_root
First, set up a temporary directory and create a regular file with
diff --git a/test/root/restore.test b/test/root/restore.test
index 6003cd4..63a9d01 100644
--- a/test/root/restore.test
+++ b/test/root/restore.test
@@ -1,6 +1,10 @@
Ensure setuid bit is restored when the owner changes
https://bugzilla.redhat.com/show_bug.cgi?id=467936#c7
+Cry immediately if we are not running as root.
+
+ $ require_root
+
$ touch passwd
$ chmod 755 passwd
$ chmod u+s passwd
diff --git a/test/root/setfacl.test b/test/root/setfacl.test
index 630e9fb..a46a9f4 100644
--- a/test/root/setfacl.test
+++ b/test/root/setfacl.test
@@ -1,5 +1,9 @@
Setfacl utility tests. Run these tests on a filesystem with ACL support.
+Cry immediately if we are not running as root.
+
+ $ require_root
+
$ mkdir d
$ chown bin:bin d
$ cd d
diff --git a/test/run b/test/run
index 0a12be6..fcbcf29 100755
--- a/test/run
+++ b/test/run
@@ -268,6 +268,14 @@ sub exec_test($$) {
return su($prog->[1]);
} elsif ($prog->[0] eq "sg") {
return sg($prog->[1]);
+ } elsif ($prog->[0] eq "require_root") {
+ my $ret = su("root");
+ if ($! != 0) {
+ print $ret->[0];
+ warn "required root failed; skipping test";
+ exit 77;
+ }
+ return [];
} elsif ($prog->[0] eq "export") {
my ($name, $value) = split /=/, $prog->[1];
# FIXME: need to evaluate $value, so that things like this will work:
diff --git a/tools/Makemodule.am b/tools/Makemodule.am
new file mode 100644
index 0000000..60a9a2d
--- /dev/null
+++ b/tools/Makemodule.am
@@ -0,0 +1,23 @@
+tools_ldadd = $(LDADD) libacl.la libmisc.la
+
+bin_PROGRAMS += chacl
+chacl_SOURCES = tools/chacl.c
+chacl_LDADD = $(tools_ldadd)
+
+bin_PROGRAMS += getfacl
+getfacl_SOURCES = \
+ tools/getfacl.c \
+ tools/user_group.c \
+ tools/user_group.h
+getfacl_LDADD = $(tools_ldadd)
+
+bin_PROGRAMS += setfacl
+setfacl_SOURCES = \
+ tools/do_set.c \
+ tools/do_set.h \
+ tools/parse.c \
+ tools/parse.h \
+ tools/sequence.c \
+ tools/sequence.h \
+ tools/setfacl.c
+setfacl_LDADD = $(tools_ldadd)
diff --git a/tools/chacl.c b/tools/chacl.c
new file mode 100644
index 0000000..525a7ff
--- /dev/null
+++ b/tools/chacl.c
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2001-2002 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/acl.h>
+#include <acl/libacl.h>
+#include "misc.h"
+
+static int acl_delete_file (const char * path, acl_type_t type);
+static int list_acl(char *file);
+static int set_acl(acl_t acl, acl_t dacl, const char *fname);
+static int walk_dir(acl_t acl, acl_t dacl, const char *fname);
+
+static char *program;
+static int rflag;
+
+static void
+usage(void)
+{
+ fprintf(stderr, _("Usage:\n"));
+ fprintf(stderr, _("\t%s acl pathname...\n"), program);
+ fprintf(stderr, _("\t%s -b acl dacl pathname...\n"), program);
+ fprintf(stderr, _("\t%s -d dacl pathname...\n"), program);
+ fprintf(stderr, _("\t%s -R pathname...\n"), program);
+ fprintf(stderr, _("\t%s -D pathname...\n"), program);
+ fprintf(stderr, _("\t%s -B pathname...\n"), program);
+ fprintf(stderr, _("\t%s -l pathname...\t[not IRIX compatible]\n"),
+ program);
+ fprintf(stderr, _("\t%s -r pathname...\t[not IRIX compatible]\n"),
+ program);
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *file;
+ int switch_flag = 0; /* ensure only one switch is used */
+ int args_required = 2;
+ int failed = 0; /* exit status */
+ int c; /* For use by getopt(3) */
+ int dflag = 0; /* a Default ACL is desired */
+ int bflag = 0; /* a both ACLs are desired */
+ int Rflag = 0; /* set to true to remove an acl */
+ int Dflag = 0; /* set to true to remove default acls */
+ int Bflag = 0; /* set to true to remove both acls */
+ int lflag = 0; /* set to true to list acls */
+ acl_t acl = NULL; /* File ACL */
+ acl_t dacl = NULL; /* Directory Default ACL */
+
+ program = basename(argv[0]);
+
+ setlocale(LC_CTYPE, "");
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ /* parse arguments */
+ while ((c = getopt(argc, argv, "bdlRDBr")) != -1) {
+ if (switch_flag)
+ usage();
+ switch_flag = 1;
+
+ switch (c) {
+ case 'b':
+ bflag = 1;
+ args_required = 3;
+ break;
+ case 'd':
+ dflag = 1;
+ args_required = 2;
+ break;
+ case 'R':
+ Rflag = 1;
+ args_required = 1;
+ break;
+ case 'D':
+ Dflag = 1;
+ args_required = 1;
+ break;
+ case 'B':
+ Bflag = 1;
+ args_required = 1;
+ break;
+ case 'l':
+ lflag = 1;
+ args_required = 1;
+ break;
+ case 'r':
+ rflag = 1;
+ args_required = 1;
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+
+ /* if not enough arguments quit */
+ if ((argc - optind) < args_required)
+ usage();
+
+ /* list the acls */
+ if (lflag) {
+ for (; optind < argc; optind++) {
+ file = argv[optind];
+ if (!list_acl(file))
+ failed++;
+ }
+ return(failed);
+ }
+
+ /* remove the acls */
+ if (Rflag || Dflag || Bflag) {
+ for (; optind < argc; optind++) {
+ file = argv[optind];
+ if (!Dflag &&
+ (acl_delete_file(file, ACL_TYPE_ACCESS) == -1)) {
+ fprintf(stderr, _(
+ "%s: error removing access acl on \"%s\": %s\n"),
+ program, file, strerror(errno));
+ failed++;
+ }
+ if (!Rflag &&
+ (acl_delete_file(file, ACL_TYPE_DEFAULT) == -1)) {
+ fprintf(stderr, _(
+ "%s: error removing default acl on \"%s\": %s\n"),
+ program, file, strerror(errno));
+ failed++;
+ }
+ }
+ return(failed);
+ }
+
+ /* file access acl */
+ if (! dflag) {
+ acl = acl_from_text(argv[optind]);
+ failed = acl_check(acl, &c);
+ if (failed < 0) {
+ fprintf(stderr, "%s: %s - %s\n",
+ program, argv[optind], strerror(errno));
+ return 1;
+ }
+ else if (failed > 0) {
+ fprintf(stderr, _(
+ "%s: access ACL '%s': %s at entry %d\n"),
+ program, argv[optind], acl_error(failed), c);
+ return 1;
+ }
+ optind++;
+ }
+
+
+ /* directory default acl */
+ if (bflag || dflag) {
+ dacl = acl_from_text(argv[optind]);
+ failed = acl_check(dacl, &c);
+ if (failed < 0) {
+ fprintf(stderr, "%s: %s - %s\n",
+ program, argv[optind], strerror(errno));
+ return 1;
+ }
+ else if (failed > 0) {
+ fprintf(stderr, _(
+ "%s: access ACL '%s': %s at entry %d\n"),
+ program, argv[optind], acl_error(failed), c);
+ return 1;
+ }
+ optind++;
+ }
+
+ /* place acls on files */
+ for (; optind < argc; optind++)
+ failed += set_acl(acl, dacl, argv[optind]);
+
+ if (acl)
+ acl_free(acl);
+ if (dacl)
+ acl_free(dacl);
+
+ return(failed);
+}
+
+/*
+ * deletes an access acl or directory default acl if one exists
+ */
+static int
+acl_delete_file(const char *path, acl_type_t type)
+{
+ int error = 0;
+
+ /* converts access ACL to a minimal ACL */
+ if (type == ACL_TYPE_ACCESS) {
+ acl_t acl;
+ acl_entry_t entry;
+ acl_tag_t tag;
+
+ acl = acl_get_file(path, ACL_TYPE_ACCESS);
+ if (!acl)
+ return -1;
+ error = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry);
+ while (error == 1) {
+ acl_get_tag_type(entry, &tag);
+ switch(tag) {
+ case ACL_USER:
+ case ACL_GROUP:
+ case ACL_MASK:
+ acl_delete_entry(acl, entry);
+ break;
+ }
+ error = acl_get_entry(acl, ACL_NEXT_ENTRY, &entry);
+ }
+ if (!error)
+ error = acl_set_file(path, ACL_TYPE_ACCESS, acl);
+ } else
+ error = acl_delete_def_file(path);
+ return(error);
+}
+
+/*
+ * lists the acl for a file/dir in short text form
+ * return 0 on failure
+ * return 1 on success
+ */
+static int
+list_acl(char *file)
+{
+ acl_t acl = NULL;
+ acl_t dacl = NULL;
+ char *acl_text, *dacl_text = NULL;
+
+ if ((acl = acl_get_file(file, ACL_TYPE_ACCESS)) == NULL) {
+ fprintf(stderr, _("%s: cannot get access ACL on '%s': %s\n"),
+ program, file, strerror(errno));
+ return 0;
+ }
+ if ((dacl = acl_get_file(file, ACL_TYPE_DEFAULT)) == NULL &&
+ (errno != EACCES)) { /* EACCES given if not a directory */
+ fprintf(stderr, _("%s: cannot get default ACL on '%s': %s\n"),
+ program, file, strerror(errno));
+ return 0;
+ }
+ acl_text = acl_to_any_text(acl, NULL, ',', TEXT_ABBREVIATE);
+ if (acl_text == NULL) {
+ fprintf(stderr, _("%s: cannot get access ACL text on "
+ "'%s': %s\n"), program, file, strerror(errno));
+ return 0;
+ }
+ if (acl_entries(dacl) > 0) {
+ dacl_text = acl_to_any_text(dacl, NULL, ',', TEXT_ABBREVIATE);
+ if (dacl_text == NULL) {
+ fprintf(stderr, _("%s: cannot get default ACL text on "
+ "'%s': %s\n"), program, file, strerror(errno));
+ return 0;
+ }
+ }
+ if (dacl_text) {
+ printf("%s [%s/%s]\n", file, acl_text, dacl_text);
+ acl_free(dacl_text);
+ } else
+ printf("%s [%s]\n", file, acl_text);
+ acl_free(acl_text);
+ acl_free(acl);
+ acl_free(dacl);
+ return 1;
+}
+
+static int
+set_acl(acl_t acl, acl_t dacl, const char *fname)
+{
+ int failed = 0;
+
+ if (rflag)
+ failed += walk_dir(acl, dacl, fname);
+
+ /* set regular acl */
+ if (acl && acl_set_file(fname, ACL_TYPE_ACCESS, acl) == -1) {
+ fprintf(stderr, _("%s: cannot set access acl on \"%s\": %s\n"),
+ program, fname, strerror(errno));
+ failed++;
+ }
+ /* set default acl */
+ if (dacl && acl_set_file(fname, ACL_TYPE_DEFAULT, dacl) == -1) {
+ fprintf(stderr, _("%s: cannot set default acl on \"%s\": %s\n"),
+ program, fname, strerror(errno));
+ failed++;
+ }
+
+ return(failed);
+}
+
+static int
+walk_dir(acl_t acl, acl_t dacl, const char *fname)
+{
+ int failed = 0;
+ DIR *dir;
+ struct dirent64 *d;
+ char *name;
+
+ if ((dir = opendir(fname)) == NULL) {
+ if (errno != ENOTDIR) {
+ fprintf(stderr, _("%s: opendir failed: %s\n"),
+ program, strerror(errno));
+ return(1);
+ }
+ return(0); /* got a file, not an error */
+ }
+
+ while ((d = readdir64(dir)) != NULL) {
+ /* skip "." and ".." entries */
+ if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0)
+ continue;
+
+ name = malloc(strlen(fname) + strlen(d->d_name) + 2);
+ if (name == NULL) {
+ fprintf(stderr, _("%s: malloc failed: %s\n"),
+ program, strerror(errno));
+ exit(1);
+ }
+ sprintf(name, "%s/%s", fname, d->d_name);
+
+ failed += set_acl(acl, dacl, name);
+ free(name);
+ }
+ closedir(dir);
+
+ return(failed);
+}
diff --git a/tools/do_set.c b/tools/do_set.c
new file mode 100644
index 0000000..60da837
--- /dev/null
+++ b/tools/do_set.c
@@ -0,0 +1,528 @@
+/*
+ File: do_set.c
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999, 2000
+ Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "config.h"
+#include <stdio.h>
+#include <errno.h>
+#include <sys/acl.h>
+#include <acl/libacl.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <ftw.h>
+#include "misc.h"
+#include "sequence.h"
+#include "do_set.h"
+#include "parse.h"
+#include "walk_tree.h"
+
+
+extern const char *progname;
+extern int opt_recalculate;
+extern int opt_test;
+extern int print_options;
+
+acl_entry_t
+find_entry(
+ acl_t acl,
+ acl_tag_t type,
+ id_t id)
+{
+ acl_entry_t ent;
+ acl_tag_t e_type;
+ id_t *e_id_p;
+
+ if (acl_get_entry(acl, ACL_FIRST_ENTRY, &ent) != 1)
+ return NULL;
+
+ for(;;) {
+ acl_get_tag_type(ent, &e_type);
+ if (type == e_type) {
+ if (id != ACL_UNDEFINED_ID) {
+ e_id_p = acl_get_qualifier(ent);
+ if (e_id_p == NULL)
+ return NULL;
+ if (*e_id_p == id) {
+ acl_free(e_id_p);
+ return ent;
+ }
+ acl_free(e_id_p);
+ } else {
+ return ent;
+ }
+ }
+ if (acl_get_entry(acl, ACL_NEXT_ENTRY, &ent) != 1)
+ return NULL;
+ }
+}
+
+int
+has_execute_perms(
+ acl_t acl)
+{
+ acl_entry_t ent;
+
+ if (acl_get_entry(acl, ACL_FIRST_ENTRY, &ent) != 1)
+ return 0;
+
+ for(;;) {
+ acl_permset_t permset;
+
+ acl_get_permset(ent, &permset);
+ if (acl_get_perm(permset, ACL_EXECUTE) != 0)
+ return 1;
+
+ if (acl_get_entry(acl, ACL_NEXT_ENTRY, &ent) != 1)
+ return 0;
+ }
+}
+
+int
+clone_entry(
+ acl_t from_acl,
+ acl_tag_t from_type,
+ acl_t *to_acl,
+ acl_tag_t to_type)
+{
+ acl_entry_t from_entry, to_entry;
+ from_entry = find_entry(from_acl, from_type, ACL_UNDEFINED_ID);
+ if (from_entry) {
+ if (acl_create_entry(to_acl, &to_entry) != 0)
+ return -1;
+ acl_copy_entry(to_entry, from_entry);
+ acl_set_tag_type(to_entry, to_type);
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+
+void
+print_test(
+ FILE *file,
+ const char *path_p,
+ const struct stat *st,
+ const acl_t acl,
+ const acl_t default_acl)
+{
+ char *acl_text, *default_acl_text;
+
+ acl_text = acl_to_any_text(acl, NULL, ',', TEXT_ABBREVIATE);
+ default_acl_text =
+ acl_to_any_text(default_acl, "d:", ',', TEXT_ABBREVIATE);
+ fprintf(file, "%s: %s,%s\n", path_p,
+ acl_text ? acl_text : "*",
+ default_acl_text ? default_acl_text : "*");
+ acl_free(acl_text);
+ acl_free(default_acl_text);
+}
+
+
+static void
+set_perm(
+ acl_entry_t ent,
+ mode_t perm)
+{
+ acl_permset_t set;
+
+ acl_get_permset(ent, &set);
+ if (perm & CMD_PERM_READ)
+ acl_add_perm(set, ACL_READ);
+ else
+ acl_delete_perm(set, ACL_READ);
+ if (perm & CMD_PERM_WRITE)
+ acl_add_perm(set, ACL_WRITE);
+ else
+ acl_delete_perm(set, ACL_WRITE);
+ if (perm & CMD_PERM_EXECUTE)
+ acl_add_perm(set, ACL_EXECUTE);
+ else
+ acl_delete_perm(set, ACL_EXECUTE);
+}
+
+
+static int
+retrieve_acl(
+ const char *path_p,
+ acl_type_t type,
+ const struct stat *st,
+ acl_t *old_acl,
+ acl_t *acl)
+{
+ if (*acl)
+ return 0;
+ *acl = NULL;
+ if (type == ACL_TYPE_ACCESS || S_ISDIR(st->st_mode)) {
+ *old_acl = acl_get_file(path_p, type);
+ if (*old_acl == NULL && (errno == ENOSYS || errno == ENOTSUP)) {
+ if (type == ACL_TYPE_DEFAULT)
+ *old_acl = acl_init(0);
+ else
+ *old_acl = acl_from_mode(st->st_mode);
+ }
+ } else
+ *old_acl = acl_init(0);
+ if (*old_acl == NULL)
+ return -1;
+ *acl = acl_dup(*old_acl);
+ if (*acl == NULL)
+ return -1;
+ return 0;
+}
+
+
+static int
+remove_extended_entries(
+ acl_t acl)
+{
+ acl_entry_t ent, group_obj;
+ acl_permset_t mask_permset, group_obj_permset;
+ acl_tag_t tag;
+ int error;
+
+ /*
+ * Removing the ACL_MASK entry from the ACL results in
+ * increased permissions for the owning group if the
+ * ACL_GROUP_OBJ entry contains permissions not contained
+ * in the ACL_MASK entry. We remove these permissions from
+ * the ACL_GROUP_OBJ entry to avoid that.
+ *
+ * After removing the ACL, the file owner and the owning group
+ * therefore have the same permissions as before.
+ */
+
+ ent = find_entry(acl, ACL_MASK, ACL_UNDEFINED_ID);
+ group_obj = find_entry(acl, ACL_GROUP_OBJ, ACL_UNDEFINED_ID);
+ if (ent && group_obj) {
+ if (!acl_get_permset(ent, &mask_permset) &&
+ !acl_get_permset(group_obj, &group_obj_permset)) {
+ if (!acl_get_perm(mask_permset, ACL_READ))
+ acl_delete_perm(group_obj_permset, ACL_READ);
+ if (!acl_get_perm(mask_permset, ACL_WRITE))
+ acl_delete_perm(group_obj_permset, ACL_WRITE);
+ if (!acl_get_perm(mask_permset, ACL_EXECUTE))
+ acl_delete_perm(group_obj_permset, ACL_EXECUTE);
+ }
+ }
+
+ error = acl_get_entry(acl, ACL_FIRST_ENTRY, &ent);
+ while (error == 1) {
+ acl_get_tag_type(ent, &tag);
+ switch(tag) {
+ case ACL_USER:
+ case ACL_GROUP:
+ case ACL_MASK:
+ acl_delete_entry(acl, ent);
+ break;
+ default:
+ break;
+ }
+
+ error = acl_get_entry(acl, ACL_NEXT_ENTRY, &ent);
+ }
+ if (error < 0)
+ return -1;
+ return 0;
+}
+
+
+#define RETRIEVE_ACL(type) do { \
+ error = retrieve_acl(path_p, type, st, old_xacl, xacl); \
+ if (error) \
+ goto fail; \
+ } while(0)
+
+int
+do_set(
+ const char *path_p,
+ const struct stat *st,
+ int walk_flags,
+ void *arg)
+{
+ struct do_set_args *args = arg;
+ acl_t old_acl = NULL, old_default_acl = NULL;
+ acl_t acl = NULL, default_acl = NULL;
+ acl_t *xacl, *old_xacl;
+ acl_entry_t ent;
+ cmd_t cmd;
+ int which_entry;
+ int errors = 0, error;
+ char *acl_text;
+ int acl_modified = 0, default_acl_modified = 0;
+ int acl_mask_provided = 0, default_acl_mask_provided = 0;
+
+ if (walk_flags & WALK_TREE_FAILED) {
+ fprintf(stderr, "%s: %s: %s\n", progname, path_p, strerror(errno));
+ return 1;
+ }
+
+ /*
+ * Symlinks can never have ACLs, so when doing a physical walk, we
+ * skip symlinks altogether, and when doing a half-logical walk, we
+ * skip all non-toplevel symlinks.
+ */
+ if ((walk_flags & WALK_TREE_SYMLINK) &&
+ ((walk_flags & WALK_TREE_PHYSICAL) ||
+ !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL))))
+ return 0;
+
+ /* Execute the commands in seq (read ACLs on demand) */
+ error = seq_get_cmd(args->seq, SEQ_FIRST_CMD, &cmd);
+ if (error == 0)
+ return 0;
+ while (error == 1) {
+ mode_t perm = cmd->c_perm;
+
+ if (cmd->c_type == ACL_TYPE_ACCESS) {
+ xacl = &acl;
+ old_xacl = &old_acl;
+ acl_modified = 1;
+ if (cmd->c_tag == ACL_MASK)
+ acl_mask_provided = 1;
+ } else {
+ xacl = &default_acl;
+ old_xacl = &old_default_acl;
+ default_acl_modified = 1;
+ if (cmd->c_tag == ACL_MASK)
+ default_acl_mask_provided = 1;
+ }
+
+ RETRIEVE_ACL(cmd->c_type);
+
+ /* Check for `X', and replace with `x' as appropriate. */
+ if (perm & CMD_PERM_COND_EXECUTE) {
+ perm &= ~CMD_PERM_COND_EXECUTE;
+ if (S_ISDIR(st->st_mode) || has_execute_perms(*xacl))
+ perm |= CMD_PERM_EXECUTE;
+ }
+
+ switch(cmd->c_cmd) {
+ case CMD_ENTRY_REPLACE:
+ ent = find_entry(*xacl, cmd->c_tag, cmd->c_id);
+ if (!ent) {
+ if (acl_create_entry(xacl, &ent) != 0)
+ goto fail;
+ acl_set_tag_type(ent, cmd->c_tag);
+ if (cmd->c_id != ACL_UNDEFINED_ID)
+ acl_set_qualifier(ent,
+ &cmd->c_id);
+ }
+ set_perm(ent, perm);
+ break;
+
+ case CMD_REMOVE_ENTRY:
+ ent = find_entry(*xacl, cmd->c_tag, cmd->c_id);
+ if (ent)
+ acl_delete_entry(*xacl, ent);
+ else
+ /* ignore */;
+ break;
+
+ case CMD_REMOVE_EXTENDED_ACL:
+ remove_extended_entries(acl);
+ break;
+
+ case CMD_REMOVE_ACL:
+ acl_free(*xacl);
+ *xacl = acl_init(5);
+ if (!*xacl)
+ goto fail;
+ break;
+
+ default:
+ errno = EINVAL;
+ goto fail;
+ }
+
+ error = seq_get_cmd(args->seq, SEQ_NEXT_CMD, &cmd);
+ }
+
+ if (error < 0)
+ goto fail;
+
+ /* Try to fill in missing entries */
+ if (default_acl && acl_entries(default_acl) != 0) {
+ xacl = &acl;
+ old_xacl = &old_acl;
+
+ if (!find_entry(default_acl, ACL_USER_OBJ, ACL_UNDEFINED_ID)) {
+ if (!acl)
+ RETRIEVE_ACL(ACL_TYPE_ACCESS);
+ clone_entry(acl, ACL_USER_OBJ,
+ &default_acl, ACL_USER_OBJ);
+ }
+ if (!find_entry(default_acl, ACL_GROUP_OBJ, ACL_UNDEFINED_ID)) {
+ if (!acl)
+ RETRIEVE_ACL(ACL_TYPE_ACCESS);
+ clone_entry(acl, ACL_GROUP_OBJ,
+ &default_acl, ACL_GROUP_OBJ);
+ }
+ if (!find_entry(default_acl, ACL_OTHER, ACL_UNDEFINED_ID)) {
+ if (!acl)
+ RETRIEVE_ACL(ACL_TYPE_ACCESS);
+ clone_entry(acl, ACL_OTHER,
+ &default_acl, ACL_OTHER);
+ }
+ }
+
+ /* update mask entries and check if ACLs are valid */
+ if (acl && acl_modified) {
+ if (acl_equiv_mode(acl, NULL) != 0) {
+ if (!acl_mask_provided &&
+ !find_entry(acl, ACL_MASK, ACL_UNDEFINED_ID))
+ clone_entry(acl, ACL_GROUP_OBJ,
+ &acl, ACL_MASK);
+ if (opt_recalculate != -1 &&
+ (!acl_mask_provided || opt_recalculate == 1))
+ acl_calc_mask(&acl);
+ }
+
+ error = acl_check(acl, &which_entry);
+ if (error < 0)
+ goto fail;
+ if (error > 0) {
+ acl_text = acl_to_any_text(acl, NULL, ',', 0);
+ fprintf(stderr, _("%s: %s: Malformed access ACL "
+ "`%s': %s at entry %d\n"), progname, path_p,
+ acl_text, acl_error(error), which_entry+1);
+ acl_free(acl_text);
+ errors++;
+ goto cleanup;
+ }
+ }
+
+ if (default_acl && acl_entries(default_acl) != 0 &&
+ default_acl_modified) {
+ if (acl_equiv_mode(default_acl, NULL) != 0) {
+ if (!default_acl_mask_provided &&
+ !find_entry(default_acl,ACL_MASK,ACL_UNDEFINED_ID))
+ clone_entry(default_acl, ACL_GROUP_OBJ,
+ &default_acl, ACL_MASK);
+ if (opt_recalculate != -1 &&
+ (!default_acl_mask_provided ||
+ opt_recalculate == 1))
+ acl_calc_mask(&default_acl);
+ }
+
+ error = acl_check(default_acl, &which_entry);
+ if (error < 0)
+ goto fail;
+ if (error > 0) {
+ acl_text = acl_to_any_text(default_acl, NULL, ',', 0);
+ fprintf(stderr, _("%s: %s: Malformed default ACL "
+ "`%s': %s at entry %d\n"),
+ progname, path_p, acl_text,
+ acl_error(error), which_entry+1);
+ acl_free(acl_text);
+ errors++;
+ goto cleanup;
+ }
+ }
+
+ /* Only directores can have default ACLs */
+ if (default_acl && !S_ISDIR(st->st_mode) && (walk_flags & WALK_TREE_RECURSIVE)) {
+ /* In recursive mode, ignore default ACLs for files */
+ acl_free(default_acl);
+ default_acl = NULL;
+ }
+
+ /* check which ACLs have changed */
+ if (acl && old_acl && acl_cmp(old_acl, acl) == 0) {
+ acl_free(acl);
+ acl = NULL;
+ }
+ if ((default_acl && old_default_acl &&
+ acl_cmp(old_default_acl, default_acl) == 0)) {
+ acl_free(default_acl);
+ default_acl = NULL;
+ }
+
+ /* update the file system */
+ if (opt_test) {
+ print_test(stdout, path_p, st,
+ acl, default_acl);
+ goto cleanup;
+ }
+ if (acl) {
+ int equiv_mode;
+ mode_t mode = 0;
+
+ equiv_mode = acl_equiv_mode(acl, &mode);
+
+ if (acl_set_file(path_p, ACL_TYPE_ACCESS, acl) != 0) {
+ if (errno == ENOSYS || errno == ENOTSUP) {
+ if (equiv_mode != 0)
+ goto fail;
+ else if (chmod(path_p, mode) != 0)
+ goto fail;
+ } else
+ goto fail;
+ }
+ args->mode = mode;
+ }
+ if (default_acl) {
+ if (S_ISDIR(st->st_mode)) {
+ if (acl_entries(default_acl) == 0) {
+ if (acl_delete_def_file(path_p) != 0 &&
+ errno != ENOSYS && errno != ENOTSUP)
+ goto fail;
+ } else {
+ if (acl_set_file(path_p, ACL_TYPE_DEFAULT,
+ default_acl) != 0)
+ goto fail;
+ }
+ } else {
+ if (acl_entries(default_acl) != 0) {
+ fprintf(stderr, _("%s: %s: Only directories "
+ "can have default ACLs\n"),
+ progname, path_p);
+ errors++;
+ goto cleanup;
+ }
+ }
+ }
+
+ error = 0;
+
+cleanup:
+ if (acl)
+ acl_free(acl);
+ if (old_acl)
+ acl_free(old_acl);
+ if (default_acl)
+ acl_free(default_acl);
+ if (old_default_acl)
+ acl_free(old_default_acl);
+ return errors;
+
+fail:
+ fprintf(stderr, "%s: %s: %s\n", progname, path_p, strerror(errno));
+ errors++;
+ goto cleanup;
+}
+
diff --git a/tools/do_set.h b/tools/do_set.h
new file mode 100644
index 0000000..2ea25a8
--- /dev/null
+++ b/tools/do_set.h
@@ -0,0 +1,36 @@
+/*
+ File: do_set.h
+ (Linux Access Control List Management)
+
+ Copyright (C) 2009 by Andreas Gruenbacher
+ <a.gruenbacher@computer.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __DO_SET_H
+#define __DO_SET_H
+
+#include "sequence.h"
+
+struct do_set_args {
+ seq_t seq;
+ mode_t mode;
+};
+
+extern int do_set(const char *path_p, const struct stat *stat_p, int flags,
+ void *arg);
+
+#endif /* __DO_SET_H */
diff --git a/tools/getfacl.c b/tools/getfacl.c
new file mode 100644
index 0000000..22cc1c7
--- /dev/null
+++ b/tools/getfacl.c
@@ -0,0 +1,747 @@
+/*
+ File: getfacl.c
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999-2002
+ Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA.
+*/
+
+#include "config.h"
+#include <stdio.h>
+#include <errno.h>
+#include <sys/acl.h>
+#include <acl/libacl.h>
+
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <libgen.h>
+#include <getopt.h>
+#include "misc.h"
+#include "user_group.h"
+#include "walk_tree.h"
+
+#define POSIXLY_CORRECT_STR "POSIXLY_CORRECT"
+
+#if !POSIXLY_CORRECT
+# define CMD_LINE_OPTIONS "aceEsRLPtpndvh"
+#endif
+#define POSIXLY_CMD_LINE_OPTIONS "d"
+
+struct option long_options[] = {
+#if !POSIXLY_CORRECT
+ { "access", 0, 0, 'a' },
+ { "omit-header", 0, 0, 'c' },
+ { "all-effective", 0, 0, 'e' },
+ { "no-effective", 0, 0, 'E' },
+ { "skip-base", 0, 0, 's' },
+ { "recursive", 0, 0, 'R' },
+ { "logical", 0, 0, 'L' },
+ { "physical", 0, 0, 'P' },
+ { "tabular", 0, 0, 't' },
+ { "absolute-names", 0, 0, 'p' },
+ { "numeric", 0, 0, 'n' },
+#endif
+ { "default", 0, 0, 'd' },
+ { "version", 0, 0, 'v' },
+ { "help", 0, 0, 'h' },
+ { NULL, 0, 0, 0 }
+};
+
+const char *progname;
+const char *cmd_line_options;
+
+int walk_flags = WALK_TREE_DEREFERENCE_TOPLEVEL;
+int opt_print_acl;
+int opt_print_default_acl;
+int opt_strip_leading_slash = 1;
+int opt_comments = 1; /* include comments */
+int opt_skip_base; /* skip files that only have the base entries */
+int opt_tabular; /* tabular output format (alias `showacl') */
+#if POSIXLY_CORRECT
+const int posixly_correct = 1; /* Posix compatible behavior! */
+#else
+int posixly_correct; /* Posix compatible behavior? */
+#endif
+int had_errors;
+int absolute_warning; /* Absolute path warning was issued */
+int print_options = TEXT_SOME_EFFECTIVE;
+int opt_numeric; /* don't convert id's to symbolic names */
+
+
+static const char *xquote(const char *str, const char *quote_chars)
+{
+ const char *q = quote(str, quote_chars);
+ if (q == NULL) {
+ fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ exit(1);
+ }
+ return q;
+}
+
+struct name_list {
+ struct name_list *next;
+ char name[0];
+};
+
+void free_list(struct name_list *names)
+{
+ struct name_list *next;
+
+ while (names) {
+ next = names->next;
+ free(names);
+ names = next;
+ }
+}
+
+struct name_list *get_list(const struct stat *st, acl_t acl)
+{
+ struct name_list *first = NULL, *last = NULL;
+ acl_entry_t ent;
+ int ret = 0;
+
+ if (acl != NULL)
+ ret = acl_get_entry(acl, ACL_FIRST_ENTRY, &ent);
+ if (ret != 1)
+ return NULL;
+ while (ret > 0) {
+ acl_tag_t e_type;
+ const id_t *id_p;
+ const char *name = "";
+ int len;
+
+ acl_get_tag_type(ent, &e_type);
+ switch(e_type) {
+ case ACL_USER_OBJ:
+ name = user_name(st->st_uid, opt_numeric);
+ break;
+
+ case ACL_USER:
+ id_p = acl_get_qualifier(ent);
+ if (id_p != NULL)
+ name = user_name(*id_p, opt_numeric);
+ break;
+
+ case ACL_GROUP_OBJ:
+ name = group_name(st->st_gid, opt_numeric);
+ break;
+
+ case ACL_GROUP:
+ id_p = acl_get_qualifier(ent);
+ if (id_p != NULL)
+ name = group_name(*id_p, opt_numeric);
+ break;
+ }
+ name = xquote(name, "\t\n\r");
+ len = strlen(name);
+ if (last == NULL) {
+ first = last = (struct name_list *)
+ malloc(sizeof(struct name_list) + len + 1);
+ } else {
+ last->next = (struct name_list *)
+ malloc(sizeof(struct name_list) + len + 1);
+ last = last->next;
+ }
+ if (last == NULL) {
+ free_list(first);
+ return NULL;
+ }
+ last->next = NULL;
+ strcpy(last->name, name);
+
+ ret = acl_get_entry(acl, ACL_NEXT_ENTRY, &ent);
+ }
+ return first;
+}
+
+int max_name_length(struct name_list *names)
+{
+ int max_len = 0;
+ while (names != NULL) {
+ struct name_list *next = names->next;
+ int len = strlen(names->name);
+
+ if (len > max_len)
+ max_len = len;
+ names = next;
+ }
+ return max_len;
+}
+
+int names_width;
+
+struct acl_perm_def {
+ acl_tag_t tag;
+ char c;
+};
+
+struct acl_perm_def acl_perm_defs[] = {
+ { ACL_READ, 'r' },
+ { ACL_WRITE, 'w' },
+ { ACL_EXECUTE, 'x' },
+ { 0, 0 }
+};
+
+#define ACL_PERMS (sizeof(acl_perm_defs) / sizeof(struct acl_perm_def) - 1)
+
+void acl_perm_str(acl_entry_t entry, char *str)
+{
+ acl_permset_t permset;
+ int n;
+
+ acl_get_permset(entry, &permset);
+ for (n = 0; n < (int) ACL_PERMS; n++) {
+ str[n] = (acl_get_perm(permset, acl_perm_defs[n].tag) ?
+ acl_perm_defs[n].c : '-');
+ }
+ str[n] = '\0';
+}
+
+void acl_mask_perm_str(acl_t acl, char *str)
+{
+ acl_entry_t entry;
+
+ str[0] = '\0';
+ if (acl_get_entry(acl, ACL_FIRST_ENTRY, &entry) != 1)
+ return;
+ for(;;) {
+ acl_tag_t tag;
+
+ acl_get_tag_type(entry, &tag);
+ if (tag == ACL_MASK) {
+ acl_perm_str(entry, str);
+ return;
+ }
+ if (acl_get_entry(acl, ACL_NEXT_ENTRY, &entry) != 1)
+ return;
+ }
+}
+
+void apply_mask(char *perm, const char *mask)
+{
+ while (*perm) {
+ if (*mask == '-' && *perm >= 'a' && *perm <= 'z')
+ *perm = *perm - 'a' + 'A';
+ perm++;
+ if (*mask)
+ mask++;
+ }
+}
+
+int show_line(FILE *stream, struct name_list **acl_names, acl_t acl,
+ acl_entry_t *acl_ent, const char *acl_mask,
+ struct name_list **dacl_names, acl_t dacl,
+ acl_entry_t *dacl_ent, const char *dacl_mask)
+{
+ acl_tag_t tag_type;
+ const char *tag, *name;
+ char acl_perm[ACL_PERMS+1], dacl_perm[ACL_PERMS+1];
+
+ if (acl) {
+ acl_get_tag_type(*acl_ent, &tag_type);
+ name = (*acl_names)->name;
+ } else {
+ acl_get_tag_type(*dacl_ent, &tag_type);
+ name = (*dacl_names)->name;
+ }
+
+ switch(tag_type) {
+ case ACL_USER_OBJ:
+ tag = "USER";
+ break;
+ case ACL_USER:
+ tag = "user";
+ break;
+ case ACL_GROUP_OBJ:
+ tag = "GROUP";
+ break;
+ case ACL_GROUP:
+ tag = "group";
+ break;
+ case ACL_MASK:
+ tag = "mask";
+ break;
+ case ACL_OTHER:
+ tag = "other";
+ break;
+ default:
+ return -1;
+ }
+
+ memset(acl_perm, ' ', ACL_PERMS);
+ acl_perm[ACL_PERMS] = '\0';
+ if (acl_ent) {
+ acl_perm_str(*acl_ent, acl_perm);
+ if (tag_type != ACL_USER_OBJ && tag_type != ACL_OTHER &&
+ tag_type != ACL_MASK)
+ apply_mask(acl_perm, acl_mask);
+ }
+ memset(dacl_perm, ' ', ACL_PERMS);
+ dacl_perm[ACL_PERMS] = '\0';
+ if (dacl_ent) {
+ acl_perm_str(*dacl_ent, dacl_perm);
+ if (tag_type != ACL_USER_OBJ && tag_type != ACL_OTHER &&
+ tag_type != ACL_MASK)
+ apply_mask(dacl_perm, dacl_mask);
+ }
+
+ fprintf(stream, "%-5s %*s %*s %*s\n",
+ tag, -names_width, name,
+ -(int)ACL_PERMS, acl_perm,
+ -(int)ACL_PERMS, dacl_perm);
+
+ if (acl_names) {
+ acl_get_entry(acl, ACL_NEXT_ENTRY, acl_ent);
+ (*acl_names) = (*acl_names)->next;
+ }
+ if (dacl_names) {
+ acl_get_entry(dacl, ACL_NEXT_ENTRY, dacl_ent);
+ (*dacl_names) = (*dacl_names)->next;
+ }
+ return 0;
+}
+
+int do_show(FILE *stream, const char *path_p, const struct stat *st,
+ acl_t acl, acl_t dacl)
+{
+ struct name_list *acl_names = get_list(st, acl),
+ *first_acl_name = acl_names;
+ struct name_list *dacl_names = get_list(st, dacl),
+ *first_dacl_name = dacl_names;
+
+ int acl_names_width = max_name_length(acl_names);
+ int dacl_names_width = max_name_length(dacl_names);
+ acl_entry_t acl_ent;
+ acl_entry_t dacl_ent;
+ char acl_mask[ACL_PERMS+1], dacl_mask[ACL_PERMS+1];
+ int ret;
+
+ names_width = 8;
+ if (acl_names_width > names_width)
+ names_width = acl_names_width;
+ if (dacl_names_width > names_width)
+ names_width = dacl_names_width;
+
+ acl_mask[0] = '\0';
+ if (acl) {
+ acl_mask_perm_str(acl, acl_mask);
+ ret = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_ent);
+ if (ret == 0)
+ acl = NULL;
+ if (ret < 0)
+ return ret;
+ }
+ dacl_mask[0] = '\0';
+ if (dacl) {
+ acl_mask_perm_str(dacl, dacl_mask);
+ ret = acl_get_entry(dacl, ACL_FIRST_ENTRY, &dacl_ent);
+ if (ret == 0)
+ dacl = NULL;
+ if (ret < 0)
+ return ret;
+ }
+ fprintf(stream, "# file: %s\n", xquote(path_p, "\n\r"));
+ while (acl_names != NULL || dacl_names != NULL) {
+ acl_tag_t acl_tag, dacl_tag;
+
+ if (acl)
+ acl_get_tag_type(acl_ent, &acl_tag);
+ if (dacl)
+ acl_get_tag_type(dacl_ent, &dacl_tag);
+
+ if (acl && (!dacl || acl_tag < dacl_tag)) {
+ show_line(stream, &acl_names, acl, &acl_ent, acl_mask,
+ NULL, NULL, NULL, NULL);
+ continue;
+ } else if (dacl && (!acl || dacl_tag < acl_tag)) {
+ show_line(stream, NULL, NULL, NULL, NULL,
+ &dacl_names, dacl, &dacl_ent, dacl_mask);
+ continue;
+ } else {
+ if (acl_tag == ACL_USER || acl_tag == ACL_GROUP) {
+ id_t *acl_id_p = NULL, *dacl_id_p = NULL;
+ if (acl_ent)
+ acl_id_p = acl_get_qualifier(acl_ent);
+ if (dacl_ent)
+ dacl_id_p = acl_get_qualifier(dacl_ent);
+
+ if (acl && (!dacl || *acl_id_p < *dacl_id_p)) {
+ show_line(stream, &acl_names, acl,
+ &acl_ent, acl_mask,
+ NULL, NULL, NULL, NULL);
+ continue;
+ } else if (dacl &&
+ (!acl || *dacl_id_p < *acl_id_p)) {
+ show_line(stream, NULL, NULL, NULL,
+ NULL, &dacl_names, dacl,
+ &dacl_ent, dacl_mask);
+ continue;
+ }
+ }
+ show_line(stream, &acl_names, acl, &acl_ent, acl_mask,
+ &dacl_names, dacl, &dacl_ent, dacl_mask);
+ }
+ }
+
+ free_list(first_acl_name);
+ free_list(first_dacl_name);
+
+ return 0;
+}
+
+/*
+ * Create an ACL from the file permission bits
+ * of the file PATH_P.
+ */
+static acl_t
+acl_get_file_mode(const char *path_p)
+{
+ struct stat st;
+
+ if (stat(path_p, &st) != 0)
+ return NULL;
+ return acl_from_mode(st.st_mode);
+}
+
+static const char *
+flagstr(mode_t mode)
+{
+ static char str[4];
+
+ str[0] = (mode & S_ISUID) ? 's' : '-';
+ str[1] = (mode & S_ISGID) ? 's' : '-';
+ str[2] = (mode & S_ISVTX) ? 't' : '-';
+ str[3] = '\0';
+ return str;
+}
+
+int do_print(const char *path_p, const struct stat *st, int walk_flags, void *unused)
+{
+ const char *default_prefix = NULL;
+ acl_t acl = NULL, default_acl = NULL;
+ int error = 0;
+
+ if (walk_flags & WALK_TREE_FAILED) {
+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
+ strerror(errno));
+ return 1;
+ }
+
+ /*
+ * Symlinks can never have ACLs, so when doing a physical walk, we
+ * skip symlinks altogether, and when doing a half-logical walk, we
+ * skip all non-toplevel symlinks.
+ */
+ if ((walk_flags & WALK_TREE_SYMLINK) &&
+ ((walk_flags & WALK_TREE_PHYSICAL) ||
+ !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL))))
+ return 0;
+
+ if (opt_print_acl) {
+ acl = acl_get_file(path_p, ACL_TYPE_ACCESS);
+ if (acl == NULL && (errno == ENOSYS || errno == ENOTSUP))
+ acl = acl_get_file_mode(path_p);
+ if (acl == NULL)
+ goto fail;
+ }
+
+ if (opt_print_default_acl && S_ISDIR(st->st_mode)) {
+ default_acl = acl_get_file(path_p, ACL_TYPE_DEFAULT);
+ if (default_acl == NULL) {
+ if (errno != ENOSYS && errno != ENOTSUP)
+ goto fail;
+ } else if (acl_entries(default_acl) == 0) {
+ acl_free(default_acl);
+ default_acl = NULL;
+ }
+ }
+
+ if (opt_skip_base &&
+ (!acl || acl_equiv_mode(acl, NULL) == 0) && !default_acl)
+ return 0;
+
+ if (opt_print_acl && opt_print_default_acl)
+ default_prefix = "default:";
+
+ if (opt_strip_leading_slash) {
+ if (*path_p == '/') {
+ if (!absolute_warning) {
+ fprintf(stderr, _("%s: Removing leading "
+ "'/' from absolute path names\n"),
+ progname);
+ absolute_warning = 1;
+ }
+ while (*path_p == '/')
+ path_p++;
+ } else if (*path_p == '.' && *(path_p+1) == '/')
+ while (*++path_p == '/')
+ /* nothing */ ;
+ if (*path_p == '\0')
+ path_p = ".";
+ }
+
+ if (opt_tabular) {
+ if (do_show(stdout, path_p, st, acl, default_acl) != 0)
+ goto fail;
+ } else {
+ if (opt_comments) {
+ printf("# file: %s\n", xquote(path_p, "\n\r"));
+ printf("# owner: %s\n",
+ xquote(user_name(st->st_uid, opt_numeric), " \t\n\r"));
+ printf("# group: %s\n",
+ xquote(group_name(st->st_gid, opt_numeric), " \t\n\r"));
+ if ((st->st_mode & (S_ISVTX | S_ISUID | S_ISGID)) && !posixly_correct)
+ printf("# flags: %s\n", flagstr(st->st_mode));
+ }
+ if (acl != NULL) {
+ char *acl_text = acl_to_any_text(acl, NULL, '\n',
+ print_options);
+ if (!acl_text)
+ goto fail;
+ if (puts(acl_text) < 0) {
+ acl_free(acl_text);
+ goto fail;
+ }
+ acl_free(acl_text);
+ }
+ if (default_acl != NULL) {
+ char *acl_text = acl_to_any_text(default_acl,
+ default_prefix, '\n',
+ print_options);
+ if (!acl_text)
+ goto fail;
+ if (puts(acl_text) < 0) {
+ acl_free(acl_text);
+ goto fail;
+ }
+ acl_free(acl_text);
+ }
+ }
+ if (acl || default_acl || opt_comments)
+ printf("\n");
+
+cleanup:
+ if (acl)
+ acl_free(acl);
+ if (default_acl)
+ acl_free(default_acl);
+ return error;
+
+fail:
+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
+ strerror(errno));
+ error = -1;
+ goto cleanup;
+}
+
+
+void help(void)
+{
+ printf(_("%s %s -- get file access control lists\n"),
+ progname, VERSION);
+ printf(_("Usage: %s [-%s] file ...\n"),
+ progname, cmd_line_options);
+#if !POSIXLY_CORRECT
+ if (posixly_correct) {
+#endif
+ printf(_(
+" -d, --default display the default access control list\n"));
+#if !POSIXLY_CORRECT
+ } else {
+ printf(_(
+" -a, --access display the file access control list only\n"
+" -d, --default display the default access control list only\n"
+" -c, --omit-header do not display the comment header\n"
+" -e, --all-effective print all effective rights\n"
+" -E, --no-effective print no effective rights\n"
+" -s, --skip-base skip files that only have the base entries\n"
+" -R, --recursive recurse into subdirectories\n"
+" -L, --logical logical walk, follow symbolic links\n"
+" -P, --physical physical walk, do not follow symbolic links\n"
+" -t, --tabular use tabular output format\n"
+" -n, --numeric print numeric user/group identifiers\n"
+" -p, --absolute-names don't strip leading '/' in pathnames\n"));
+ }
+#endif
+ printf(_(
+" -v, --version print version and exit\n"
+" -h, --help this help text\n"));
+}
+
+int main(int argc, char *argv[])
+{
+ int opt;
+ char *line;
+
+ progname = basename(argv[0]);
+
+#if POSIXLY_CORRECT
+ cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
+#else
+ if (getenv(POSIXLY_CORRECT_STR))
+ posixly_correct = 1;
+ if (!posixly_correct)
+ cmd_line_options = CMD_LINE_OPTIONS;
+ else
+ cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
+#endif
+
+ setlocale(LC_CTYPE, "");
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ /* Align `#effective:' comments to column 40 for tty's */
+ if (!posixly_correct && isatty(fileno(stdout)))
+ print_options |= TEXT_SMART_INDENT;
+
+ while ((opt = getopt_long(argc, argv, cmd_line_options,
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 'a': /* acl only */
+ if (posixly_correct)
+ goto synopsis;
+ opt_print_acl = 1;
+ break;
+
+ case 'd': /* default acl only */
+ opt_print_default_acl = 1;
+ break;
+
+ case 'c': /* no comments */
+ if (posixly_correct)
+ goto synopsis;
+ opt_comments = 0;
+ break;
+
+ case 'e': /* all #effective comments */
+ if (posixly_correct)
+ goto synopsis;
+ print_options |= TEXT_ALL_EFFECTIVE;
+ break;
+
+ case 'E': /* no #effective comments */
+ if (posixly_correct)
+ goto synopsis;
+ print_options &= ~(TEXT_SOME_EFFECTIVE |
+ TEXT_ALL_EFFECTIVE);
+ break;
+
+ case 'R': /* recursive */
+ if (posixly_correct)
+ goto synopsis;
+ walk_flags |= WALK_TREE_RECURSIVE;
+ break;
+
+ case 'L': /* follow all symlinks */
+ if (posixly_correct)
+ goto synopsis;
+ walk_flags |= WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE;
+ walk_flags &= ~WALK_TREE_PHYSICAL;
+ break;
+
+ case 'P': /* skip all symlinks */
+ if (posixly_correct)
+ goto synopsis;
+ walk_flags |= WALK_TREE_PHYSICAL;
+ walk_flags &= ~(WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE |
+ WALK_TREE_DEREFERENCE_TOPLEVEL);
+ break;
+
+ case 's': /* skip files with only base entries */
+ if (posixly_correct)
+ goto synopsis;
+ opt_skip_base = 1;
+ break;
+
+ case 'p':
+ if (posixly_correct)
+ goto synopsis;
+ opt_strip_leading_slash = 0;
+ break;
+
+ case 't':
+ if (posixly_correct)
+ goto synopsis;
+ opt_tabular = 1;
+ break;
+
+ case 'n': /* numeric */
+ opt_numeric = 1;
+ print_options |= TEXT_NUMERIC_IDS;
+ break;
+
+ case 'v': /* print version */
+ printf("%s " VERSION "\n", progname);
+ return 0;
+
+ case 'h': /* help */
+ help();
+ return 0;
+
+ case ':': /* option missing */
+ case '?': /* unknown option */
+ default:
+ goto synopsis;
+ }
+ }
+
+ if (!(opt_print_acl || opt_print_default_acl)) {
+ opt_print_acl = 1;
+ if (!posixly_correct)
+ opt_print_default_acl = 1;
+ }
+
+ if ((optind == argc) && !posixly_correct)
+ goto synopsis;
+
+ do {
+ if (optind == argc ||
+ strcmp(argv[optind], "-") == 0) {
+ while ((line = next_line(stdin)) != NULL) {
+ if (*line == '\0')
+ continue;
+
+ had_errors += walk_tree(line, walk_flags, 0,
+ do_print, NULL);
+ }
+ if (!feof(stdin)) {
+ fprintf(stderr, _("%s: Standard input: %s\n"),
+ progname, strerror(errno));
+ had_errors++;
+ }
+ } else
+ had_errors += walk_tree(argv[optind], walk_flags, 0,
+ do_print, NULL);
+ optind++;
+ } while (optind < argc);
+
+ return had_errors ? 1 : 0;
+
+synopsis:
+ fprintf(stderr, _("Usage: %s [-%s] file ...\n"),
+ progname, cmd_line_options);
+ fprintf(stderr, _("Try `%s --help' for more information.\n"),
+ progname);
+ return 2;
+}
+
diff --git a/tools/parse.c b/tools/parse.c
new file mode 100644
index 0000000..e7e6add
--- /dev/null
+++ b/tools/parse.c
@@ -0,0 +1,594 @@
+/*
+ File: parse.c
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999, 2000
+ Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <grp.h>
+#include "sys/acl.h"
+
+#include "sequence.h"
+#include "parse.h"
+#include "misc.h"
+
+#define SKIP_WS(x) ({ \
+ while (*(x)==' ' || *(x)=='\t' || *(x)=='\n' || *(x)=='\r') \
+ (x)++; \
+ })
+
+
+static int
+skip_tag_name(
+ const char **text_p,
+ const char *token)
+{
+ size_t len = strlen(token);
+ const char *text = *text_p;
+
+ SKIP_WS(text);
+ if (strncmp(text, token, len) == 0) {
+ text += len;
+ goto delimiter;
+ }
+ if (*text == *token) {
+ text++;
+ goto delimiter;
+ }
+ return 0;
+
+delimiter:
+ SKIP_WS(text);
+ if (*text == ':') {
+ *text_p = text+1;
+ return 1;
+ }
+ if (*text == ',' || *text == '\0') {
+ *text_p = text;
+ return 1;
+ }
+ return 0;
+}
+
+
+static char *
+get_token(
+ const char **text_p)
+{
+ char *token = NULL, *t;
+ const char *bp, *ep;
+
+ bp = *text_p;
+ SKIP_WS(bp);
+ ep = bp;
+
+ while (*ep!='\0' && *ep!='\r' && *ep!='\n' && *ep!=':' && *ep!=',')
+ ep++;
+ if (ep == bp)
+ goto after_token;
+ token = (char*)malloc(ep - bp + 1);
+ if (token == NULL)
+ goto after_token;
+ memcpy(token, bp, ep - bp);
+
+ /* Trim trailing whitespace */
+ t = token + (ep - bp - 1);
+ while (t >= token &&
+ (*t==' ' || *t=='\t' || *t=='\n' || *t=='\r'))
+ t--;
+ *(t+1) = '\0';
+
+after_token:
+ if (*ep == ':')
+ ep++;
+ *text_p = ep;
+ return token;
+}
+
+
+static int
+get_id(
+ const char *token,
+ id_t *id_p)
+{
+ char *ep;
+ long l;
+ l = strtol(token, &ep, 0);
+ if (*ep != '\0')
+ return -1;
+ if (l < 0) {
+ /*
+ Negative values are interpreted as 16-bit numbers,
+ so that id -2 maps to 65534 (nobody/nogroup), etc.
+ */
+ l &= 0xFFFF;
+ }
+ *id_p = l;
+ return 0;
+}
+
+
+static int
+get_uid(
+ const char *token,
+ uid_t *uid_p)
+{
+ struct passwd *passwd;
+
+ if (get_id(token, (id_t *)uid_p) == 0)
+ goto accept;
+ passwd = getpwnam(token);
+ if (passwd) {
+ *uid_p = passwd->pw_uid;
+ goto accept;
+ }
+ return -1;
+
+accept:
+ return 0;
+}
+
+
+static int
+get_gid(
+ const char *token,
+ gid_t *gid_p)
+{
+ struct group *group;
+
+ if (get_id(token, (id_t *)gid_p) == 0)
+ goto accept;
+ group = getgrnam(token);
+ if (group) {
+ *gid_p = group->gr_gid;
+ goto accept;
+ }
+ return -1;
+
+accept:
+ return 0;
+}
+
+
+/*
+ Parses the next acl entry in text_p.
+
+ Returns:
+ -1 on error, 0 on success.
+*/
+
+cmd_t
+parse_acl_cmd(
+ const char **text_p,
+ int seq_cmd,
+ int parse_mode)
+{
+ cmd_t cmd = cmd_init();
+ char *str;
+ const char *backup;
+ int error, perm_chars;
+ if (!cmd)
+ return NULL;
+
+ cmd->c_cmd = seq_cmd;
+ if (parse_mode & SEQ_PROMOTE_ACL)
+ cmd->c_type = ACL_TYPE_DEFAULT;
+ else
+ cmd->c_type = ACL_TYPE_ACCESS;
+ cmd->c_id = ACL_UNDEFINED_ID;
+ cmd->c_perm = 0;
+
+ if (parse_mode & SEQ_PARSE_DEFAULT) {
+ /* check for default acl entry */
+ backup = *text_p;
+ if (skip_tag_name(text_p, "default")) {
+ if (parse_mode & SEQ_PROMOTE_ACL) {
+ /* if promoting from acl to default acl and
+ a default acl entry is found, fail. */
+ *text_p = backup;
+ goto fail;
+ }
+ cmd->c_type = ACL_TYPE_DEFAULT;
+ }
+ }
+
+ /* parse acl entry type */
+ switch (**text_p) {
+ case 'u': /* user */
+ skip_tag_name(text_p, "user");
+
+user_entry:
+ backup = *text_p;
+ str = get_token(text_p);
+ if (str) {
+ cmd->c_tag = ACL_USER;
+ error = get_uid(unquote(str), &cmd->c_id);
+ free(str);
+ if (error) {
+ *text_p = backup;
+ goto fail;
+ }
+ } else {
+ cmd->c_tag = ACL_USER_OBJ;
+ }
+ break;
+
+ case 'g': /* group */
+ if (!skip_tag_name(text_p, "group"))
+ goto user_entry;
+
+ backup = *text_p;
+ str = get_token(text_p);
+ if (str) {
+ cmd->c_tag = ACL_GROUP;
+ error = get_gid(unquote(str), &cmd->c_id);
+ free(str);
+ if (error) {
+ *text_p = backup;
+ goto fail;
+ }
+ } else {
+ cmd->c_tag = ACL_GROUP_OBJ;
+ }
+ break;
+
+ case 'o': /* other */
+ if (!skip_tag_name(text_p, "other"))
+ goto user_entry;
+ /* skip empty entry qualifier field (this field may
+ be missing for compatibility with Solaris.) */
+ SKIP_WS(*text_p);
+ if (**text_p == ':')
+ (*text_p)++;
+ cmd->c_tag = ACL_OTHER;
+ break;
+
+ case 'm': /* mask */
+ if (!skip_tag_name(text_p, "mask"))
+ goto user_entry;
+ /* skip empty entry qualifier field (this field may
+ be missing for compatibility with Solaris.) */
+ SKIP_WS(*text_p);
+ if (**text_p == ':')
+ (*text_p)++;
+ cmd->c_tag = ACL_MASK;
+ break;
+
+ default: /* assume "user:" */
+ goto user_entry;
+ }
+
+ SKIP_WS(*text_p);
+ if (**text_p == ',' || **text_p == '\0') {
+ if (parse_mode & SEQ_PARSE_NO_PERM)
+ return cmd;
+ else
+ goto fail;
+ }
+ if (!(parse_mode & SEQ_PARSE_WITH_PERM))
+ return cmd;
+
+ /* parse permissions */
+ SKIP_WS(*text_p);
+ if (**text_p >= '0' && **text_p <= '7') {
+ cmd->c_perm = 0;
+ while (**text_p == '0')
+ (*text_p)++;
+ if (**text_p >= '1' && **text_p <= '7') {
+ cmd->c_perm = (*(*text_p)++ - '0');
+ }
+
+ return cmd;
+ }
+
+ for (perm_chars=0; perm_chars<3; perm_chars++, (*text_p)++) {
+ switch(**text_p) {
+ case 'r': /* read */
+ if (cmd->c_perm & CMD_PERM_READ)
+ goto fail;
+ cmd->c_perm |= CMD_PERM_READ;
+ break;
+
+ case 'w': /* write */
+ if (cmd->c_perm & CMD_PERM_WRITE)
+ goto fail;
+ cmd->c_perm |= CMD_PERM_WRITE;
+ break;
+
+ case 'x': /* execute */
+ if (cmd->c_perm & CMD_PERM_EXECUTE)
+ goto fail;
+ cmd->c_perm |= CMD_PERM_EXECUTE;
+ break;
+
+ case 'X': /* execute only if directory or some
+ entries already have execute permissions
+ set */
+ if (cmd->c_perm & CMD_PERM_COND_EXECUTE)
+ goto fail;
+ cmd->c_perm |= CMD_PERM_COND_EXECUTE;
+ break;
+
+ case '-':
+ /* ignore */
+ break;
+
+ default:
+ if (perm_chars == 0)
+ goto fail;
+ return cmd;
+ }
+ }
+ if (perm_chars != 3)
+ goto fail;
+ return cmd;
+
+fail:
+ cmd_free(cmd);
+ return NULL;
+}
+
+
+/*
+ Parse a comma-separated list of acl entries.
+
+ which is set to the index of the first character that was not parsed,
+ or -1 in case of success.
+*/
+int
+parse_acl_seq(
+ seq_t seq,
+ const char *text_p,
+ int *which,
+ int seq_cmd,
+ int parse_mode)
+{
+ const char *initial_text_p = text_p;
+ cmd_t cmd;
+
+ if (which)
+ *which = -1;
+
+ while (*text_p != '\0') {
+ cmd = parse_acl_cmd(&text_p, seq_cmd, parse_mode);
+ if (cmd == NULL) {
+ errno = EINVAL;
+ goto fail;
+ }
+ if (seq_append(seq, cmd) != 0) {
+ cmd_free(cmd);
+ goto fail;
+ }
+ SKIP_WS(text_p);
+ if (*text_p != ',')
+ break;
+ text_p++;
+ }
+
+ if (*text_p != '\0') {
+ errno = EINVAL;
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ if (which)
+ *which = (text_p - initial_text_p);
+ return -1;
+}
+
+
+
+int
+read_acl_comments(
+ FILE *file,
+ int *line,
+ char **path_p,
+ uid_t *uid_p,
+ gid_t *gid_p,
+ mode_t *flags)
+{
+ int c;
+ /*
+ Max PATH_MAX bytes even for UTF-8 path names and additional 9
+ bytes for "# file: ". Not a good solution but for now it is the
+ best I can do without too much impact on the code. [tw]
+ */
+ char linebuf[(4*PATH_MAX)+9];
+ char *cp;
+ char *p;
+ int comments_read = 0;
+
+ if (path_p)
+ *path_p = NULL;
+ if (uid_p)
+ *uid_p = ACL_UNDEFINED_ID;
+ if (gid_p)
+ *gid_p = ACL_UNDEFINED_ID;
+ if (flags)
+ *flags = 0;
+
+ for(;;) {
+ c = fgetc(file);
+ if (c == EOF)
+ break;
+ if (c==' ' || c=='\t' || c=='\r' || c=='\n') {
+ if (c=='\n')
+ (*line)++;
+ continue;
+ }
+ if (c != '#') {
+ ungetc(c, file);
+ break;
+ }
+ if (line)
+ (*line)++;
+
+ if (fgets(linebuf, sizeof(linebuf), file) == NULL)
+ break;
+
+ comments_read = 1;
+
+ p = strrchr(linebuf, '\0');
+ while (p > linebuf &&
+ (*(p-1)=='\r' || *(p-1)=='\n')) {
+ p--;
+ *p = '\0';
+ }
+
+ cp = linebuf;
+ SKIP_WS(cp);
+ if (strncmp(cp, "file:", 5) == 0) {
+ cp += 5;
+ SKIP_WS(cp);
+ cp = unquote(cp);
+
+ if (path_p) {
+ if (*path_p)
+ goto fail;
+ *path_p = (char*)malloc(strlen(cp)+1);
+ if (!*path_p)
+ return -1;
+ strcpy(*path_p, cp);
+ }
+ } else if (strncmp(cp, "owner:", 6) == 0) {
+ cp += 6;
+ SKIP_WS(cp);
+
+ if (uid_p) {
+ if (*uid_p != ACL_UNDEFINED_ID)
+ goto fail;
+ if (get_uid(unquote(cp), uid_p) != 0)
+ continue;
+ }
+ } else if (strncmp(cp, "group:", 6) == 0) {
+ cp += 6;
+ SKIP_WS(cp);
+
+ if (gid_p) {
+ if (*gid_p != ACL_UNDEFINED_ID)
+ goto fail;
+ if (get_gid(unquote(cp), gid_p) != 0)
+ continue;
+ }
+ } else if (strncmp(cp, "flags:", 6) == 0) {
+ mode_t f = 0;
+
+ cp += 6;
+ SKIP_WS(cp);
+
+ if (cp[0] == 's')
+ f |= S_ISUID;
+ else if (cp[0] != '-')
+ goto fail;
+ if (cp[1] == 's')
+ f |= S_ISGID;
+ else if (cp[1] != '-')
+ goto fail;
+ if (cp[2] == 't')
+ f |= S_ISVTX;
+ else if (cp[2] != '-')
+ goto fail;
+ if (cp[3] != '\0')
+ goto fail;
+
+ if (flags)
+ *flags = f;
+ }
+ }
+ if (ferror(file))
+ return -1;
+ return comments_read;
+fail:
+ if (path_p && *path_p) {
+ free(*path_p);
+ *path_p = NULL;
+ }
+ return -EINVAL;
+}
+
+
+int
+read_acl_seq(
+ FILE *file,
+ seq_t seq,
+ int seq_cmd,
+ int parse_mode,
+ int *line,
+ int *which)
+{
+ char linebuf[1024];
+ const char *cp;
+ cmd_t cmd;
+
+ if (which)
+ *which = -1;
+
+ for(;;) {
+ if (fgets(linebuf, sizeof(linebuf), file) == NULL)
+ break;
+ if (line)
+ (*line)++;
+
+ cp = linebuf;
+ SKIP_WS(cp);
+ if (*cp == '\0') {
+ if (!(parse_mode & SEQ_PARSE_MULTI))
+ continue;
+ break;
+ } else if (*cp == '#') {
+ continue;
+ }
+
+ cmd = parse_acl_cmd(&cp, seq_cmd, parse_mode);
+ if (cmd == NULL) {
+ errno = EINVAL;
+ goto fail;
+ }
+ if (seq_append(seq, cmd) != 0) {
+ cmd_free(cmd);
+ goto fail;
+ }
+
+ SKIP_WS(cp);
+ if (*cp != '\0' && *cp != '#') {
+ errno = EINVAL;
+ goto fail;
+ }
+ }
+
+ if (ferror(file))
+ goto fail;
+ return 0;
+
+fail:
+ if (which)
+ *which = (cp - linebuf);
+ return -1;
+}
+
diff --git a/tools/parse.h b/tools/parse.h
new file mode 100644
index 0000000..b2e68b4
--- /dev/null
+++ b/tools/parse.h
@@ -0,0 +1,85 @@
+/*
+ File: parse.h
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999 by Andreas Gruenbacher
+ <a.gruenbacher@computer.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __PARSE_H
+#define __PARSE_H
+
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include "sequence.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* parse options */
+
+#define SEQ_PARSE_WITH_PERM (0x0001)
+#define SEQ_PARSE_NO_PERM (0x0002)
+#define SEQ_PARSE_ANY_PERM (0x0001|0x0002)
+
+#define SEQ_PARSE_MULTI (0x0010)
+#define SEQ_PARSE_DEFAULT (0x0020) /* "default:" = default acl */
+
+#define SEQ_PROMOTE_ACL (0x0040) /* promote from acl
+ to default acl */
+
+cmd_t
+parse_acl_cmd(
+ const char **text_p,
+ int seq_cmd,
+ int parse_mode);
+int
+parse_acl_seq(
+ seq_t seq,
+ const char *text_p,
+ int *which,
+ int seq_cmd,
+ int parse_mode);
+int
+read_acl_comments(
+ FILE *file,
+ int *line,
+ char **path_p,
+ uid_t *uid_p,
+ gid_t *gid_p,
+ mode_t *flags);
+int
+read_acl_seq(
+ FILE *file,
+ seq_t seq,
+ int seq_cmd,
+ int parse_mode,
+ int *line,
+ int *which);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __PARSE_H */
+
diff --git a/tools/sequence.c b/tools/sequence.c
new file mode 100644
index 0000000..a418b23
--- /dev/null
+++ b/tools/sequence.c
@@ -0,0 +1,162 @@
+/*
+ File: sequence.c
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999, 2000
+ Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include <stdlib.h>
+#include "sequence.h"
+
+
+cmd_t
+cmd_init(
+ void)
+{
+ return (cmd_t)malloc(sizeof(struct cmd_obj));
+}
+
+
+void
+cmd_free(
+ cmd_t cmd)
+{
+ free(cmd);
+}
+
+
+seq_t
+seq_init(
+ void)
+{
+ seq_t seq = (seq_t)malloc(sizeof(struct seq_obj));
+ if (seq == NULL)
+ return NULL;
+ seq->s_first = seq->s_last = NULL;
+ return seq;
+}
+
+
+int
+seq_free(
+ seq_t seq)
+{
+ cmd_t cmd = seq->s_first;
+ while (cmd) {
+ seq->s_first = seq->s_first->c_next;
+ cmd_free(cmd);
+ cmd = seq->s_first;
+ }
+ free(seq);
+ return 0;
+}
+
+
+int
+seq_empty(
+ seq_t seq)
+{
+ return (seq->s_first == NULL);
+}
+
+
+int
+seq_append(
+ seq_t seq,
+ cmd_t cmd)
+{
+ cmd->c_next = NULL;
+ if (seq->s_first == NULL) {
+ seq->s_first = seq->s_last = cmd;
+ } else {
+ seq->s_last->c_next = cmd;
+ seq->s_last = cmd;
+ }
+ return 0;
+}
+
+
+int
+seq_append_cmd(
+ seq_t seq,
+ cmd_tag_t cmd,
+ acl_type_t type)
+{
+ cmd_t cmd_d = cmd_init();
+ if (cmd_d == NULL)
+ return -1;
+ cmd_d->c_cmd = cmd;
+ cmd_d->c_type = type;
+ if (seq_append(seq, cmd_d) != 0) {
+ cmd_free(cmd_d);
+ return -1;
+ }
+ return 0;
+}
+
+
+int
+seq_get_cmd(
+ seq_t seq,
+ int which,
+ cmd_t *cmd)
+{
+ if (which == SEQ_FIRST_CMD) {
+ if (seq->s_first == NULL)
+ return 0;
+ if (cmd)
+ *cmd = seq->s_first;
+ return 1;
+ } else if (which == SEQ_NEXT_CMD) {
+ if (cmd == NULL)
+ return -1;
+ if (*cmd) {
+ *cmd = (*cmd)->c_next;
+ return (*cmd == NULL) ? 0 : 1;
+ }
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+
+int
+seq_delete_cmd(
+ seq_t seq,
+ cmd_t cmd)
+{
+ cmd_t prev = seq->s_first;
+
+ if (cmd == seq->s_first) {
+ seq->s_first = seq->s_first->c_next;
+ cmd_free(cmd);
+ return 0;
+ }
+ while (prev != NULL && prev->c_next != cmd)
+ prev = prev->c_next;
+ if (prev == NULL)
+ return -1;
+ if (cmd == seq->s_last)
+ seq->s_last = prev;
+ prev->c_next = cmd->c_next;
+ cmd_free(cmd);
+ return 0;
+}
+
diff --git a/tools/sequence.h b/tools/sequence.h
new file mode 100644
index 0000000..c5d7403
--- /dev/null
+++ b/tools/sequence.h
@@ -0,0 +1,115 @@
+/*
+ File: sequence.h
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999 by Andreas Gruenbacher
+ <a.gruenbacher@computer.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#ifndef __SEQUENCE_H
+#define __SEQUENCE_H
+
+
+#include <sys/acl.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef unsigned int cmd_tag_t;
+
+struct cmd_obj {
+ cmd_tag_t c_cmd;
+ acl_type_t c_type;
+ acl_tag_t c_tag;
+ uid_t c_id;
+ mode_t c_perm;
+ struct cmd_obj *c_next;
+};
+
+typedef struct cmd_obj *cmd_t;
+
+struct seq_obj {
+ cmd_t s_first;
+ cmd_t s_last;
+};
+
+typedef struct seq_obj *seq_t;
+
+/* command types */
+#define CMD_ENTRY_REPLACE (0)
+#define CMD_REMOVE_ENTRY (3)
+#define CMD_REMOVE_EXTENDED_ACL (4)
+#define CMD_REMOVE_ACL (5)
+
+/* constants for permission specifiers */
+#define CMD_PERM_READ (4)
+#define CMD_PERM_WRITE (2)
+#define CMD_PERM_EXECUTE (1)
+#define CMD_PERM_COND_EXECUTE (8)
+
+/* iteration over command sequence */
+#define SEQ_FIRST_CMD (0)
+#define SEQ_NEXT_CMD (1)
+
+/* command sequence manipulation */
+
+cmd_t
+cmd_init(
+ void);
+void
+cmd_free(
+ cmd_t cmd);
+seq_t
+seq_init(
+ void);
+int
+seq_free(
+ seq_t seq);
+int
+seq_empty(
+ seq_t seq);
+int
+seq_append(
+ seq_t seq,
+ cmd_t cmd);
+int
+seq_append_cmd(
+ seq_t seq,
+ cmd_tag_t cmd,
+ acl_type_t type);
+int
+seq_get_cmd(
+ seq_t seq,
+ int which,
+ cmd_t *cmd);
+int
+seq_delete_cmd(
+ seq_t seq,
+ cmd_t cmd);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __SEQUENCE_H */
+
diff --git a/tools/setfacl.c b/tools/setfacl.c
new file mode 100644
index 0000000..f6135b7
--- /dev/null
+++ b/tools/setfacl.c
@@ -0,0 +1,669 @@
+/*
+ File: setfacl.c
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999-2002
+ Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "config.h"
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <libgen.h>
+#include <getopt.h>
+#include "misc.h"
+#include "sequence.h"
+#include "parse.h"
+#include "do_set.h"
+#include "walk_tree.h"
+
+#define POSIXLY_CORRECT_STR "POSIXLY_CORRECT"
+
+/* '-' stands for `process non-option arguments in loop' */
+#if !POSIXLY_CORRECT
+# define CMD_LINE_OPTIONS "-:bkndvhm:M:x:X:RLP"
+# define CMD_LINE_SPEC "[-bkndRLP] { -m|-M|-x|-X ... } file ..."
+#endif
+#define POSIXLY_CMD_LINE_OPTIONS "-:bkndvhm:M:x:X:"
+#define POSIXLY_CMD_LINE_SPEC "[-bknd] {-m|-M|-x|-X ... } file ..."
+
+struct option long_options[] = {
+#if !POSIXLY_CORRECT
+ { "set", 1, 0, 's' },
+ { "set-file", 1, 0, 'S' },
+
+ { "mask", 0, 0, 'r' },
+ { "recursive", 0, 0, 'R' },
+ { "logical", 0, 0, 'L' },
+ { "physical", 0, 0, 'P' },
+ { "restore", 1, 0, 'B' },
+ { "test", 0, 0, 't' },
+#endif
+ { "modify", 1, 0, 'm' },
+ { "modify-file", 1, 0, 'M' },
+ { "remove", 1, 0, 'x' },
+ { "remove-file", 1, 0, 'X' },
+
+ { "default", 0, 0, 'd' },
+ { "no-mask", 0, 0, 'n' },
+ { "remove-all", 0, 0, 'b' },
+ { "remove-default", 0, 0, 'k' },
+ { "version", 0, 0, 'v' },
+ { "help", 0, 0, 'h' },
+ { NULL, 0, 0, 0 },
+};
+
+const char *progname;
+const char *cmd_line_options, *cmd_line_spec;
+
+int walk_flags = WALK_TREE_DEREFERENCE_TOPLEVEL;
+int opt_recalculate; /* recalculate mask entry (0=default, 1=yes, -1=no) */
+int opt_promote; /* promote access ACL to default ACL */
+int opt_test; /* do not write to the file system.
+ Print what would happen instead. */
+#if POSIXLY_CORRECT
+const int posixly_correct = 1; /* Posix compatible behavior! */
+#else
+int posixly_correct; /* Posix compatible behavior? */
+#endif
+int chown_error;
+int promote_warning;
+
+
+static const char *xquote(const char *str, const char *quote_chars)
+{
+ const char *q = quote(str, quote_chars);
+ if (q == NULL) {
+ fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ exit(1);
+ }
+ return q;
+}
+
+int
+has_any_of_type(
+ cmd_t cmd,
+ acl_type_t acl_type)
+{
+ while (cmd) {
+ if (cmd->c_type == acl_type)
+ return 1;
+ cmd = cmd->c_next;
+ }
+ return 0;
+}
+
+
+#if !POSIXLY_CORRECT
+int
+restore(
+ FILE *file,
+ const char *filename)
+{
+ char *path_p;
+ struct stat st;
+ uid_t uid;
+ gid_t gid;
+ mode_t mask, flags;
+ struct do_set_args args = { };
+ int line = 0, backup_line;
+ int error, status = 0;
+ int chmod_required = 0;
+
+ memset(&st, 0, sizeof(st));
+
+ for(;;) {
+ backup_line = line;
+ error = read_acl_comments(file, &line, &path_p, &uid, &gid,
+ &flags);
+ if (error < 0) {
+ error = -error;
+ goto fail;
+ }
+ if (error == 0)
+ return status;
+
+ if (path_p == NULL) {
+ if (filename) {
+ fprintf(stderr, _("%s: %s: No filename found "
+ "in line %d, aborting\n"),
+ progname, xquote(filename, "\n\r"),
+ backup_line);
+ } else {
+ fprintf(stderr, _("%s: No filename found in "
+ "line %d of standard input, "
+ "aborting\n"),
+ progname, backup_line);
+ }
+ status = 1;
+ goto getout;
+ }
+
+ if (!(args.seq = seq_init()))
+ goto fail_errno;
+ if (seq_append_cmd(args.seq, CMD_REMOVE_ACL, ACL_TYPE_ACCESS) ||
+ seq_append_cmd(args.seq, CMD_REMOVE_ACL, ACL_TYPE_DEFAULT))
+ goto fail_errno;
+
+ error = read_acl_seq(file, args.seq, CMD_ENTRY_REPLACE,
+ SEQ_PARSE_WITH_PERM |
+ SEQ_PARSE_DEFAULT |
+ SEQ_PARSE_MULTI,
+ &line, NULL);
+ if (error != 0) {
+ fprintf(stderr, _("%s: %s: %s in line %d\n"),
+ progname, xquote(filename, "\n\r"), strerror(errno),
+ line);
+ status = 1;
+ goto getout;
+ }
+
+ error = stat(path_p, &st);
+ if (opt_test && error != 0) {
+ fprintf(stderr, "%s: %s: %s\n", progname,
+ xquote(path_p, "\n\r"), strerror(errno));
+ status = 1;
+ }
+
+ args.mode = 0;
+ error = do_set(path_p, &st, 0, &args);
+ if (error != 0) {
+ status = 1;
+ goto resume;
+ }
+
+ if (uid != ACL_UNDEFINED_ID && uid != st.st_uid)
+ st.st_uid = uid;
+ else
+ st.st_uid = -1;
+ if (gid != ACL_UNDEFINED_ID && gid != st.st_gid)
+ st.st_gid = gid;
+ else
+ st.st_gid = -1;
+ if (!opt_test &&
+ (st.st_uid != -1 || st.st_gid != -1)) {
+ if (chown(path_p, st.st_uid, st.st_gid) != 0) {
+ fprintf(stderr, _("%s: %s: Cannot change "
+ "owner/group: %s\n"),
+ progname, xquote(path_p, "\n\r"),
+ strerror(errno));
+ status = 1;
+ }
+
+ /* chown() clears setuid/setgid so force a chmod if
+ * S_ISUID/S_ISGID was expected */
+ if ((st.st_mode & flags) & (S_ISUID | S_ISGID))
+ chmod_required = 1;
+ }
+
+ mask = S_ISUID | S_ISGID | S_ISVTX;
+ if (chmod_required || ((st.st_mode & mask) != (flags & mask))) {
+ if (!args.mode)
+ args.mode = st.st_mode;
+ args.mode &= (S_IRWXU | S_IRWXG | S_IRWXO);
+ if (chmod(path_p, flags | args.mode) != 0) {
+ fprintf(stderr, _("%s: %s: Cannot change "
+ "mode: %s\n"),
+ progname, xquote(path_p, "\n\r"),
+ strerror(errno));
+ status = 1;
+ }
+ }
+resume:
+ if (path_p) {
+ free(path_p);
+ path_p = NULL;
+ }
+ if (args.seq) {
+ seq_free(args.seq);
+ args.seq = NULL;
+ }
+ }
+
+getout:
+ if (path_p) {
+ free(path_p);
+ path_p = NULL;
+ }
+ if (args.seq) {
+ seq_free(args.seq);
+ args.seq = NULL;
+ }
+ return status;
+
+fail_errno:
+ error = errno;
+fail:
+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(filename, "\n\r"),
+ strerror(error));
+ status = 1;
+ goto getout;
+}
+#endif
+
+
+void help(void)
+{
+ printf(_("%s %s -- set file access control lists\n"),
+ progname, VERSION);
+ printf(_("Usage: %s %s\n"),
+ progname, cmd_line_spec);
+ printf(_(
+" -m, --modify=acl modify the current ACL(s) of file(s)\n"
+" -M, --modify-file=file read ACL entries to modify from file\n"
+" -x, --remove=acl remove entries from the ACL(s) of file(s)\n"
+" -X, --remove-file=file read ACL entries to remove from file\n"
+" -b, --remove-all remove all extended ACL entries\n"
+" -k, --remove-default remove the default ACL\n"));
+#if !POSIXLY_CORRECT
+ if (!posixly_correct) {
+ printf(_(
+" --set=acl set the ACL of file(s), replacing the current ACL\n"
+" --set-file=file read ACL entries to set from file\n"
+" --mask do recalculate the effective rights mask\n"));
+ }
+#endif
+ printf(_(
+" -n, --no-mask don't recalculate the effective rights mask\n"
+" -d, --default operations apply to the default ACL\n"));
+#if !POSIXLY_CORRECT
+ if (!posixly_correct) {
+ printf(_(
+" -R, --recursive recurse into subdirectories\n"
+" -L, --logical logical walk, follow symbolic links\n"
+" -P, --physical physical walk, do not follow symbolic links\n"
+" --restore=file restore ACLs (inverse of `getfacl -R')\n"
+" --test test mode (ACLs are not modified)\n"));
+ }
+#endif
+ printf(_(
+" -v, --version print version and exit\n"
+" -h, --help this help text\n"));
+}
+
+
+int next_file(const char *arg, seq_t seq)
+{
+ char *line;
+ int errors = 0;
+ struct do_set_args args;
+
+ args.seq = seq;
+
+ if (strcmp(arg, "-") == 0) {
+ while ((line = next_line(stdin)))
+ errors = walk_tree(line, walk_flags, 0, do_set, &args);
+ if (!feof(stdin)) {
+ fprintf(stderr, _("%s: Standard input: %s\n"),
+ progname, strerror(errno));
+ errors = 1;
+ }
+ } else {
+ errors = walk_tree(arg, walk_flags, 0, do_set, &args);
+ }
+ return errors ? 1 : 0;
+}
+
+
+#define ERRNO_ERROR(s) \
+ ({status = (s); goto errno_error; })
+
+
+int main(int argc, char *argv[])
+{
+ int opt;
+ int saw_files = 0;
+ int status = 0;
+ FILE *file;
+ int which;
+ int lineno;
+ int error;
+ seq_t seq;
+ int seq_cmd, parse_mode;
+
+ progname = basename(argv[0]);
+
+#if POSIXLY_CORRECT
+ cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
+ cmd_line_spec = _(POSIXLY_CMD_LINE_SPEC);
+#else
+ if (getenv(POSIXLY_CORRECT_STR))
+ posixly_correct = 1;
+ if (!posixly_correct) {
+ cmd_line_options = CMD_LINE_OPTIONS;
+ cmd_line_spec = _(CMD_LINE_SPEC);
+ } else {
+ cmd_line_options = POSIXLY_CMD_LINE_OPTIONS;
+ cmd_line_spec = _(POSIXLY_CMD_LINE_SPEC);
+ }
+#endif
+
+ setlocale(LC_CTYPE, "");
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ seq = seq_init();
+ if (!seq)
+ ERRNO_ERROR(1);
+
+ while ((opt = getopt_long(argc, argv, cmd_line_options,
+ long_options, NULL)) != -1) {
+ /* we remember the two REMOVE_ACL commands of the set
+ operations because we may later need to delete them. */
+ cmd_t seq_remove_default_acl_cmd = NULL;
+ cmd_t seq_remove_acl_cmd = NULL;
+
+ if (opt != '\1' && saw_files) {
+ seq_free(seq);
+ seq = seq_init();
+ if (!seq)
+ ERRNO_ERROR(1);
+ saw_files = 0;
+ }
+
+ switch (opt) {
+ case 'b': /* remove all extended entries */
+ if (seq_append_cmd(seq, CMD_REMOVE_EXTENDED_ACL,
+ ACL_TYPE_ACCESS) ||
+ seq_append_cmd(seq, CMD_REMOVE_ACL,
+ ACL_TYPE_DEFAULT))
+ ERRNO_ERROR(1);
+ break;
+
+ case 'k': /* remove default ACL */
+ if (seq_append_cmd(seq, CMD_REMOVE_ACL,
+ ACL_TYPE_DEFAULT))
+ ERRNO_ERROR(1);
+ break;
+
+ case 'n': /* do not recalculate mask */
+ opt_recalculate = -1;
+ break;
+
+ case 'r': /* force recalculate mask */
+ opt_recalculate = 1;
+ break;
+
+ case 'd': /* operations apply to default ACL */
+ opt_promote = 1;
+ break;
+
+ case 's': /* set */
+ if (seq_append_cmd(seq, CMD_REMOVE_ACL,
+ ACL_TYPE_ACCESS))
+ ERRNO_ERROR(1);
+ seq_remove_acl_cmd = seq->s_last;
+ if (seq_append_cmd(seq, CMD_REMOVE_ACL,
+ ACL_TYPE_DEFAULT))
+ ERRNO_ERROR(1);
+ seq_remove_default_acl_cmd = seq->s_last;
+
+ seq_cmd = CMD_ENTRY_REPLACE;
+ parse_mode = SEQ_PARSE_WITH_PERM;
+ goto set_modify_delete;
+
+ case 'm': /* modify */
+ seq_cmd = CMD_ENTRY_REPLACE;
+ parse_mode = SEQ_PARSE_WITH_PERM;
+ goto set_modify_delete;
+
+ case 'x': /* delete */
+ seq_cmd = CMD_REMOVE_ENTRY;
+#if POSIXLY_CORRECT
+ parse_mode = SEQ_PARSE_ANY_PERM;
+#else
+ if (posixly_correct)
+ parse_mode = SEQ_PARSE_ANY_PERM;
+ else
+ parse_mode = SEQ_PARSE_NO_PERM;
+#endif
+ goto set_modify_delete;
+
+ set_modify_delete:
+ if (!posixly_correct)
+ parse_mode |= SEQ_PARSE_DEFAULT;
+ if (opt_promote)
+ parse_mode |= SEQ_PROMOTE_ACL;
+ if (parse_acl_seq(seq, optarg, &which,
+ seq_cmd, parse_mode) != 0) {
+ if (which < 0 ||
+ (size_t) which >= strlen(optarg)) {
+ fprintf(stderr, _(
+ "%s: Option "
+ "-%c incomplete\n"),
+ progname, opt);
+ } else {
+ fprintf(stderr, _(
+ "%s: Option "
+ "-%c: %s near "
+ "character %d\n"),
+ progname, opt,
+ strerror(errno),
+ which+1);
+ }
+ status = 2;
+ goto cleanup;
+ }
+ break;
+
+ case 'S': /* set from file */
+ if (seq_append_cmd(seq, CMD_REMOVE_ACL,
+ ACL_TYPE_ACCESS))
+ ERRNO_ERROR(1);
+ seq_remove_acl_cmd = seq->s_last;
+ if (seq_append_cmd(seq, CMD_REMOVE_ACL,
+ ACL_TYPE_DEFAULT))
+ ERRNO_ERROR(1);
+ seq_remove_default_acl_cmd = seq->s_last;
+
+ seq_cmd = CMD_ENTRY_REPLACE;
+ parse_mode = SEQ_PARSE_WITH_PERM;
+ goto set_modify_delete_from_file;
+
+ case 'M': /* modify from file */
+ seq_cmd = CMD_ENTRY_REPLACE;
+ parse_mode = SEQ_PARSE_WITH_PERM;
+ goto set_modify_delete_from_file;
+
+ case 'X': /* delete from file */
+ seq_cmd = CMD_REMOVE_ENTRY;
+#if POSIXLY_CORRECT
+ parse_mode = SEQ_PARSE_ANY_PERM;
+#else
+ if (posixly_correct)
+ parse_mode = SEQ_PARSE_ANY_PERM;
+ else
+ parse_mode = SEQ_PARSE_NO_PERM;
+#endif
+ goto set_modify_delete_from_file;
+
+ set_modify_delete_from_file:
+ if (!posixly_correct)
+ parse_mode |= SEQ_PARSE_DEFAULT;
+ if (opt_promote)
+ parse_mode |= SEQ_PROMOTE_ACL;
+ if (strcmp(optarg, "-") == 0) {
+ file = stdin;
+ } else {
+ file = fopen(optarg, "r");
+ if (file == NULL) {
+ fprintf(stderr, "%s: %s: %s\n",
+ progname,
+ xquote(optarg, "\n\r"),
+ strerror(errno));
+ status = 2;
+ goto cleanup;
+ }
+ }
+
+ lineno = 0;
+ error = read_acl_seq(file, seq, seq_cmd,
+ parse_mode, &lineno, NULL);
+
+ if (file != stdin) {
+ fclose(file);
+ }
+
+ if (error) {
+ if (!errno)
+ errno = EINVAL;
+
+ if (file != stdin) {
+ fprintf(stderr, _(
+ "%s: %s in line "
+ "%d of file %s\n"),
+ progname,
+ strerror(errno),
+ lineno,
+ xquote(optarg, "\n\r"));
+ } else {
+ fprintf(stderr, _(
+ "%s: %s in line "
+ "%d of standard "
+ "input\n"), progname,
+ strerror(errno),
+ lineno);
+ }
+ status = 2;
+ goto cleanup;
+ }
+ break;
+
+
+ case '\1': /* file argument */
+ if (seq_empty(seq))
+ goto synopsis;
+ saw_files = 1;
+
+ status = next_file(optarg, seq);
+ break;
+
+ case 'B': /* restore ACL backup */
+ saw_files = 1;
+
+ if (strcmp(optarg, "-") == 0)
+ file = stdin;
+ else {
+ file = fopen(optarg, "r");
+ if (file == NULL) {
+ fprintf(stderr, "%s: %s: %s\n",
+ progname,
+ xquote(optarg, "\n\r"),
+ strerror(errno));
+ status = 2;
+ goto cleanup;
+ }
+ }
+
+ status = restore(file,
+ (file == stdin) ? NULL : optarg);
+
+ if (file != stdin)
+ fclose(file);
+ if (status != 0)
+ goto cleanup;
+ break;
+
+ case 'R': /* recursive */
+ walk_flags |= WALK_TREE_RECURSIVE;
+ break;
+
+ case 'L': /* follow symlinks */
+ walk_flags |= WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE;
+ walk_flags &= ~WALK_TREE_PHYSICAL;
+ break;
+
+ case 'P': /* do not follow symlinks */
+ walk_flags |= WALK_TREE_PHYSICAL;
+ walk_flags &= ~(WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE |
+ WALK_TREE_DEREFERENCE_TOPLEVEL);
+ break;
+
+ case 't': /* test mode */
+ opt_test = 1;
+ break;
+
+ case 'v': /* print version and exit */
+ printf("%s " VERSION "\n", progname);
+ status = 0;
+ goto cleanup;
+
+ case 'h': /* help! */
+ help();
+ status = 0;
+ goto cleanup;
+
+ case ':': /* option missing */
+ case '?': /* unknown option */
+ default:
+ goto synopsis;
+ }
+ if (seq_remove_acl_cmd) {
+ /* This was a set operation. Check if there are
+ actually entries of ACL_TYPE_ACCESS; if there
+ are none, we need to remove this command! */
+ if (!has_any_of_type(seq_remove_acl_cmd->c_next,
+ ACL_TYPE_ACCESS))
+ seq_delete_cmd(seq, seq_remove_acl_cmd);
+ }
+ if (seq_remove_default_acl_cmd) {
+ /* This was a set operation. Check if there are
+ actually entries of ACL_TYPE_DEFAULT; if there
+ are none, we need to remove this command! */
+ if (!has_any_of_type(seq_remove_default_acl_cmd->c_next,
+ ACL_TYPE_DEFAULT))
+ seq_delete_cmd(seq, seq_remove_default_acl_cmd);
+ }
+ }
+ while (optind < argc) {
+ if(!seq)
+ goto synopsis;
+ if (seq_empty(seq))
+ goto synopsis;
+ saw_files = 1;
+
+ status = next_file(argv[optind++], seq);
+ }
+ if (!saw_files)
+ goto synopsis;
+
+ goto cleanup;
+
+synopsis:
+ fprintf(stderr, _("Usage: %s %s\n"),
+ progname, cmd_line_spec);
+ fprintf(stderr, _("Try `%s --help' for more information.\n"),
+ progname);
+ status = 2;
+ goto cleanup;
+
+errno_error:
+ fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ goto cleanup;
+
+cleanup:
+ if (seq)
+ seq_free(seq);
+ return status;
+}
+
diff --git a/tools/user_group.c b/tools/user_group.c
new file mode 100644
index 0000000..61fa0c3
--- /dev/null
+++ b/tools/user_group.c
@@ -0,0 +1,59 @@
+/*
+ File: user_group.c
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999, 2000
+ Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "user_group.h"
+
+
+const char *
+user_name(uid_t uid, int numeric)
+{
+ struct passwd *passwd = numeric ? NULL : getpwuid(uid);
+ static char uid_str[22];
+ int ret;
+
+ if (passwd != NULL)
+ return passwd->pw_name;
+ ret = snprintf(uid_str, sizeof(uid_str), "%ld", (long)uid);
+ if (ret < 1 || (size_t)ret >= sizeof(uid_str))
+ return "?";
+ return uid_str;
+}
+
+
+const char *
+group_name(gid_t gid, int numeric)
+{
+ struct group *group = numeric ? NULL : getgrgid(gid);
+ static char gid_str[22];
+ int ret;
+
+ if (group != NULL)
+ return group->gr_name;
+ ret = snprintf(gid_str, sizeof(gid_str), "%ld", (long)gid);
+ if (ret < 1 || (size_t)ret >= sizeof(gid_str))
+ return "?";
+ return gid_str;
+}
+
diff --git a/tools/user_group.h b/tools/user_group.h
new file mode 100644
index 0000000..aad5846
--- /dev/null
+++ b/tools/user_group.h
@@ -0,0 +1,31 @@
+/*
+ File: user_group.h
+ (Linux Access Control List Management)
+
+ Copyright (C) 1999 by Andreas Gruenbacher
+ <a.gruenbacher@computer.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+
+const char *
+user_name(uid_t uid, int numeric);
+const char *
+group_name(gid_t uid, int numeric);
+
--
2.5.2