[PATCH] LXC: mount /dev/pts/0 to /dev/console

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

 



Now, /dev/console is linked to the /dev/pts/0,
so for the process agetty, the tty device of
agetty is pts/0. this will cause login container
failed.
since pts/0 is not in the /etc/securetty. so
pam module pam_securetty will prevent the root
user logging on the system.

this patch doesn't make /dev/console a symbol but
binds /dev/pts/0 to it. so the tty device of
agetty will be console. root can login the system
successfully.

Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
---
 src/lxc/lxc_container.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 255c711..1cede41 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1049,12 +1049,19 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
             return -1;
         }
         VIR_FREE(tty);
-        if (i == 0 &&
-            symlink(ttyPaths[i], "/dev/console") < 0) {
-            virReportSystemError(errno,
-                                 _("Failed to symlink %s to /dev/console"),
-                                 ttyPaths[i]);
-            return -1;
+        if (i == 0) {
+            if (virFileTouch("/dev/console", 0600) < 0) {
+                virReportSystemError(errno, "%s",
+                                     _("Failed to create /dev/console"));
+                return -1;
+            }
+
+            if (mount(ttyPaths[0], "/dev/console", NULL, MS_BIND, NULL) < 0) {
+                virReportSystemError(errno,
+                                     _("Failed to symlink %s to /dev/console"),
+                                     ttyPaths[i]);
+                return -1;
+            }
         }
     }
     return 0;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]