From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#14295: Support copy-file ACLs for Solaris etc. Date: Sun, 28 Apr 2013 20:16:29 +0300 Message-ID: <83ehdushhu.fsf@gnu.org> References: <517C987F.6060902@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1367169473 17026 80.91.229.3 (28 Apr 2013 17:17:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Apr 2013 17:17:53 +0000 (UTC) Cc: 14295@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 28 19:17:58 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UWVEY-0006Cj-JZ for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Apr 2013 19:17:54 +0200 Original-Received: from localhost ([::1]:51825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWVEY-0005vl-5c for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Apr 2013 13:17:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWVEU-0005vg-I9 for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 13:17:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWVET-0005Bj-BX for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 13:17:50 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44639) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWVET-0005B4-7n for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 13:17:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UWVEf-0004Mr-PV for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 13:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Apr 2013 17:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14295 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136716946616764 (code B ref -1); Sun, 28 Apr 2013 17:18:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Apr 2013 17:17:46 +0000 Original-Received: from localhost ([127.0.0.1]:48747 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UWVEP-0004ML-Oz for submit@debbugs.gnu.org; Sun, 28 Apr 2013 13:17:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39446) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UWVEM-0004MD-F0 for submit@debbugs.gnu.org; Sun, 28 Apr 2013 13:17:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWVE8-0004yX-02 for submit@debbugs.gnu.org; Sun, 28 Apr 2013 13:17:29 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:33168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWVE7-0004yS-Sr for submit@debbugs.gnu.org; Sun, 28 Apr 2013 13:17:27 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWVE6-0005vD-2C for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 13:17:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWVE4-0004wX-Pw for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 13:17:26 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:35791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWVE4-0004wM-IQ for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 13:17:24 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MLZ00I006FP4900@a-mtaout22.012.net.il> for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2013 20:16:40 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MLZ00H8G6NRJGE0@a-mtaout22.012.net.il>; Sun, 28 Apr 2013 20:16:40 +0300 (IDT) In-reply-to: <517C987F.6060902@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73803 Archived-At: > Date: Sat, 27 Apr 2013 20:33:19 -0700 > From: Paul Eggert > CC: Eli Zaretskii > > Recently copy-file was augmented to add support for > copying ACLs on abandoned-POSIX-style hosts. Here's > an additional patch to add support for copying ACLs on > Solaris, HP-UX, etc. Basically, the idea is to use > Gnulib's support for ACLs. I've tested this on > GNU/Linux and Solaris, but not on Microsoft platforms, > and am CC'ing this to Eli as a heads-up for that. Thanks; see a few comments below. > This changes the 'configure' option from --without-acl to > --disable-acl if one wishes to disable ACL support when > configuring Emacs; this is the option spelling that other GNU > packages use. How hard would it to support both? > +bool > +acl_errno_valid (int errnum) > +{ > + /* Recognize some common errors such as from an NFS mount that does > + not support ACLs, even when local drives do. */ > + switch (errnum) > + { > + case EBUSY: return false; > + case EINVAL: return false; > +#if defined __APPLE__ && defined __MACH__ > + case ENOENT: return false; > +#endif > + case ENOSYS: return false; > +#if defined ENOTSUP && ENOTSUP != EOPNOTSUPP > + case ENOTSUP: return false; > +#endif > + case EOPNOTSUPP: return false; > + default: return true; > + } > +} This uses EOPNOTSUPP without #ifdef guards; is that universally available? > #ifdef WINDOWSNT > - if (!NILP (preserve_extended_attributes)) > - { > -#ifdef HAVE_POSIX_ACL > - acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS); > - if (acl == NULL && !ACL_NOT_WELL_SUPPORTED (errno)) > - report_file_error ("Getting ACL", Fcons (file, Qnil)); > -#endif > - } > if (!CopyFile (SDATA (encoded_file), > SDATA (encoded_newname), > FALSE)) > @@ -2069,17 +2040,6 @@ > /* Restore original attributes. */ > SetFileAttributes (filename, attributes); > } > -#ifdef HAVE_POSIX_ACL > - if (acl != NULL) > - { > - bool fail = > - acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0; > - if (fail && !ACL_NOT_WELL_SUPPORTED (errno)) > - report_file_error ("Setting ACL", Fcons (newname, Qnil)); > - > - acl_free (acl); > - } > -#endif > #else /* not WINDOWSNT */ > immediate_quit = 1; > ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); > @@ -2103,12 +2063,6 @@ > report_file_error ("Doing fgetfilecon", Fcons (file, Qnil)); > } > #endif > - > -#ifdef HAVE_POSIX_ACL > - acl = acl_get_fd (ifd); > - if (acl == NULL && !ACL_NOT_WELL_SUPPORTED (errno)) > - report_file_error ("Getting ACL", Fcons (file, Qnil)); > -#endif > } > > if (out_st.st_mode != 0 > @@ -2156,7 +2110,7 @@ > immediate_quit = 0; > > #ifndef MSDOS > - /* Preserve the original file modes, and if requested, also its > + /* Preserve the original file permissions, and if requested, also its > owner and group. */ > { > mode_t mode_mask = 07777; > @@ -2173,8 +2127,16 @@ > mode_mask |= 02000; > } > } > - if (fchmod (ofd, st.st_mode & mode_mask) != 0) > - report_file_error ("Doing chmod", Fcons (newname, Qnil)); > + > + switch (!NILP (preserve_extended_attributes) > + ? qcopy_acl (SSDATA (encoded_file), ifd, > + SSDATA (encoded_newname), ofd, > + st.st_mode & mode_mask) > + : fchmod (ofd, st.st_mode & mode_mask)) > + { > + case -2: report_file_error ("Copying permissions from", list1 (file)); > + case -1: report_file_error ("Copying permissions to", list1 (newname)); > + } > } > #endif /* not MSDOS */ This hunk looks wrong, or maybe I'm missing something: it looks like you removed the ACL support code from the WINDOWSNT blocks, but added the replacement qcopy_acl in a block that is not compiled on Windows at all (and uses fchmod and st which are not initialized on Windows). If I'm right, perhaps it is best to leave the WINDOWSNT parts alone: since acl_get_file and acl_set_file are still being left in Emacs sources elsewhere, there's no need to remove their calls here, and leaving them alone will avoid the need to add qcopy_acl to w32.c. > -#ifdef HAVE_POSIX_ACL > +#ifdef HAVE_ACL_SET_FILE > absname = ENCODE_FILE (absname); > > acl = acl_get_file (SSDATA (absname), ACL_TYPE_ACCESS); It sounds wrong to me to condition a call to acl_get_file with a macro called HAVE_ACL_SET_FILE. > @@ -3193,7 +3144,7 @@ > fail = (acl_set_file (SSDATA (encoded_absname), ACL_TYPE_ACCESS, > acl) > != 0); > - if (fail && !ACL_NOT_WELL_SUPPORTED (errno)) > + if (fail && acl_errno_valid (errno)) For this to work, acl-errno-valid.c will have to be compiled on MS-Windows. And for that, we will need to solve the EOPNOTSUPP issue mentioned above, because Windows doesn't define it.