summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2009-06-22 19:57:48 +0200
committerAndreas Gruenbacher <agruen@suse.de>2009-06-22 20:50:36 +0200
commit6928165c52fe3a21829403c1eda93fbc5693f35a (patch)
tree2936504e9b1a961f53520fa6c20d85db70cbbc26
parent4383573ac7e0b6c8ddc087323c1cd166706e024c (diff)
downloadacl-6928165c52fe3a21829403c1eda93fbc5693f35a.tar.gz
Stop quoting nonprintable characters in the getfacl output
What is printable or not depends on the locale settings, and getfacl often gets it wrong. We still need to quote a few special characters like newlines so that setfacl can always parse getfacl's output.
-rw-r--r--doc/CHANGES4
-rw-r--r--getfacl/getfacl.c18
-rw-r--r--libacl/__acl_to_any_text.c4
-rw-r--r--setfacl/setfacl.c20
4 files changed, 25 insertions, 21 deletions
diff --git a/doc/CHANGES b/doc/CHANGES
index 666b866..327a19b 100644
--- a/doc/CHANGES
+++ b/doc/CHANGES
@@ -1,3 +1,7 @@
+* Stop quoting nonprintable characters in the getfacl output: what is printable
+ or not depends on the locale settings, and getfacl often gets it wrong. We
+ still need to quote a few special characters like newlines so that setfacl
+ can always parse getfacl's output.
* Fix in acl_equiv_mode(): Return the mode that the acl corresponds to even
when the acl has more than three entries (i.e., it is not equivalent to
this mode).
diff --git a/getfacl/getfacl.c b/getfacl/getfacl.c
index ab050ba..fc650e3 100644
--- a/getfacl/getfacl.c
+++ b/getfacl/getfacl.c
@@ -88,9 +88,9 @@ int print_options = TEXT_SOME_EFFECTIVE;
int opt_numeric; /* don't convert id's to symbolic names */
-static const char *xquote(const char *str)
+static const char *xquote(const char *str, const char *quote_chars)
{
- const char *q = quote(str);
+ const char *q = quote(str, quote_chars);
if (q == NULL) {
fprintf(stderr, "%s: %s\n", progname, strerror(errno));
exit(1);
@@ -152,7 +152,7 @@ struct name_list *get_list(const struct stat *st, acl_t acl)
name = group_name(*id_p, opt_numeric);
break;
}
- name = xquote(name);
+ name = xquote(name, "\t\n\r");
len = strlen(name);
if (last == NULL) {
first = last = (struct name_list *)
@@ -360,7 +360,7 @@ int do_show(FILE *stream, const char *path_p, const struct stat *st,
if (ret < 0)
return ret;
}
- fprintf(stream, "# file: %s\n", xquote(path_p));
+ fprintf(stream, "# file: %s\n", xquote(path_p, "\n\r"));
while (acl_names != NULL || dacl_names != NULL) {
acl_tag_t acl_tag, dacl_tag;
@@ -430,7 +430,7 @@ int do_print(const char *path_p, const struct stat *st, int walk_flags, void *un
int error = 0;
if (walk_flags & WALK_TREE_FAILED) {
- fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p),
+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
strerror(errno));
return 1;
}
@@ -493,11 +493,11 @@ int do_print(const char *path_p, const struct stat *st, int walk_flags, void *un
goto fail;
} else {
if (opt_comments) {
- printf("# file: %s\n", xquote(path_p));
+ printf("# file: %s\n", xquote(path_p, "\n\r"));
printf("# owner: %s\n",
- xquote(user_name(st->st_uid, opt_numeric)));
+ xquote(user_name(st->st_uid, opt_numeric), " \t\n\r"));
printf("# group: %s\n",
- xquote(group_name(st->st_gid, opt_numeric)));
+ xquote(group_name(st->st_gid, opt_numeric), " \t\n\r"));
}
if (acl != NULL) {
char *acl_text = acl_to_any_text(acl, NULL, '\n',
@@ -534,7 +534,7 @@ cleanup:
return error;
fail:
- fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p),
+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
strerror(errno));
error = -1;
goto cleanup;
diff --git a/libacl/__acl_to_any_text.c b/libacl/__acl_to_any_text.c
index 22abc97..a4f9c34 100644
--- a/libacl/__acl_to_any_text.c
+++ b/libacl/__acl_to_any_text.c
@@ -160,7 +160,7 @@ acl_entry_to_any_str(const acl_entry_t entry_d, char *text_p, ssize_t size,
str = NULL;
else
str = quote(user_name(
- entry_obj_p->eid.qid));
+ entry_obj_p->eid.qid), ":, \t\n\r");
if (str != NULL) {
strncpy(text_p, str, size);
ADVANCE(strlen(str));
@@ -183,7 +183,7 @@ acl_entry_to_any_str(const acl_entry_t entry_d, char *text_p, ssize_t size,
str = NULL;
else
str = quote(group_name(
- entry_obj_p->eid.qid));
+ entry_obj_p->eid.qid), ":, \t\n\r");
if (str != NULL) {
strncpy(text_p, str, size);
ADVANCE(strlen(str));
diff --git a/setfacl/setfacl.c b/setfacl/setfacl.c
index 7d94350..a4ce899 100644
--- a/setfacl/setfacl.c
+++ b/setfacl/setfacl.c
@@ -91,9 +91,9 @@ int chown_error;
int promote_warning;
-static const char *xquote(const char *str)
+static const char *xquote(const char *str, const char *quote_chars)
{
- const char *q = quote(str);
+ const char *q = quote(str, quote_chars);
if (q == NULL) {
fprintf(stderr, "%s: %s\n", progname, strerror(errno));
exit(1);
@@ -143,7 +143,7 @@ restore(
if (filename) {
fprintf(stderr, _("%s: %s: No filename found "
"in line %d, aborting\n"),
- progname, xquote(filename),
+ progname, xquote(filename, "\n\r"),
backup_line);
} else {
fprintf(stderr, _("%s: No filename found in "
@@ -168,7 +168,7 @@ restore(
&line, NULL);
if (error != 0) {
fprintf(stderr, _("%s: %s: %s in line %d\n"),
- progname, xquote(filename), strerror(errno),
+ progname, xquote(filename, "\n\r"), strerror(errno),
line);
status = 1;
goto getout;
@@ -177,7 +177,7 @@ restore(
error = stat(path_p, &st);
if (opt_test && error != 0) {
fprintf(stderr, "%s: %s: %s\n", progname,
- xquote(path_p), strerror(errno));
+ xquote(path_p, "\n\r"), strerror(errno));
status = 1;
}
@@ -200,7 +200,7 @@ restore(
if (chown(path_p, st.st_uid, st.st_gid) != 0) {
fprintf(stderr, _("%s: %s: Cannot change "
"owner/group: %s\n"),
- progname, xquote(path_p),
+ progname, xquote(path_p, "\n\r"),
strerror(errno));
status = 1;
}
@@ -228,7 +228,7 @@ getout:
return status;
fail:
- fprintf(stderr, "%s: %s: %s\n", progname, xquote(filename),
+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(filename, "\n\r"),
strerror(errno));
status = 1;
goto getout;
@@ -481,7 +481,7 @@ int main(int argc, char *argv[])
if (file == NULL) {
fprintf(stderr, "%s: %s: %s\n",
progname,
- xquote(optarg),
+ xquote(optarg, "\n\r"),
strerror(errno));
status = 2;
goto cleanup;
@@ -507,7 +507,7 @@ int main(int argc, char *argv[])
progname,
strerror(errno),
lineno,
- xquote(optarg));
+ xquote(optarg, "\n\r"));
} else {
fprintf(stderr, _(
"%s: %s in line "
@@ -540,7 +540,7 @@ int main(int argc, char *argv[])
if (file == NULL) {
fprintf(stderr, "%s: %s: %s\n",
progname,
- xquote(optarg),
+ xquote(optarg, "\n\r"),
strerror(errno));
status = 2;
goto cleanup;