]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub_all: fix systemd escaping again
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 10 Oct 2018 19:35:48 +0000 (14:35 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 10 Oct 2018 19:35:48 +0000 (14:35 -0500)
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:

 # xfs_scrub_all
 Scrubbing /home...
  Invalid unit name "xfs_scrub@/home" was escaped as "xfs_scrub@-home"
 (maybe you should use systemd-escape?)
 Starting Online XFS Metadata Check for /home...

So change the systemd_escape() function to escape paths unconditionally
to make the warning go away.

Reported-by: Matthias Bodenbinder <matthias@bodenbinder.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/xfs_scrub_all.in

index f7d9e6c7bf92afb15b0724bf8b6668ba6e6e6a92..c4e9899d42c62590d771105a343b259ac40c1cee 100644 (file)
@@ -82,11 +82,16 @@ def run_killable(cmd, stdout, killfuncs, kill_fn):
 # actually /can/ escape the dashes correctly if it is told that this is a path
 # (and not a unit name), but it didn't do this prior to January 2017, so fix
 # this for them.
+#
+# 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.
 def systemd_escape(path):
        '''Escape a path to avoid mangled systemd mangling.'''
 
-       if '-' not in path:
-               return path
+       if path == '/':
+               return '-'
        cmd = ['systemd-escape', '--path', path]
        try:
                proc = subprocess.Popen(cmd, stdout = subprocess.PIPE)