[systemd-commits] 2 commits - src/login src/shared

Kay Sievers kay at kemper.freedesktop.org
Mon Jun 4 06:10:02 PDT 2012


 src/login/logind-inhibit.h |    1 -
 src/shared/unit-name.c     |   29 ++++++++++++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)

New commits:
commit 4b7126538c25268c79ff10d166920934f149a329
Author: Kay Sievers <kay at vrfy.org>
Date:   Mon Jun 4 14:57:24 2012 +0200

    unit-name: never create a unit name with a leading '.'
    
    Supposed to prevent creating unit files like:
      ├── dev-sda1.device.wants
      │   └── .dot.mount -> /run/systemd/generator/.dot.mount
      ├── .dot.mount
    from:
      # cat /etc/fstab
      /dev/sda1    /.dot           vfat ro           1 3
    
    which we later skip reading because of the leading '.'.

diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c
index e0a18d1..1440d2f 100644
--- a/src/shared/unit-name.c
+++ b/src/shared/unit-name.c
@@ -179,19 +179,30 @@ char *unit_name_build(const char *prefix, const char *instance, const char *suff
         return join(prefix, "@", instance, suffix, NULL);
 }
 
-static char* do_escape(const char *f, char *t) {
+static char *do_escape_char(char c, char *t) {
+        *(t++) = '\\';
+        *(t++) = 'x';
+        *(t++) = hexchar(c >> 4);
+        *(t++) = hexchar(c);
+        return t;
+}
+
+static char *do_escape(const char *f, char *t) {
         assert(f);
         assert(t);
 
+        /* do not create units with a leading '.', like for "/.dotdir" mount points */
+        if (*f == '.') {
+                t = do_escape_char(*f, t);
+                f++;
+        }
+
         for (; *f; f++) {
                 if (*f == '/')
                         *(t++) = '-';
-                else if (*f == '-' || *f == '\\' || !strchr(VALID_CHARS, *f)) {
-                        *(t++) = '\\';
-                        *(t++) = 'x';
-                        *(t++) = hexchar(*f >> 4);
-                        *(t++) = hexchar(*f);
-                } else
+                else if (*f == '-' || *f == '\\' || !strchr(VALID_CHARS, *f))
+                        t = do_escape_char(*f, t);
+                else
                         *(t++) = *f;
         }
 
@@ -209,8 +220,8 @@ char *unit_name_build_escape(const char *prefix, const char *instance, const cha
          * suffix and makes a nice string suitable as unit name of it,
          * escaping all weird chars on the way.
          *
-         * / becomes ., and all chars not allowed in a unit name get
-         * escaped as \xFF, including \ and ., of course. This
+         * / becomes -, and all chars not allowed in a unit name get
+         * escaped as \xFF, including \ and -, of course. This
          * escaping is hence reversible.
          *
          * This is primarily useful to make nice unit names from

commit cabe5d25640914be1000d23bcdd29d2ffc6333de
Author: Malte Starostik <m-starostik at versanet.de>
Date:   Sun Jun 3 21:39:21 2012 +0200

    logind: punt duplicate definition of InhibitWhat
    
    Trivial fix for:
      src/login/logind-inhibit.h:37:3: error: redefinition of typedef 'InhibitWhat'
      src/login/logind-inhibit.h:26:26: note: previous declaration of 'InhibitWhat' was here

diff --git a/src/login/logind-inhibit.h b/src/login/logind-inhibit.h
index 4377f00..e72536f 100644
--- a/src/login/logind-inhibit.h
+++ b/src/login/logind-inhibit.h
@@ -23,7 +23,6 @@
 ***/
 
 typedef struct Inhibitor Inhibitor;
-typedef enum InhibitWhat InhibitWhat;
 
 #include "list.h"
 #include "util.h"



More information about the systemd-commits mailing list