Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15
acl.9183
0002-quote-escape-literal-backslashes.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-quote-escape-literal-backslashes.patch of Package acl.9183
From b6ba5c29a2ad9dcaac4191e81d2b497d396fa7d1 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney <jeffm@suse.com> Date: Wed, 2 Dec 2015 11:09:52 -0500 Subject: [PATCH 2/2] quote: escape literal backslashes References: bsc#953659 Git-commit: b6ba5c29a2ad9dcaac4191e81d2b497d396fa7d1 The octal unquote code can't handle escaping backslashes except by specifying the octal code for the backslash. That's not exactly a user-friendly interface for a scenario that may not be that uncommon. The unquote code isn't documented in the man page and can result in confusion when specifying names via a Windows domain that are entirely numeric (e.g. WINDOM\1234). This patch adds handling to allow literal escaping of the backslash (\\) as both input and output and documents the quoting rules in the setfacl man page. Also included are test cases for escaped backslashes followed by letters, escaped backslashes followed by numbers, and the original use case of escaped character literals. [Minor fixes by Andreas Gruenbacher.] Acked-by: Jeff Mahoney <jeffm@suse.com> --- libmisc/quote.c | 5 ++++- libmisc/unquote.c | 2 ++ man/man1/setfacl.1 | 8 +++++++- test/misc.test | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/libmisc/quote.c b/libmisc/quote.c index a28800c..a24c958 100644 --- a/libmisc/quote.c +++ b/libmisc/quote.c @@ -44,11 +44,14 @@ const char *__acl_quote(const char *str, const char *quote_chars) (s - (unsigned char *)str) + nonpr * 3 + 1)) return NULL; for (s = (unsigned char *)str, q = quoted_str; *s != '\0'; s++) { - if (*s == '\\' || strchr(quote_chars, *s)) { + if (strchr(quote_chars, *s)) { *q++ = '\\'; *q++ = '0' + ((*s >> 6) ); *q++ = '0' + ((*s >> 3) & 7); *q++ = '0' + ((*s ) & 7); + } else if (*s == '\\') { + *q++ = '\\'; + *q++ = '\\'; } else *q++ = *s; } diff --git a/libmisc/unquote.c b/libmisc/unquote.c index 4f4ce7c..b8b3505 100644 --- a/libmisc/unquote.c +++ b/libmisc/unquote.c @@ -46,6 +46,8 @@ char *__acl_unquote(char *str) ((*(s+2) - '0') << 3) + ((*(s+3) - '0') ); s += 3; + } else if (*s == '\\' && *(s+1) == '\\') { + *t++ = *s++; } else *t++ = *s; } while (*s++ != '\0'); diff --git a/man/man1/setfacl.1 b/man/man1/setfacl.1 index a73d122..3d06031 100644 --- a/man/man1/setfacl.1 +++ b/man/man1/setfacl.1 @@ -190,7 +190,13 @@ For .I uid and .I gid -you can specify either a name or a number. +you can specify either a name or a number. Character literals may be specified +with a backslash followed by the 3-digit octal digits corresponding to the +ASCII code for the character (e.g., +.I \e101 +for 'A'). If the name contains a literal backslash followed by 3 digits, the +backslash must be escaped (i.e., +.IR "\e\e" ). .PP The .I perms diff --git a/test/misc.test b/test/misc.test index 29372b7..c4d9774 100644 --- a/test/misc.test +++ b/test/misc.test @@ -454,6 +454,45 @@ Dangling symlink test http://savannah.nongnu.org/bugs/?28131 > setfacl: d/b: No such file or directory $ rm -R d +Handle escaped literal backslash followed by numeric username + $ mkdir d + $ touch d/f + $ setfacl -m u:domain\\\\12345:rw- d/f + $ getfacl --omit-header d/f + > user::rw- + > user:domain\\12345:rw- + > group::rw- + > mask::rw- + > other::r-- + > + $ rm -R d + +Handle escaped literal backslash + $ mkdir d + $ touch d/f + $ setfacl -m u:domain\\\\user:rw- d/f + $ getfacl --omit-header d/f + > user::rw- + > user:domain\\user:rw- + > group::rw- + > mask::rw- + > other::r-- + > + $ rm -R d + +Handle escaped literal characters by octal code (bin) + $ mkdir d + $ touch d/f + $ setfacl -m u:\\142\\151\\156:rw- d/f + $ getfacl --omit-header d/f + > user::rw- + > user:bin:rw- + > group::rw- + > mask::rw- + > other::r-- + > + $ rm -R d + Malformed restore file $ echo "# owner: root" > f -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor