aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2015-07-05 08:22:26 -0700
committerPaul Eggert2015-07-05 08:23:11 -0700
commit1323c13978b7280ddf034e8f527f48d17487b5a2 (patch)
tree969cb5381db64e141d0b55ddea68f6e3751a1817 /lib
parentb9e14de6cf08a19fa5d98742b71c5580a50a40d8 (diff)
downloademacs-1323c13978b7280ddf034e8f527f48d17487b5a2.tar.gz
emacs-1323c13978b7280ddf034e8f527f48d17487b5a2.zip
Merge from gnulib
This incorporates: 2015-07-04 file-has-acl, acl-permissions: fix HP-UX typos 2015-07-03 set-permissions.c: adjust acl_from_mode's cpp guard 2015-07-02 update-copyright: fix test failure with perl >= 5.22 2015-07-01 gnulib-common.m4: change the ARFLAGS default to 'cr' 2015-07-01 acl: fix definition of acl_from_mode on FreeBSD * build-aux/update-copyright, doc/misc/texinfo.tex, lib/acl-internal.h: * lib/set-permissions.c, m4/gnulib-common.m4: Copy from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-internal.h6
-rw-r--r--lib/set-permissions.c58
2 files changed, 32 insertions, 32 deletions
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index d592a7559f0..4f042adc96b 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -127,10 +127,8 @@ rpl_acl_set_fd (int fd, acl_t acl)
127# define acl_extended_file(name) (-1) 127# define acl_extended_file(name) (-1)
128# endif 128# endif
129 129
130/* Linux-specific */ 130# if ! defined HAVE_ACL_FROM_MODE && ! defined HAVE_ACL_FROM_TEXT
131# ifndef HAVE_ACL_FROM_MODE 131# define acl_from_mode (NULL)
132# define HAVE_ACL_FROM_MODE false
133# define acl_from_mode(mode) (NULL)
134# endif 132# endif
135 133
136/* Set to 0 if a file's mode is stored independently from the ACL. */ 134/* Set to 0 if a file's mode is stored independently from the ACL. */
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index 3bcfd31530e..25c463d966d 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -25,6 +25,8 @@
25 25
26#if USE_ACL 26#if USE_ACL
27# if ! defined HAVE_ACL_FROM_MODE && defined HAVE_ACL_FROM_TEXT /* FreeBSD, IRIX, Tru64 */ 27# if ! defined HAVE_ACL_FROM_MODE && defined HAVE_ACL_FROM_TEXT /* FreeBSD, IRIX, Tru64 */
28# if HAVE_ACL_GET_FILE && !HAVE_ACL_TYPE_EXTENDED
29
28static acl_t 30static acl_t
29acl_from_mode (mode_t mode) 31acl_from_mode (mode_t mode)
30{ 32{
@@ -46,6 +48,7 @@ acl_from_mode (mode_t mode)
46 48
47 return acl_from_text (acl_text); 49 return acl_from_text (acl_text);
48} 50}
51# endif
49# endif 52# endif
50 53
51# if HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ 54# if HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
@@ -269,7 +272,7 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
269 } 272 }
270} 273}
271 274
272#elif HAVE_GETACL /* HP-UX */ 275# elif HAVE_GETACL /* HP-UX */
273static int 276static int
274context_acl_from_mode (struct permission_context *ctx, const char *name, int desc) 277context_acl_from_mode (struct permission_context *ctx, const char *name, int desc)
275{ 278{
@@ -285,13 +288,13 @@ context_acl_from_mode (struct permission_context *ctx, const char *name, int des
285 288
286 ctx->entries[0].uid = statbuf.st_uid; 289 ctx->entries[0].uid = statbuf.st_uid;
287 ctx->entries[0].gid = ACL_NSGROUP; 290 ctx->entries[0].gid = ACL_NSGROUP;
288 ctx->entries[0].mode = (mode >> 6) & 7; 291 ctx->entries[0].mode = (ctx->mode >> 6) & 7;
289 ctx->entries[1].uid = ACL_NSUSER; 292 ctx->entries[1].uid = ACL_NSUSER;
290 ctx->entries[1].gid = statbuf.st_gid; 293 ctx->entries[1].gid = statbuf.st_gid;
291 ctx->entries[1].mode = (mode >> 3) & 7; 294 ctx->entries[1].mode = (ctx->mode >> 3) & 7;
292 ctx->entries[2].uid = ACL_NSUSER; 295 ctx->entries[2].uid = ACL_NSUSER;
293 ctx->entries[2].gid = ACL_NSGROUP; 296 ctx->entries[2].gid = ACL_NSGROUP;
294 ctx->entries[2].mode = mode & 7; 297 ctx->entries[2].mode = ctx->mode & 7;
295 ctx->count = 3; 298 ctx->count = 3;
296 return 0; 299 return 0;
297} 300}
@@ -304,24 +307,24 @@ context_aclv_from_mode (struct permission_context *ctx)
304 307
305 ctx->aclv_entries[0].a_type = USER_OBJ; 308 ctx->aclv_entries[0].a_type = USER_OBJ;
306 ctx->aclv_entries[0].a_id = 0; /* irrelevant */ 309 ctx->aclv_entries[0].a_id = 0; /* irrelevant */
307 ctx->aclv_entries[0].a_perm = (mode >> 6) & 7; 310 ctx->aclv_entries[0].a_perm = (ctx->mode >> 6) & 7;
308 ctx->aclv_entries[1].a_type = GROUP_OBJ; 311 ctx->aclv_entries[1].a_type = GROUP_OBJ;
309 ctx->aclv_entries[1].a_id = 0; /* irrelevant */ 312 ctx->aclv_entries[1].a_id = 0; /* irrelevant */
310 ctx->aclv_entries[1].a_perm = (mode >> 3) & 7; 313 ctx->aclv_entries[1].a_perm = (ctx->mode >> 3) & 7;
311 ctx->aclv_entries[2].a_type = CLASS_OBJ; 314 ctx->aclv_entries[2].a_type = CLASS_OBJ;
312 ctx->aclv_entries[2].a_id = 0; 315 ctx->aclv_entries[2].a_id = 0;
313 ctx->aclv_entries[2].a_perm = (mode >> 3) & 7; 316 ctx->aclv_entries[2].a_perm = (ctx->mode >> 3) & 7;
314 ctx->aclv_entries[3].a_type = OTHER_OBJ; 317 ctx->aclv_entries[3].a_type = OTHER_OBJ;
315 ctx->aclv_entries[3].a_id = 0; 318 ctx->aclv_entries[3].a_id = 0;
316 ctx->aclv_entries[3].a_perm = mode & 7; 319 ctx->aclv_entries[3].a_perm = ctx->mode & 7;
317 ctx->aclv_count = 4; 320 ctx->aclv_count = 4;
318 321
319 ret = aclsort (sizeof (entries) / sizeof (struct acl), 1, entries); 322 ret = aclsort (ctx->aclv_count, 1, ctx->aclv_entries);
320 if (ret > 0) 323 if (ret > 0)
321 abort (); 324 abort ();
322 return ret; 325 return ret;
323} 326}
324#endif 327# endif
325 328
326# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */ 329# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */
327static int 330static int
@@ -458,19 +461,19 @@ context_acl_from_mode (struct permission_context *ctx)
458 461
459 ctx->entries[0].a_type = USER_OBJ; 462 ctx->entries[0].a_type = USER_OBJ;
460 ctx->entries[0].a_id = 0; /* irrelevant */ 463 ctx->entries[0].a_id = 0; /* irrelevant */
461 ctx->entries[0].a_perm = (mode >> 6) & 7; 464 ctx->entries[0].a_perm = (ctx->mode >> 6) & 7;
462 ctx->entries[1].a_type = GROUP_OBJ; 465 ctx->entries[1].a_type = GROUP_OBJ;
463 ctx->entries[1].a_id = 0; /* irrelevant */ 466 ctx->entries[1].a_id = 0; /* irrelevant */
464 ctx->entries[1].a_perm = (mode >> 3) & 7; 467 ctx->entries[1].a_perm = (ctx->mode >> 3) & 7;
465 ctx->entries[2].a_type = CLASS_OBJ; 468 ctx->entries[2].a_type = CLASS_OBJ;
466 ctx->entries[2].a_id = 0; 469 ctx->entries[2].a_id = 0;
467 ctx->entries[2].a_perm = (mode >> 3) & 7; 470 ctx->entries[2].a_perm = (ctx->mode >> 3) & 7;
468 ctx->entries[3].a_type = OTHER_OBJ; 471 ctx->entries[3].a_type = OTHER_OBJ;
469 ctx->entries[3].a_id = 0; 472 ctx->entries[3].a_id = 0;
470 ctx->entries[3].a_perm = mode & 7; 473 ctx->entries[3].a_perm = ctx->mode & 7;
471 ctx->count = 4; 474 ctx->count = 4;
472 475
473 ret = aclsort (sizeof (entries) / sizeof (struct acl), 1, entries); 476 ret = aclsort (ctx->count, 1, entries);
474 if (ret > 0) 477 if (ret > 0)
475 abort (); 478 abort ();
476 return ret; 479 return ret;
@@ -483,18 +486,18 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
483{ 486{
484 int ret = 0; 487 int ret = 0;
485 488
486#if HAVE_ACL_GET_FILE 489# if HAVE_ACL_GET_FILE
487 /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ 490 /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
488 /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */ 491 /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
489# if !HAVE_ACL_TYPE_EXTENDED 492# if !HAVE_ACL_TYPE_EXTENDED
490 /* Linux, FreeBSD, IRIX, Tru64 */ 493 /* Linux, FreeBSD, IRIX, Tru64 */
491 494
492# ifndef HAVE_ACL_FROM_TEXT 495# ifndef HAVE_ACL_FROM_TEXT
493# error Must have acl_from_text (see POSIX 1003.1e draft 17). 496# error Must have acl_from_text (see POSIX 1003.1e draft 17).
494# endif 497# endif
495# ifndef HAVE_ACL_DELETE_DEF_FILE 498# ifndef HAVE_ACL_DELETE_DEF_FILE
496# error Must have acl_delete_def_file (see POSIX 1003.1e draft 17). 499# error Must have acl_delete_def_file (see POSIX 1003.1e draft 17).
497# endif 500# endif
498 501
499 if (! ctx->acls_not_supported) 502 if (! ctx->acls_not_supported)
500 { 503 {
@@ -641,9 +644,9 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
641 else 644 else
642 *acls_set = true; 645 *acls_set = true;
643 } 646 }
644# endif 647# endif
645 648
646#elif HAVE_GETACL /* HP-UX */ 649# elif HAVE_GETACL /* HP-UX */
647 650
648 if (from_mode) 651 if (from_mode)
649 ret = context_acl_from_mode (ctx, name, desc); 652 ret = context_acl_from_mode (ctx, name, desc);
@@ -657,7 +660,7 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
657 if (ret < 0) 660 if (ret < 0)
658 { 661 {
659 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) 662 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
660 && (from_mode || !acl_nontrivial (ctx->count, ctx->entries, &source_statbuf))) 663 && (from_mode || !acl_nontrivial (ctx->count, ctx->entries)))
661 ret = 0; 664 ret = 0;
662 } 665 }
663 else 666 else
@@ -730,7 +733,7 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
730 733
731 /* Nothing to do. */ 734 /* Nothing to do. */
732 735
733#endif 736# endif
734 737
735 return ret; 738 return ret;
736} 739}
@@ -801,10 +804,9 @@ set_permissions (struct permission_context *ctx, const char *name, int desc)
801 int saved_errno = ret ? errno : 0; 804 int saved_errno = ret ? errno : 0;
802 805
803 /* If we can't set an acl which we expect to be able to set, try setting 806 /* If we can't set an acl which we expect to be able to set, try setting
804 the permissions to ctx->mode. Doe to possible inherited permissions, 807 the permissions to ctx->mode. Due to possible inherited permissions,
805 we cannot simply chmod. */ 808 we cannot simply chmod. */
806 809
807 acls_set = false;
808 ret = set_acls (ctx, name, desc, true, &must_chmod, &acls_set); 810 ret = set_acls (ctx, name, desc, true, &must_chmod, &acls_set);
809 if (! acls_set) 811 if (! acls_set)
810 must_chmod = true; 812 must_chmod = true;