summaryrefslogtreecommitdiff
path: root/scrub/e2scrub_all.in
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-11-05 09:59:46 -0800
committerTheodore Ts'o <tytso@mit.edu>2018-11-15 14:20:35 -0500
commite6a3faa237b15e2fe576c249250636cdd6a38cc7 (patch)
tree8c17f9122ebc5777169bdd2d26f71047b82c0966 /scrub/e2scrub_all.in
parentae9c0f3666de1aec5ebb2663346dcfc116f90f50 (diff)
downloade2fsprogs-e6a3faa237b15e2fe576c249250636cdd6a38cc7.tar.gz
e2scrub: fix systemd escaping again
Apparently newer versions of systemd than the one on this author's laptop <cough> now complain about lack of (path) escaping in unit instance variable contents: # e2scrub_all Scrubbing /home... Invalid unit name "e2scrub@/home" was escaped as "e2scrub@-home" (maybe you should use systemd-escape?) Starting Online ext4 Metadata Check for /home... So change the escape_path_for_systemd function to escape paths unconditionally to make the warning go away. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'scrub/e2scrub_all.in')
-rw-r--r--scrub/e2scrub_all.in9
1 files changed, 7 insertions, 2 deletions
diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in
index 9581dc2c..23d122d2 100644
--- a/scrub/e2scrub_all.in
+++ b/scrub/e2scrub_all.in
@@ -101,13 +101,18 @@ ls_scrub_targets() {
# systemd doesn't know to do path escaping on the instance variable we pass
# to the e2scrub service, which breaks things if there is a dash in the path
# name. Therefore, do the path escaping ourselves if needed.
+#
+# systemd path escaping also drops the initial slash so we add that back in so
+# that log messages from the service units preserve the full path and users can
+# look up log messages using full paths. However, for "/" the escaping rules
+# do /not/ drop the initial slash, so we have to special-case that here.
escape_path_for_systemd() {
local path="$1"
- if echo "${path}" | grep -q -- "-"; then
+ if [ "${path}" != "/" ]; then
echo "-$(systemd-escape --path "${path}")"
else
- echo "${path}"
+ echo "-"
fi
}