]> xenbits.xensource.com Git - osstest.git/commitdiff
Do not multiply console hvc0 getty entries
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 29 Sep 2015 13:19:05 +0000 (14:19 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 2 Oct 2015 10:32:50 +0000 (11:32 +0100)
target_kernkind_console_inittab is supposed to edit inittab to make
sure that there is a getty running on hvc0.

However:
 - It is not idempotent; if run more than once it can produce duplicate
   entries `1:' and `xc:'.
 - It works by copying and editing the entry `1:' but it might be that
   there is already another console entry for hvc0 for some other
   reason.

If we end up with multiple entries for hvc0, we can have two copies of
getty fighting, and if you manage to log in, one of them will be
fighting with your shell.

Guard the script with a grep, which looks for inittab entries
mentioning the intended console.  This makes makes it do nothing if
nothing is needed (and therefore it also makes it idempotent).

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Osstest/TestSupport.pm

index 3fc8e1590c0b2d78eca2a58a94df6d9654b4ac88..09694f4e155733b6157ee34b5d60d9ed1fbdb3b8 100644 (file)
@@ -2027,7 +2027,8 @@ sub target_kernkind_console_inittab ($$$) {
     if (defined $console && length $console) {
         target_cmd_root($ho, <<END);
             set -ex
-            perl -i~ -ne "
+            egrep '^[0-9a-zA-Z].*getty.* $console\$' $inittabpath \\
+           || perl -i~ -ne "
                 next if m/^xc:/;
                 print \\\$_ or die \\\$!;
                 next unless s/^1:/xc:/;