PERFORCE change 22721 for review

Robert Watson rwatson at freebsd.org
Tue Dec 24 22:26:14 GMT 2002


http://perforce.freebsd.org/chv.cgi?CH=22721

Change 22721 by rwatson at 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 at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list