From: Sasha Levin Subject: [PATCH 2/2] kvm tools: Create /etc/passwd in shared rootfs Date: Mon, 7 Nov 2011 23:36:21 +0200 Message-ID: <1320701781-20635-2-git-send-email-levinsasha928@gmail.com> References: <1320701781-20635-1-git-send-email-levinsasha928@gmail.com> Cc: dvhart@linux.intel.com, kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@cs.helsinki.fi Return-path: Received: from mail-bw0-f46.google.com ([209.85.214.46]:37146 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752950Ab1KGViZ (ORCPT ); Mon, 7 Nov 2011 16:38:25 -0500 Received: by bke11 with SMTP id 11so4040993bke.19 for ; Mon, 07 Nov 2011 13:38:24 -0800 (PST) In-Reply-To: <1320701781-20635-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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