xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 2/4] Do not multiply console hvc0 getty entries
Date: Tue, 29 Sep 2015 17:21:26 +0100	[thread overview]
Message-ID: <1443543688-1195-3-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1443543688-1195-1-git-send-email-ian.jackson@eu.citrix.com>

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>
---
 Osstest/TestSupport.pm |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 3fc8e15..09694f4 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -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:/;
-- 
1.7.10.4

  parent reply	other threads:[~2015-09-29 16:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 16:21 [OSSTEST PATCH 0/4] Miscellaneous bald yaks Ian Jackson
2015-09-29 16:21 ` [OSSTEST PATCH 1/4] ts-debian-fixup: Set password Ian Jackson
2015-09-29 16:21 ` Ian Jackson [this message]
2015-09-29 16:21 ` [OSSTEST PATCH 3/4] Runvar functions: Provide target_xenkernel_ver Ian Jackson
2015-09-29 16:21 ` [OSSTEST PATCH 4/4] Runvar functions: Introduce target_var and target_store_runvar Ian Jackson
2015-09-30  8:20 ` [OSSTEST PATCH 0/4] Miscellaneous bald yaks Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443543688-1195-3-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).