Date: Tue, 24 Dec 2002 14:26:14 -0800 (PST) From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 22721 for review Message-ID: <200212242226.gBOMQE5m004930@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=22721 Change 22721 by rwatson@rwatson_paprika on 2002/12/24 14:25:44 Apply Chris Faulhaber's ACL patches for mv(1). These changes preserve ACLs across cross-file system move operations. Affected files ... .. //depot/projects/trustedbsd/acl/bin/mv/Makefile#2 edit .. //depot/projects/trustedbsd/acl/bin/mv/mv.c#2 edit Differences ... ==== //depot/projects/trustedbsd/acl/bin/mv/Makefile#2 (text+ko) ==== @@ -3,4 +3,6 @@ PROG= mv +CFLAGS+=-DWANT_ACL + .include <bsd.prog.mk> ==== //depot/projects/trustedbsd/acl/bin/mv/mv.c#2 (text+ko) ==== @@ -49,6 +49,9 @@ __FBSDID("$FreeBSD: src/bin/mv/mv.c,v 1.39 2002/07/09 17:45:13 johan Exp $"); #include <sys/param.h> +#ifdef WANT_ACL +#include <sys/acl.h> +#endif #include <sys/time.h> #include <sys/wait.h> #include <sys/stat.h> @@ -242,6 +245,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; @@ -283,6 +289,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; @@ -298,6 +317,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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212242226.gBOMQE5m004930>
