Index: Makefile =================================================================== RCS file: /home/ncvs/src/bin/mv/Makefile,v retrieving revision 1.8 diff -u -r1.8 Makefile --- Makefile 4 Dec 2001 01:57:45 -0000 1.8 +++ Makefile 4 Feb 2002 02:16:28 -0000 @@ -3,4 +3,6 @@ PROG= mv +CFLAGS+=-DWANT_ACL + .include Index: mv.c =================================================================== RCS file: /home/ncvs/src/bin/mv/mv.c,v retrieving revision 1.32 diff -u -r1.32 mv.c --- mv.c 2 Feb 2002 07:09:30 -0000 1.32 +++ mv.c 4 Feb 2002 02:16:28 -0000 @@ -49,6 +49,9 @@ #endif /* not lint */ #include +#ifdef WANT_ACL +#include +#endif #include #include #include @@ -230,6 +233,9 @@ int fastcopy(char *from, char *to, struct stat *sbp) { +#ifdef WANT_ACL + acl_t acc_acl, def_acl; +#endif struct timeval tval[2]; static u_int blen; static char *bp; @@ -271,6 +277,19 @@ (void)close(to_fd); return (1); } +#ifdef WANT_ACL + /* retrieve the access ACL */ + acc_acl = acl_get_file(from, ACL_TYPE_ACCESS); + if (acc_acl == NULL && errno != EOPNOTSUPP) + warn("%s: get access acl", from); + if (S_ISDIR(sbp->st_mode)) { + /* retrieve the default ACL */ + def_acl = acl_get_file(from, ACL_TYPE_DEFAULT); + if (def_acl == NULL && errno != EOPNOTSUPP) + warn("%s: get access acl", from); + } else + def_acl = NULL; +#endif (void)close(from_fd); oldmode = sbp->st_mode & ALLPERMS; @@ -286,6 +305,26 @@ } if (fchmod(to_fd, sbp->st_mode)) warn("%s: set mode (was: 0%03o)", to, oldmode); +#ifdef WANT_ACL + if (acc_acl) { + /* set the access ACL */ + if (acl_set_fd(to_fd, acc_acl) == -1 && errno != EOPNOTSUPP) + warn("%s: set access acl", to); + acl_free(acc_acl); + } + if (S_ISDIR(sbp->st_mode)) { + /* retrieve the default ACL */ + def_acl = acl_get_file(from, ACL_TYPE_DEFAULT); + if (def_acl) { + /* set the default ACL */ + if (acl_set_file(to, ACL_TYPE_DEFAULT, def_acl) == -1 && + errno != EOPNOTSUPP) + warn("%s: set default acl", to); + acl_free(def_acl); + } else if (errno != EOPNOTSUPP) + warn("%s: get default acl", from); + } +#endif /* * XXX * NFS doesn't support chflags; ignore errors unless there's reason