Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add ACL support for FFS. From FreeBSD.



details:   https://anonhg.NetBSD.org/src/rev/7dd756db7608
branches:  trunk
changeset: 932805:7dd756db7608
user:      christos <christos%NetBSD.org@localhost>
date:      Sat May 16 18:31:45 2020 +0000

description:
Add ACL support for FFS. From FreeBSD.

diffstat:

 bin/Makefile                                            |    8 +-
 bin/cp/cp.c                                             |   24 +-
 bin/cp/extern.h                                         |    4 +-
 bin/cp/utils.c                                          |  148 +++-
 bin/getfacl/Makefile                                    |    6 +
 bin/getfacl/getfacl.1                                   |  138 +++
 bin/getfacl/getfacl.c                                   |  348 +++++++
 bin/ls/ls.1                                             |   16 +-
 bin/ls/print.c                                          |   78 +-
 bin/setfacl/Makefile                                    |    7 +
 bin/setfacl/file.c                                      |   82 +
 bin/setfacl/mask.c                                      |  120 ++
 bin/setfacl/merge.c                                     |  299 ++++++
 bin/setfacl/remove.c                                    |  179 ++++
 bin/setfacl/setfacl.1                                   |  517 +++++++++++
 bin/setfacl/setfacl.c                                   |  511 +++++++++++
 bin/setfacl/setfacl.h                                   |   64 +
 bin/setfacl/util.c                                      |   85 +
 distrib/sets/lists/base/mi                              |    4 +-
 distrib/sets/lists/comp/mi                              |  170 +++-
 distrib/sets/lists/debug/mi                             |    4 +-
 distrib/sets/lists/man/mi                               |    8 +-
 external/bsd/libarchive/include/config_netbsd.h         |   82 +-
 external/bsd/libarchive/lib/libarchive/Makefile         |    3 +-
 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c |    2 +-
 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c  |   20 +-
 external/cddl/osnet/sys/kern/policy.c                   |    4 +-
 external/cddl/osnet/sys/sys/policy.h                    |    4 +-
 include/mntopts.h                                       |    4 +-
 include/unistd.h                                        |    3 +-
 lib/libc/Makefile                                       |    3 +-
 lib/libc/posix1e/Makefile.inc                           |   89 ++
 lib/libc/posix1e/acl.3                                  |  307 +++++++
 lib/libc/posix1e/acl_add_flag_np.3                      |   98 ++
 lib/libc/posix1e/acl_add_perm.3                         |  129 ++
 lib/libc/posix1e/acl_branding.c                         |  175 ++++
 lib/libc/posix1e/acl_calc_mask.3                        |   98 ++
 lib/libc/posix1e/acl_calc_mask.c                        |  136 +++
 lib/libc/posix1e/acl_clear_flags_np.3                   |   79 +
 lib/libc/posix1e/acl_clear_perms.3                      |   79 +
 lib/libc/posix1e/acl_compat.c                           |   69 +
 lib/libc/posix1e/acl_copy.c                             |   91 ++
 lib/libc/posix1e/acl_copy_entry.3                       |   85 +
 lib/libc/posix1e/acl_create_entry.3                     |   98 ++
 lib/libc/posix1e/acl_delete.3                           |  140 +++
 lib/libc/posix1e/acl_delete.c                           |   84 +
 lib/libc/posix1e/acl_delete_entry.3                     |  101 ++
 lib/libc/posix1e/acl_delete_entry.c                     |  165 +++
 lib/libc/posix1e/acl_delete_flag_np.3                   |   84 +
 lib/libc/posix1e/acl_delete_perm.3                      |   84 +
 lib/libc/posix1e/acl_dup.3                              |  110 ++
 lib/libc/posix1e/acl_entry.c                            |  151 +++
 lib/libc/posix1e/acl_flag.c                             |  161 +++
 lib/libc/posix1e/acl_free.3                             |   89 ++
 lib/libc/posix1e/acl_free.c                             |   59 +
 lib/libc/posix1e/acl_from_text.3                        |  130 ++
 lib/libc/posix1e/acl_from_text.c                        |  318 +++++++
 lib/libc/posix1e/acl_from_text_nfs4.c                   |  289 ++++++
 lib/libc/posix1e/acl_get.3                              |  168 +++
 lib/libc/posix1e/acl_get.c                              |  221 +++++
 lib/libc/posix1e/acl_get_brand_np.3                     |   86 +
 lib/libc/posix1e/acl_get_entry.3                        |  145 +++
 lib/libc/posix1e/acl_get_entry_type_np.3                |   80 +
 lib/libc/posix1e/acl_get_flag_np.3                      |   94 ++
 lib/libc/posix1e/acl_get_flagset_np.3                   |   83 +
 lib/libc/posix1e/acl_get_perm_np.3                      |   94 ++
 lib/libc/posix1e/acl_get_permset.3                      |   83 +
 lib/libc/posix1e/acl_get_qualifier.3                    |  140 +++
 lib/libc/posix1e/acl_get_tag_type.3                     |   85 +
 lib/libc/posix1e/acl_id_to_name.c                       |  105 ++
 lib/libc/posix1e/acl_init.3                             |  111 ++
 lib/libc/posix1e/acl_init.c                             |   94 ++
 lib/libc/posix1e/acl_is_trivial_np.3                    |   85 +
 lib/libc/posix1e/acl_perm.c                             |  133 +++
 lib/libc/posix1e/acl_set.3                              |  157 +++
 lib/libc/posix1e/acl_set.c                              |  258 +++++
 lib/libc/posix1e/acl_set_entry_type_np.3                |   94 ++
 lib/libc/posix1e/acl_set_flagset_np.3                   |   85 +
 lib/libc/posix1e/acl_set_permset.3                      |   81 +
 lib/libc/posix1e/acl_set_qualifier.3                    |   91 ++
 lib/libc/posix1e/acl_set_tag_type.3                     |  102 ++
 lib/libc/posix1e/acl_strip.c                            |  222 +++++
 lib/libc/posix1e/acl_strip_np.3                         |  109 ++
 lib/libc/posix1e/acl_support.c                          |  423 +++++++++
 lib/libc/posix1e/acl_support.h                          |   70 +
 lib/libc/posix1e/acl_support_nfs4.c                     |  267 ++++++
 lib/libc/posix1e/acl_to_text.3                          |  159 +++
 lib/libc/posix1e/acl_to_text.c                          |  267 ++++++
 lib/libc/posix1e/acl_to_text_nfs4.c                     |  271 ++++++
 lib/libc/posix1e/acl_valid.3                            |  170 +++
 lib/libc/posix1e/acl_valid.c                            |  129 ++
 lib/libc/posix1e/extattr.3                              |  100 ++
 lib/libc/posix1e/extattr.c                              |   83 +
 lib/libc/posix1e/posix1e.3                              |  118 ++
 lib/libc/sys/Makefile.inc                               |   12 +-
 lib/libc/sys/makelintstub                               |    3 +-
 sbin/mount_ffs/mount_ffs.c                              |    6 +-
 sbin/tunefs/tunefs.8                                    |   10 +-
 sbin/tunefs/tunefs.c                                    |   95 +-
 sys/arch/amd64/amd64/genassym.cf                        |    3 +-
 sys/arch/amd64/conf/GENERIC                             |    5 +-
 sys/coda/coda_vnops.c                                   |   14 +-
 sys/compat/netbsd32/files.netbsd32                      |    3 +-
 sys/compat/netbsd32/netbsd32.h                          |    3 +-
 sys/compat/netbsd32/netbsd32_acl.c                      |  216 ++++
 sys/compat/netbsd32/netbsd32_netbsd.c                   |   19 +-
 sys/compat/netbsd32/netbsd32_syscall.h                  |   43 +-
 sys/compat/netbsd32/netbsd32_syscallargs.h              |  115 ++-
 sys/compat/netbsd32/netbsd32_syscalls.c                 |   56 +-
 sys/compat/netbsd32/netbsd32_syscalls_autoload.c        |    4 +-
 sys/compat/netbsd32/netbsd32_sysent.c                   |   93 +-
 sys/compat/netbsd32/netbsd32_systrace_args.c            |  376 ++++++++-
 sys/compat/netbsd32/syscalls.master                     |   36 +-
 sys/fs/adosfs/advnops.c                                 |   23 +-
 sys/fs/autofs/autofs_vnops.c                            |    5 +-
 sys/fs/cd9660/cd9660_vnops.c                            |   25 +-
 sys/fs/efs/efs_vnops.c                                  |   25 +-
 sys/fs/filecorefs/filecore_vnops.c                      |   19 +-
 sys/fs/hfs/hfs_vnops.c                                  |   25 +-
 sys/fs/msdosfs/msdosfs_vnops.c                          |   31 +-
 sys/fs/nilfs/nilfs_vnops.c                              |   27 +-
 sys/fs/ntfs/ntfs_vnops.c                                |   23 +-
 sys/fs/ptyfs/ptyfs_vnops.c                              |   25 +-
 sys/fs/puffs/puffs_vnops.c                              |   16 +-
 sys/fs/sysvbfs/sysvbfs.c                                |    5 +-
 sys/fs/sysvbfs/sysvbfs_vnops.c                          |   26 +-
 sys/fs/tmpfs/tmpfs_fifoops.c                            |    5 +-
 sys/fs/tmpfs/tmpfs_specops.c                            |    5 +-
 sys/fs/tmpfs/tmpfs_subr.c                               |   13 +-
 sys/fs/tmpfs/tmpfs_vnops.c                              |   19 +-
 sys/fs/udf/udf_vnops.c                                  |   29 +-
 sys/fs/union/union_vnops.c                              |    9 +-
 sys/fs/unionfs/unionfs_vnops.c                          |    1 +
 sys/fs/v7fs/v7fs_extern.c                               |    7 +-
 sys/fs/v7fs/v7fs_vnops.c                                |   36 +-
 sys/kern/files.kern                                     |    5 +-
 sys/kern/init_sysent.c                                  |  106 +-
 sys/kern/kern_auth.c                                    |   17 +-
 sys/kern/subr_acl_nfs4.c                                |  614 ++++++++++++++
 sys/kern/subr_acl_posix1e.c                             |  338 +++++++
 sys/kern/sys_mqueue.c                                   |   14 +-
 sys/kern/syscalls.c                                     |   57 +-
 sys/kern/syscalls.conf                                  |    4 +-
 sys/kern/syscalls.master                                |   28 +-
 sys/kern/syscalls_autoload.c                            |    5 +-
 sys/kern/systrace_args.c                                |  376 ++++++++-
 sys/kern/vfs_acl.c                                      |  542 ++++++++++++
 sys/kern/vfs_cache.c                                    |   16 +-
 sys/kern/vfs_getcwd.c                                   |   14 +-
 sys/kern/vfs_init.c                                     |    8 +-
 sys/kern/vfs_subr.c                                     |   66 +-
 sys/kern/vfs_syscalls.c                                 |   64 +-
 sys/kern/vfs_xattr.c                                    |    8 +-
 sys/kern/vnode_if.c                                     |  154 +++-
 sys/kern/vnode_if.sh                                    |    4 +-
 sys/kern/vnode_if.src                                   |   43 +-
 sys/miscfs/fdesc/fdesc_vnops.c                          |    5 +-
 sys/miscfs/fifofs/fifo_vnops.c                          |    5 +-
 sys/miscfs/genfs/genfs.h                                |   26 +-
 sys/miscfs/genfs/genfs_rename.c                         |    6 +-
 sys/miscfs/genfs/genfs_vnops.c                          |  649 +++++++++++++-
 sys/miscfs/genfs/layer_vnops.c                          |   10 +-
 sys/miscfs/kernfs/kernfs_vnops.c                        |   14 +-
 sys/miscfs/nullfs/null_vnops.c                          |    5 +-
 sys/miscfs/overlay/overlay_vnops.c                      |    7 +-
 sys/miscfs/procfs/procfs_vnops.c                        |   13 +-
 sys/miscfs/specfs/spec_vnops.c                          |    5 +-
 sys/miscfs/umapfs/umap_vnops.c                          |    5 +-
 sys/modules/compat_netbsd32/Makefile                    |    3 +-
 sys/modules/ffs/Makefile                                |    4 +-
 sys/modules/ufs/Makefile                                |    6 +-
 sys/nfs/nfs_vnops.c                                     |   44 +-
 sys/rump/fs/lib/libffs/Makefile                         |   10 +-
 sys/rump/include/rump/rump_syscalls.h                   |    7 +-
 sys/rump/include/rump/rumpvnode_if.h                    |   14 +-
 sys/rump/librump/rumpkern/rump_syscalls.c               |  123 +-
 sys/rump/librump/rumpvfs/Makefile.rumpvfs               |   13 +-
 sys/rump/librump/rumpvfs/rumpfs.c                       |   28 +-
 sys/rump/librump/rumpvfs/rumpvnode_if.c                 |   67 +-
 sys/rump/rump.sysmap                                    |    1 +
 sys/sys/Makefile                                        |    4 +-
 sys/sys/acl.h                                           |  440 ++++++++++
 sys/sys/ansi.h                                          |    3 +-
 sys/sys/extattr.h                                       |    4 +-
 sys/sys/fstypes.h                                       |   16 +-
 sys/sys/kauth.h                                         |    6 +-
 sys/sys/namei.h                                         |    9 +-
 sys/sys/namei.src                                       |    4 +-
 sys/sys/statvfs.h                                       |    3 +-
 sys/sys/syscall.h                                       |   43 +-
 sys/sys/syscallargs.h                                   |  140 +++-
 sys/sys/types.h                                         |    7 +-
 sys/sys/unistd.h                                        |    7 +-
 sys/sys/vnode.h                                         |   73 +-
 sys/sys/vnode_if.h                                      |  135 ++-
 sys/ufs/chfs/chfs_subr.c                                |    4 +-
 sys/ufs/chfs/chfs_vnode.c                               |    8 +-
 sys/ufs/chfs/chfs_vnops.c                               |   24 +-
 sys/ufs/ext2fs/ext2fs_lookup.c                          |    6 +-
 sys/ufs/ext2fs/ext2fs_vfsops.c                          |    8 +-
 sys/ufs/ext2fs/ext2fs_vnops.c                           |   32 +-
 sys/ufs/ext2fs/ext2fs_xattr.c                           |   26 +-
 sys/ufs/ffs/ffs_extattr.c                               |   40 +-
 sys/ufs/ffs/ffs_vfsops.c                                |   56 +-
 sys/ufs/ffs/ffs_vnops.c                                 |   23 +-
 sys/ufs/ffs/fs.h                                        |   16 +-
 sys/ufs/files.ufs                                       |    5 +-
 sys/ufs/lfs/lfs_vnops.c                                 |   12 +-
 sys/ufs/lfs/ulfs_extattr.c                              |   68 +-
 sys/ufs/lfs/ulfs_lookup.c                               |    6 +-
 sys/ufs/lfs/ulfs_vnops.c                                |   38 +-
 sys/ufs/mfs/mfs_vnops.c                                 |    5 +-
 sys/ufs/ufs/README.acls                                 |   79 +
 sys/ufs/ufs/acl.h                                       |   62 +
 sys/ufs/ufs/ufs_acl.c                                   |  698 ++++++++++++++++
 sys/ufs/ufs/ufs_extattr.c                               |   67 +-
 sys/ufs/ufs/ufs_extern.h                                |    4 +-
 sys/ufs/ufs/ufs_lookup.c                                |   49 +-
 sys/ufs/ufs/ufs_vnops.c                                 |  456 +++++++++-
 219 files changed, 18135 insertions(+), 1121 deletions(-)

diffs (truncated from 24654 to 300 lines):

diff -r dee849f7cbf3 -r 7dd756db7608 bin/Makefile
--- a/bin/Makefile      Sat May 16 17:52:42 2020 +0000
+++ b/bin/Makefile      Sat May 16 18:31:45 2020 +0000
@@ -1,8 +1,8 @@
-#      $NetBSD: Makefile,v 1.22 2007/12/31 15:31:24 ad Exp $
+#      $NetBSD: Makefile,v 1.23 2020/05/16 18:31:45 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 5/31/93
 
-SUBDIR=        cat chio chmod cp csh date dd df domainname echo ed expr hostname \
-       kill ksh ln ls mkdir mt mv pax ps pwd rcp rcmd rm rmdir sh \
-       sleep stty sync test
+SUBDIR=        cat chio chmod cp csh date dd df domainname echo ed expr getfacl \
+       hostname kill ksh ln ls mkdir mt mv pax ps pwd rcp rcmd rm rmdir \
+       setfacl sh sleep stty sync test
 
 .include <bsd.subdir.mk>
diff -r dee849f7cbf3 -r 7dd756db7608 bin/cp/cp.c
--- a/bin/cp/cp.c       Sat May 16 17:52:42 2020 +0000
+++ b/bin/cp/cp.c       Sat May 16 18:31:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cp.c,v 1.59 2016/03/05 19:48:55 uwe Exp $ */
+/* $NetBSD: cp.c,v 1.60 2020/05/16 18:31:45 christos Exp $ */
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)cp.c       8.5 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: cp.c,v 1.59 2016/03/05 19:48:55 uwe Exp $");
+__RCSID("$NetBSD: cp.c,v 1.60 2020/05/16 18:31:45 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -499,9 +499,23 @@
                                 * umask; arguably wrong, but it's been that way 
                                 * forever.
                                 */
-                               if (pflag && setfile(curr->fts_statp, 0))
-                                       this_failed = any_failed = 1;
-                               else if ((dne = popdne()))
+                               /*
+                                * If -p is in effect, set all the attributes.
+                                * Otherwise, set the correct permissions, limited
+                                * by the umask.  Optimise by avoiding a chmod()
+                                * if possible (which is usually the case if we
+                                * made the directory).  Note that mkdir() does not
+                                * honour setuid, setgid and sticky bits, but we
+                                * normally want to preserve them on directories.
+                                */
+                               if (pflag) {
+                                       if (setfile(curr->fts_statp, 0))
+                                               this_failed = any_failed = 1;
+                                       if (preserve_dir_acls(curr->fts_statp,
+                                           curr->fts_accpath, to.p_path) != 0)
+                                               this_failed = any_failed = 1;
+                               }
+                               if (this_failed && (dne = popdne()))
                                        (void)chmod(to.p_path, 
                                            curr->fts_statp->st_mode);
                        }
diff -r dee849f7cbf3 -r 7dd756db7608 bin/cp/extern.h
--- a/bin/cp/extern.h   Sat May 16 17:52:42 2020 +0000
+++ b/bin/cp/extern.h   Sat May 16 18:31:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.17 2012/01/04 15:58:37 christos Exp $ */
+/* $NetBSD: extern.h,v 1.18 2020/05/16 18:31:45 christos Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -55,6 +55,8 @@
 int    copy_special(struct stat *, int);
 int    set_utimes(const char *, struct stat *);
 int    setfile(struct stat *, int);
+int    preserve_dir_acls(struct stat *, char *, char *);
+int    preserve_fd_acls(int, int);
 void   usage(void) __attribute__((__noreturn__));
 __END_DECLS
 
diff -r dee849f7cbf3 -r 7dd756db7608 bin/cp/utils.c
--- a/bin/cp/utils.c    Sat May 16 17:52:42 2020 +0000
+++ b/bin/cp/utils.c    Sat May 16 18:31:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.c,v 1.47 2019/09/23 18:01:09 christos Exp $ */
+/* $NetBSD: utils.c,v 1.48 2020/05/16 18:31:45 christos Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -34,14 +34,16 @@
 #if 0
 static char sccsid[] = "@(#)utils.c    8.3 (Berkeley) 4/1/94";
 #else
-__RCSID("$NetBSD: utils.c,v 1.47 2019/09/23 18:01:09 christos Exp $");
+__RCSID("$NetBSD: utils.c,v 1.48 2020/05/16 18:31:45 christos Exp $");
 #endif
 #endif /* not lint */
 
+#define _ACL_PRIVATE
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <sys/acl.h>
 #include <sys/extattr.h>
 
 #include <err.h>
@@ -254,6 +256,9 @@
        if (pflag && (fcpxattr(from_fd, to_fd) != 0))
                warn("%s: error copying extended attributes", to.p_path);
 
+       if (pflag && preserve_fd_acls(from_fd, to_fd) != 0)
+               rval = 1;
+
        (void)close(from_fd);
 
        if (rval == 1) {
@@ -403,6 +408,145 @@
        return (rval);
 }
 
+int
+preserve_fd_acls(int source_fd, int dest_fd)
+{
+       acl_t acl;
+       acl_type_t acl_type;
+       int acl_supported = 0, ret, trivial;
+
+       ret = fpathconf(source_fd, _PC_ACL_NFS4);
+       if (ret > 0 ) {
+               acl_supported = 1;
+               acl_type = ACL_TYPE_NFS4;
+       } else if (ret < 0 && errno != EINVAL) {
+               warn("fpathconf(..., _PC_ACL_NFS4) failed for %s", to.p_path);
+               return (1);
+       }
+       if (acl_supported == 0) {
+               ret = fpathconf(source_fd, _PC_ACL_EXTENDED);
+               if (ret > 0 ) {
+                       acl_supported = 1;
+                       acl_type = ACL_TYPE_ACCESS;
+               } else if (ret < 0 && errno != EINVAL) {
+                       warn("fpathconf(..., _PC_ACL_EXTENDED) failed for %s",
+                           to.p_path);
+                       return (1);
+               }
+       }
+       if (acl_supported == 0)
+               return (0);
+
+       acl = acl_get_fd_np(source_fd, acl_type);
+       if (acl == NULL) {
+               warn("failed to get acl entries while setting %s", to.p_path);
+               return (1);
+       }
+       if (acl_is_trivial_np(acl, &trivial)) {
+               warn("acl_is_trivial() failed for %s", to.p_path);
+               acl_free(acl);
+               return (1);
+       }
+       if (trivial) {
+               acl_free(acl);
+               return (0);
+       }
+       if (acl_set_fd_np(dest_fd, acl, acl_type) < 0) {
+               warn("failed to set acl entries for %s", to.p_path);
+               acl_free(acl);
+               return (1);
+       }
+       acl_free(acl);
+       return (0);
+}
+
+int
+preserve_dir_acls(struct stat *fs, char *source_dir, char *dest_dir)
+{
+       acl_t (*aclgetf)(const char *, acl_type_t);
+       int (*aclsetf)(const char *, acl_type_t, acl_t);
+       struct acl *aclp;
+       acl_t acl;
+       acl_type_t acl_type;
+       int acl_supported = 0, ret, trivial;
+
+       ret = pathconf(source_dir, _PC_ACL_NFS4);
+       if (ret > 0) {
+               acl_supported = 1;
+               acl_type = ACL_TYPE_NFS4;
+       } else if (ret < 0 && errno != EINVAL) {
+               warn("fpathconf(..., _PC_ACL_NFS4) failed for %s", source_dir);
+               return (1);
+       }
+       if (acl_supported == 0) {
+               ret = pathconf(source_dir, _PC_ACL_EXTENDED);
+               if (ret > 0) {
+                       acl_supported = 1;
+                       acl_type = ACL_TYPE_ACCESS;
+               } else if (ret < 0 && errno != EINVAL) {
+                       warn("fpathconf(..., _PC_ACL_EXTENDED) failed for %s",
+                           source_dir);
+                       return (1);
+               }
+       }
+       if (acl_supported == 0)
+               return (0);
+
+       /*
+        * If the file is a link we will not follow it.
+        */
+       if (S_ISLNK(fs->st_mode)) {
+               aclgetf = acl_get_link_np;
+               aclsetf = acl_set_link_np;
+       } else {
+               aclgetf = acl_get_file;
+               aclsetf = acl_set_file;
+       }
+       if (acl_type == ACL_TYPE_ACCESS) {
+               /*
+                * Even if there is no ACL_TYPE_DEFAULT entry here, a zero
+                * size ACL will be returned. So it is not safe to simply
+                * check the pointer to see if the default ACL is present.
+                */
+               acl = aclgetf(source_dir, ACL_TYPE_DEFAULT);
+               if (acl == NULL) {
+                       warn("failed to get default acl entries on %s",
+                           source_dir);
+                       return (1);
+               }
+               aclp = &acl->ats_acl;
+               if (aclp->acl_cnt != 0 && aclsetf(dest_dir,
+                   ACL_TYPE_DEFAULT, acl) < 0) {
+                       warn("failed to set default acl entries on %s",
+                           dest_dir);
+                       acl_free(acl);
+                       return (1);
+               }
+               acl_free(acl);
+       }
+       acl = aclgetf(source_dir, acl_type);
+       if (acl == NULL) {
+               warn("failed to get acl entries on %s", source_dir);
+               return (1);
+       }
+       if (acl_is_trivial_np(acl, &trivial)) {
+               warn("acl_is_trivial() failed on %s", source_dir);
+               acl_free(acl);
+               return (1);
+       }
+       if (trivial) {
+               acl_free(acl);
+               return (0);
+       }
+       if (aclsetf(dest_dir, acl_type, acl) < 0) {
+               warn("failed to set acl entries on %s", dest_dir);
+               acl_free(acl);
+               return (1);
+       }
+       acl_free(acl);
+       return (0);
+}
+
 void
 usage(void)
 {
diff -r dee849f7cbf3 -r 7dd756db7608 bin/getfacl/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/getfacl/Makefile      Sat May 16 18:31:45 2020 +0000
@@ -0,0 +1,6 @@
+# $NetBSD: Makefile,v 1.1 2020/05/16 18:31:45 christos Exp $
+# $FreeBSD: head/bin/getfacl/Makefile 298107 2016-04-16 07:45:30Z gjb $
+
+PROG=  getfacl
+
+.include <bsd.prog.mk>
diff -r dee849f7cbf3 -r 7dd756db7608 bin/getfacl/getfacl.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/getfacl/getfacl.1     Sat May 16 18:31:45 2020 +0000
@@ -0,0 +1,138 @@
+.\" $NetBSD: getfacl.1,v 1.1 2020/05/16 18:31:45 christos Exp $
+.\"-
+.\" Copyright (c) 2000, 2001, 2002 Robert N. M. Watson
+.\" All rights reserved.
+.\"
+.\" This software was developed by Robert Watson for the TrustedBSD Project.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT



Home | Main Index | Thread Index | Old Index