From trasz@pin.if.uz.zgora.pl  Thu Dec 23 10:59:15 2010
Return-Path: <trasz@pin.if.uz.zgora.pl>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 41B5F106564A;
	Thu, 23 Dec 2010 10:59:15 +0000 (UTC)
	(envelope-from trasz@pin.if.uz.zgora.pl)
Received: from pin.if.uz.zgora.pl (pin.if.uz.zgora.pl [212.109.128.251])
	by mx1.freebsd.org (Postfix) with ESMTP id 0AE0D8FC12;
	Thu, 23 Dec 2010 10:59:14 +0000 (UTC)
Received: by pin.if.uz.zgora.pl (Postfix, from userid 1001)
	id A845839B55; Thu, 23 Dec 2010 11:59:30 +0100 (CET)
Message-Id: <20101223105930.A845839B55@pin.if.uz.zgora.pl>
Date: Thu, 23 Dec 2010 11:59:30 +0100 (CET)
From: Edward Tomasz Napierala <trasz@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: ehaupt@FreeBSD.org
Subject: [PATCH] net/rsync: workaround for ACL problem with ZFS
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         153404
>Category:       ports
>Synopsis:       [PATCH] net/rsync: workaround for ACL problem with ZFS
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ehaupt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 23 11:00:21 UTC 2010
>Closed-Date:    Wed Jan 12 18:59:30 CET 2011
>Last-Modified:  Wed Jan 12 19:00:48 CET 2011
>Originator:     Edward Tomasz Napierala
>Release:        FreeBSD 7.2-STABLE i386
>Organization:
>Environment:
System: FreeBSD pin.if.uz.zgora.pl 7.2-STABLE FreeBSD 7.2-STABLE #0: Wed Dec  2 07:49:34 CET
>Description:

When running on ZFS or UFS with NFSv4 ACL support enabled, "rsync -A" fails due to acl_get_file(3)
returning EINVAL.  EINVAL is caused by improper use of this routine - rsync doesn't bother to check
if POSIX.1e ACLs are supported, and blindly requests ACL_TYPE_ACCESS, which is invalid for files
with NFSv4 ACLs.

Attached patches make rsync properly recognize EINVAL as lack of support for the requested ACL type.

Added file(s):
- files/patch-acls.c
- files/patch-lib-sysacls.c

Port maintainer (ehaupt@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.77
>How-To-Repeat:
>Fix:

--- rsync-3.0.7_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/net/rsync/Makefile /home/trasz/rsync/Makefile
--- /usr/ports/net/rsync/Makefile	2010-10-13 20:57:09.000000000 +0200
+++ /home/trasz/rsync/Makefile	2010-12-23 11:37:14.000000000 +0100
@@ -7,6 +7,7 @@
 
 PORTNAME=	rsync
 PORTVERSION=	3.0.7
+PORTREVISION=	1
 CATEGORIES=	net ipv6
 MASTER_SITES=	http://rsync.samba.org/ftp/%SUBDIR%/ \
 		ftp://ftp.samba.org/pub/%SUBDIR%/ \
diff -ruN --exclude=CVS /usr/ports/net/rsync/files/patch-acls.c /home/trasz/rsync/files/patch-acls.c
--- /usr/ports/net/rsync/files/patch-acls.c	1970-01-01 01:00:00.000000000 +0100
+++ /home/trasz/rsync/files/patch-acls.c	2010-12-23 11:37:14.000000000 +0100
@@ -0,0 +1,13 @@
+--- acls.c.orig	2010-12-23 10:45:21.344757361 +0100
++++ acls.c	2010-12-23 10:44:33.000000000 +0100
+@@ -1082,6 +1082,10 @@ int default_perms_for_dir(const char *di
+ 		case ENOTSUP:
+ #endif
+ 		case ENOSYS:
++#ifdef __FreeBSD__
++		/* Workaround for improper NFSv4 ACL handling in rsync. */
++		case EINVAL:
++#endif
+ 			/* No ACLs are available. */
+ 			break;
+ 		case ENOENT:
diff -ruN --exclude=CVS /usr/ports/net/rsync/files/patch-lib-sysacls.c /home/trasz/rsync/files/patch-lib-sysacls.c
--- /usr/ports/net/rsync/files/patch-lib-sysacls.c	1970-01-01 01:00:00.000000000 +0100
+++ /home/trasz/rsync/files/patch-lib-sysacls.c	2010-12-23 11:37:15.000000000 +0100
@@ -0,0 +1,16 @@
+--- lib/sysacls.c.orig	2010-12-23 10:47:02.945461082 +0100
++++ lib/sysacls.c	2010-12-23 10:44:52.000000000 +0100
+@@ -2771,6 +2771,13 @@ int no_acl_syscall_error(int err)
+ 	if (err == ENOENT)
+ 		return 1; /* Weird problem with directory ACLs. */
+ #endif
++#ifdef __FreeBSD__
++	if (err == EINVAL)
++		/*
++		 * Workaround for improper NFSv4 ACL handling in rsync.
++		 */
++		return 1;
++#endif
+ #if defined(ENOSYS)
+ 	if (err == ENOSYS) {
+ 		return 1;
--- rsync-3.0.7_1.patch ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->ehaupt 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Dec 23 11:01:02 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=153404 
State-Changed-From-To: open->feedback 
State-Changed-By: ehaupt 
State-Changed-When: Thu Dec 23 13:30:16 CET 2010 
State-Changed-Why:  
Did you submit this patch upstream? I'd rather have this fixed upstream. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=153404 
State-Changed-From-To: feedback->closed 
State-Changed-By: ehaupt 
State-Changed-When: Wed Jan 12 18:59:11 CET 2011 
State-Changed-Why:  
Should be fixed upstream. Bug report:
https://bugzilla.samba.org/show_bug.cgi?id=7884

http://www.freebsd.org/cgi/query-pr.cgi?pr=153404 
>Unformatted:
