[PATCH 2/2] kvm tools: Create /etc/passwd in shared rootfs

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

 



This patch creates a dummy /etc/passwd on guest creation.

This is done because some applications (read: git) get angry when they
can't find current user in /etc/passwd.

Reported-by: Darren Hart <dvhart@xxxxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/builtin-setup.c |   15 ++++++++++++++-
 tools/kvm/guest/passwd    |    1 +
 2 files changed, 15 insertions(+), 1 deletions(-)
 create mode 100644 tools/kvm/guest/passwd

diff --git a/tools/kvm/builtin-setup.c b/tools/kvm/builtin-setup.c
index 7deb0ed..fb8a1b3 100644
--- a/tools/kvm/builtin-setup.c
+++ b/tools/kvm/builtin-setup.c
@@ -131,6 +131,15 @@ static int copy_init(const char *guestfs_name)
 	return copy_file("guest/init", path);
 }
 
+static int copy_passwd(const char *guestfs_name)
+{
+	char path[PATH_MAX];
+
+	snprintf(path, PATH_MAX, "%s%s/etc/passwd", kvm__get_dir(), guestfs_name);
+
+	return copy_file("guest/passwd", path);
+}
+
 static int make_guestfs_symlink(const char *guestfs_name, const char *path)
 {
 	char target[PATH_MAX];
@@ -197,7 +206,11 @@ static int do_setup(const char *guestfs_name)
 		make_guestfs_symlink(guestfs_name, guestfs_symlinks[i]);
 	}
 
-	return copy_init(guestfs_name);
+	ret = copy_init(guestfs_name);
+	if (ret < 0)
+		return ret;
+
+	return copy_passwd(guestfs_name);
 }
 
 int kvm_setup_create_new(const char *guestfs_name)
diff --git a/tools/kvm/guest/passwd b/tools/kvm/guest/passwd
new file mode 100644
index 0000000..eb85a55
--- /dev/null
+++ b/tools/kvm/guest/passwd
@@ -0,0 +1 @@
+root:x:0:0:root:/root:/bin/sh
-- 
1.7.7.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux