From f266cc3d09506299e26f5e5b01d1d0d1b4c2684b Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Wed, 15 Feb 2017 20:43:54 +0100 Subject: [PATCH] New archive_acl_to_text() style flag: ARCHIVE_ENTRY_ACL_STYLE_COMPACT - outputs NFSv4 permission and flags fields without minus characters Use new compact format as default for the SCHILY.acl.ace pax header --- libarchive/archive_acl.c | 8 ++--- libarchive/archive_entry.h | 5 +++ libarchive/archive_entry_acl.3 | 7 ++++ libarchive/archive_write_set_format_pax.c | 3 +- libarchive/test/test_acl_pax_nfs4.tar.uu | 44 +++++++++++------------ libarchive/test/test_acl_text.c | 13 ++++++- 6 files changed, 52 insertions(+), 28 deletions(-) diff --git a/libarchive/archive_acl.c b/libarchive/archive_acl.c index 3ca970298..b8b6b6364 100644 --- a/libarchive/archive_acl.c +++ b/libarchive/archive_acl.c @@ -860,14 +860,14 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int type, for (i = 0; i < nfsv4_acl_perm_map_size; i++) { if (perm & nfsv4_acl_perm_map[i].perm) *(*wp)++ = nfsv4_acl_perm_map[i].wc; - else + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) *(*wp)++ = L'-'; } *(*wp)++ = L':'; for (i = 0; i < nfsv4_acl_flag_map_size; i++) { if (perm & nfsv4_acl_flag_map[i].perm) *(*wp)++ = nfsv4_acl_flag_map[i].wc; - else + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) *(*wp)++ = L'-'; } *(*wp)++ = L':'; @@ -1093,14 +1093,14 @@ append_entry(char **p, const char *prefix, int type, for (i = 0; i < nfsv4_acl_perm_map_size; i++) { if (perm & nfsv4_acl_perm_map[i].perm) *(*p)++ = nfsv4_acl_perm_map[i].c; - else + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) *(*p)++ = '-'; } *(*p)++ = ':'; for (i = 0; i < nfsv4_acl_flag_map_size; i++) { if (perm & nfsv4_acl_flag_map[i].perm) *(*p)++ = nfsv4_acl_flag_map[i].c; - else + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) *(*p)++ = '-'; } *(*p)++ = ':'; diff --git a/libarchive/archive_entry.h b/libarchive/archive_entry.h index 9f1955bdb..ca77b3781 100644 --- a/libarchive/archive_entry.h +++ b/libarchive/archive_entry.h @@ -509,6 +509,10 @@ __LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type * ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and * "mask" entries. * + * Flags only for archive entries with NFSv4 ACL: + * ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for + * unset permissions and flags in NFSv4 ACL permission and flag fields + * * Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL: * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in * each ACL entry. @@ -519,6 +523,7 @@ __LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type #define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002 #define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004 #define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008 +#define ARCHIVE_ENTRY_ACL_STYLE_COMPACT 0x00000010 __LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *, ssize_t * /* len */, int /* flags */); diff --git a/libarchive/archive_entry_acl.3 b/libarchive/archive_entry_acl.3 index 93707d1ff..17cc3ceda 100644 --- a/libarchive/archive_entry_acl.3 +++ b/libarchive/archive_entry_acl.3 @@ -390,6 +390,13 @@ Prefix each default ACL entry with the word The mask and other ACLs don not contain a double colon. .El .Pp +The following flags are effecive only on NFSv4 ACL: +.Bl -tag -offset indent -compact -width ARCHIV +.It Dv ARCHIVE_ENTRY_ACL_STYLE_COMPACT +Do not output minus characters for unset permissions and flags in NFSv4 ACL +permission and flag fields. +.El +.Pp The following flags are effective on both POSIX.1e and NFSv4 ACL: .Bl -tag -offset indent -compact -width ARCHIV .It Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID diff --git a/libarchive/archive_write_set_format_pax.c b/libarchive/archive_write_set_format_pax.c index cb0e5c315..6a301ac2d 100644 --- a/libarchive/archive_write_set_format_pax.c +++ b/libarchive/archive_write_set_format_pax.c @@ -1166,7 +1166,8 @@ archive_write_pax_header(struct archive_write *a, if ((acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { ret = add_pax_acl(a, entry_original, pax, ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID | - ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA); + ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA | + ARCHIVE_ENTRY_ACL_STYLE_COMPACT); if (ret == ARCHIVE_FATAL) return (ARCHIVE_FATAL); } diff --git a/libarchive/test/test_acl_pax_nfs4.tar.uu b/libarchive/test/test_acl_pax_nfs4.tar.uu index 6a41557ff..ffc5cc279 100644 --- a/libarchive/test/test_acl_pax_nfs4.tar.uu +++ b/libarchive/test/test_acl_pax_nfs4.tar.uu @@ -1,8 +1,8 @@ begin 644 test_acl_pax_nfs4.tar M4&%X2&5A9&5R+V9I;&4````````````````````````````````````````` M```````````````````````````````````````````````````````````` -M`````````````#`P,#``````````````````````````````` +M`````````````#`P,#``````````````````````````````` M```````````````````````````````````````````````````````````` M``````````````````````````````````````````!U'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W``````````````````````` +M,#`P,C4V(#`P,#`P,#`P,#`P(#`Q,C`Q,@`@>``````````````````````` M```````````````````````````````````````````````````````````` M``````````````````````````````````````````````````!U#HZ9&5N>3HW."QG``````````````` +M`#`P,#`P,#`P,C8R(#`P,#`P,#`P,#`P(#`Q,C`P-P`@>``````````````` M```````````````````````````````````````````````````````````` M``````````````````````````````````````````````````````````!U M'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W6]N94`Z'!A05)78T-O