[systemd-commits] 2 commits - src/getty-generator

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Thu Jun 19 19:14:28 PDT 2014


 src/getty-generator/getty-generator.c |   24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

New commits:
commit a2ae516a25dafe41e0cd296ab7b5d022fa62b95f
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Jun 19 22:02:55 2014 -0400

    getty-generator: properly escape instance names
    
    Otherwise the add_symlink() function tries to make directories for
    each slash even for the slash after the @ symbol in the final link
    name, failing for /dev/3270/tty1.
    
    Based on a patch by Werner Fink <werner at suse.de>.

diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
index 35cd858..7d4b546 100644
--- a/src/getty-generator/getty-generator.c
+++ b/src/getty-generator/getty-generator.c
@@ -67,7 +67,7 @@ static int add_serial_getty(const char *tty) {
 
         log_debug("Automatically adding serial getty for /dev/%s.", tty);
 
-        n = unit_name_replace_instance("serial-getty at .service", tty);
+        n = unit_name_from_path_instance("serial-getty", tty, ".service");
         if (!n)
                 return log_oom();
 
@@ -81,7 +81,7 @@ static int add_container_getty(const char *tty) {
 
         log_debug("Automatically adding container getty for /dev/pts/%s.", tty);
 
-        n = unit_name_replace_instance("container-getty at .service", tty);
+        n = unit_name_from_path_instance("container-getty", tty, ".service");
         if (!n)
                 return log_oom();
 

commit f56506141cbf6391b0373108a2522ba771b25f4b
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Jun 19 21:48:32 2014 -0400

    getty-generator: use strappenda
    
    Allocating on the stack should be fine for the fixed number
    of items.

diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
index 6a4aa2c..35cd858 100644
--- a/src/getty-generator/getty-generator.c
+++ b/src/getty-generator/getty-generator.c
@@ -35,19 +35,14 @@
 static const char *arg_dest = "/tmp";
 
 static int add_symlink(const char *fservice, const char *tservice) {
-        _cleanup_free_ char *from = NULL, *to = NULL;
+        char *from, *to;
         int r;
 
         assert(fservice);
         assert(tservice);
 
-        from = strappend(SYSTEM_DATA_UNIT_PATH "/", fservice);
-        if (!from)
-                return log_oom();
-
-        to = strjoin(arg_dest,"/getty.target.wants/", tservice, NULL);
-        if (!to)
-                return log_oom();
+        from = strappenda(SYSTEM_DATA_UNIT_PATH "/", fservice);
+        to = strappenda3(arg_dest, "/getty.target.wants/", tservice);
 
         mkdir_parents_label(to, 0755);
 
@@ -221,14 +216,9 @@ int main(int argc, char *argv[]) {
         /* Automatically add in a serial getty on the first
          * virtualizer console */
         NULSTR_FOREACH(j, virtualization_consoles) {
-                _cleanup_free_ char *p = NULL;
-
-                p = strappend("/sys/class/tty/", j);
-                if (!p) {
-                        log_oom();
-                        return EXIT_FAILURE;
-                }
+                char *p;
 
+                p = strappenda("/sys/class/tty/", j);
                 if (access(p, F_OK) < 0)
                         continue;
 



More information about the systemd-commits mailing list