bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ACL support for copy-file module


From: Bruno Haible
Subject: ACL support for copy-file module
Date: Fri, 22 Dec 2006 19:51:43 +0100
User-agent: KMail/1.9.1

Hi,

Can an ACL expert please proofread this? This adds ACL support to the
copy_file_preserving function. It compiles fine, but I cannot test it since
none of my systems has ACL support.


2006-12-22  Bruno Haible  <address@hidden>

        * lib/copy-file.c: Include acl.h.
        (copy_file_preserving) [USE_ACL]: Use copy_acl instead of chmod.
        Close the file descriptors only after being done with copy_acl.
        * modules/copy-file (Depends-on): Add acl.

*** lib/copy-file.c     14 Sep 2006 14:18:36 -0000      1.8
--- lib/copy-file.c     22 Dec 2006 18:50:23 -0000
***************
*** 39,44 ****
--- 39,45 ----
  #include "error.h"
  #include "safe-read.h"
  #include "full-write.h"
+ #include "acl.h"
  #include "binary-io.h"
  #include "exit.h"
  #include "gettext.h"
***************
*** 80,89 ****
--- 81,92 ----
        error (EXIT_FAILURE, errno, _("error writing \"%s\""), dest_filename);
      }
  
+ #if !USE_ACL
    if (close (dest_fd) < 0)
      error (EXIT_FAILURE, errno, _("error writing \"%s\""), dest_filename);
    if (close (src_fd) < 0)
      error (EXIT_FAILURE, errno, _("error after reading \"%s\""), 
src_filename);
+ #endif
  
    /* Preserve the access and modification times.  */
  #if HAVE_UTIME
***************
*** 110,114 ****
--- 113,129 ----
  #endif
  
    /* Preserve the access permissions.  */
+ #if USE_ACL
+   if (copy_acl (src_filename, src_fd, dest_filename, dest_fd, mode))
+     exit (EXIT_FAILURE);
+ #else
    chmod (dest_filename, mode);
+ #endif
+ 
+ #if USE_ACL
+   if (close (dest_fd) < 0)
+     error (EXIT_FAILURE, errno, _("error writing \"%s\""), dest_filename);
+   if (close (src_fd) < 0)
+     error (EXIT_FAILURE, errno, _("error after reading \"%s\""), 
src_filename);
+ #endif
  }
*** modules/copy-file   24 Apr 2006 11:38:06 -0000      1.4
--- modules/copy-file   22 Dec 2006 18:50:23 -0000
***************
*** 10,15 ****
--- 10,16 ----
  error
  safe-read
  full-write
+ acl
  binary-io
  exit
  gettext-h




reply via email to

[Prev in Thread] Current Thread [Next in Thread]