root/maint/gnulib/lib/qcopy-acl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. qcopy_acl

   1 /* Copy access control list from one file to another.  -*- coding: utf-8 -*-
   2 
   3    Copyright (C) 2002-2003, 2005-2021 Free Software Foundation, Inc.
   4 
   5    This program is free software: you can redistribute it and/or modify
   6    it under the terms of the GNU General Public License as published by
   7    the Free Software Foundation; either version 3 of the License, or
   8    (at your option) any later version.
   9 
  10    This program is distributed in the hope that it will be useful,
  11    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13    GNU General Public License for more details.
  14 
  15    You should have received a copy of the GNU General Public License
  16    along with this program.  If not, see <https://www.gnu.org/licenses/>.
  17 
  18    Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible.  */
  19 
  20 #include <config.h>
  21 
  22 #include "acl.h"
  23 
  24 #include "acl-internal.h"
  25 
  26 
  27 /* Copy access control lists from one file to another. If SOURCE_DESC is
  28    a valid file descriptor, use file descriptor operations, else use
  29    filename based operations on SRC_NAME. Likewise for DEST_DESC and
  30    DST_NAME.
  31    If access control lists are not available, fchmod the target file to
  32    MODE.  Also sets the non-permission bits of the destination file
  33    (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set.
  34    Return 0 if successful.
  35    Return -2 and set errno for an error relating to the source file.
  36    Return -1 and set errno for an error relating to the destination file.  */
  37 
  38 int
  39 qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
     /* [previous][next][first][last][top][bottom][index][help] */
  40            int dest_desc, mode_t mode)
  41 {
  42   struct permission_context ctx;
  43   int ret;
  44 
  45   ret = get_permissions (src_name, source_desc, mode, &ctx);
  46   if (ret != 0)
  47     return -2;
  48   ret = set_permissions (&ctx, dst_name, dest_desc);
  49   free_permission_context (&ctx);
  50   return ret;
  51 }

/* [previous][next][first][last][top][bottom][index][help] */