From 9c22b9873aed0922d55ca11fba72d02fbc385d0b Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 7 Nov 2011 23:36:21 +0200 Subject: [PATCH] kvm tools: Create /etc/passwd in shared rootfs 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 Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- tools/kvm/builtin-setup.c | 15 ++++++++++++++- tools/kvm/guest/passwd | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tools/kvm/guest/passwd diff --git a/tools/kvm/builtin-setup.c b/tools/kvm/builtin-setup.c index 7deb0ed7c4eb..fb8a1b3f05de 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 000000000000..eb85a552ad2a --- /dev/null +++ b/tools/kvm/guest/passwd @@ -0,0 +1 @@ +root:x:0:0:root:/root:/bin/sh -- 2.39.5