From 08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sun, 1 Nov 2015 18:53:26 +0000 Subject: all: avoid quoting file names when possible Quote file names using the "shell-escape" or "shell-escape-always" methods, which quote as appropriate for most shells, and better support copy and paste of presented names. The "always" variant is used when the file name is embedded in an error message with surrounding spaces. * cfg.mk (sc_error_shell_quotes): A new syntax check rule to suggest quotef() where appropriate. (sc_error_shell_always_quotes): Likewise for quoteaf(). * src/system.h (quotef): A new define to apply shell quoting when needed. I.E. when shell character or ':' is present. (quoteaf): Likewise, but always quote. * src/*.c: Use quotef() and quoteaf() rather than quote() where appropriate. * tests/: Adjust accordingly. --- src/selinux.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/selinux.c') diff --git a/src/selinux.c b/src/selinux.c index 99b1fb0bf..6479c9392 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -26,7 +26,6 @@ #include "canonicalize.h" #include "dosname.h" #include "xfts.h" -#include "quote.h" #include "selinux.h" #if HAVE_SELINUX_SELINUX_H @@ -125,7 +124,7 @@ defaultcon (char const *path, mode_t mode) newpath = canonicalize_filename_mode (path, CAN_MISSING); if (! newpath) error (EXIT_FAILURE, errno, _("error canonicalizing %s"), - quote (path)); + quoteaf (path)); path = newpath; } @@ -298,7 +297,7 @@ restorecon (char const *path, bool recurse, bool local) newpath = canonicalize_filename_mode (path, CAN_MISSING); if (! newpath) error (EXIT_FAILURE, errno, _("error canonicalizing %s"), - quote (path)); + quoteaf (path)); } const char *ftspath[2] = { newpath ? newpath : path, NULL }; -- cgit v1.2.3-54-g00ecf