[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] Use augeas to update securetty



augeas now supports securetty. This resolves a failure when securetty isn't
present in the guest.

Resolves RHBZ#639413
---
 lib/Sys/VirtV2V/Converter/Linux.pm |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/lib/Sys/VirtV2V/Converter/Linux.pm b/lib/Sys/VirtV2V/Converter/Linux.pm
index b2eb774..22aa03f 100644
--- a/lib/Sys/VirtV2V/Converter/Linux.pm
+++ b/lib/Sys/VirtV2V/Converter/Linux.pm
@@ -218,20 +218,14 @@ sub _configure_console
     }
 
     # Replace any mention of xvc0 or hvc0 in /etc/securetty with ttyS0
-    my $size = 0;
-    my @lines = ();
+    foreach my $augpath ($g->aug_match('/files/etc/securetty/*')) {
+        my $tty = $g->aug_get($augpath);
 
-    foreach my $line ($g->read_lines('/etc/securetty')) {
-        if($line eq "xvc0" || $line eq "hvc0") {
-            $line = "ttyS0";
+        if($tty eq "xvc0" || $tty eq "hvc0") {
+            $g->aug_set($augpath, 'ttyS0');
         }
-
-        $size += length($line) + 1;
-        push(@lines, $line);
     }
 
-    $g->write_file('/etc/securetty', join("\n", @lines)."\n", $size);
-
     # Update any kernel console lines
     foreach my $augpath
         ($g->aug_match("/files/boot/grub/menu.lst/title/kernel/console"))
-- 
1.7.2.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]