From nobody Mon Apr 29 01:33:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569604395; cv=none; d=zoho.com; s=zohoarc; b=j0ek78arg3puN4tMoaL5LBwHtxEVIKSBx10JzYOBQi885eJYS9k1A0TY4qksG7NTiiq2JbMEIwZhYewUXcENbNuO5MukgIWM+Ay8jPDlKpFHg5KYrt6TI4+Jc2sxwrDBZTOxdgJyB5SWctcD389j+BkAgFR8WP699D6knGXofnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569604395; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=/L6t0sDBnIb5W+xzFLLmYC15TD8YP35+5v9C5hm6n88=; b=ZIQ03XSf/PKFrWsHQ+7PYMVT99SDqgMM66tFU/G/BZSM8OboX8W+lXMTe6XR0adAg5htQC1N5XbvUhDSuMR4ygT0zDp8kfmhQPV747m4ZkhCQxctv38VXW+m9IuFAxsixSIm+Z0ei4KbWqaiK6QtCNyWlxEpI5nFS9x42kBlOOc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1569604395193514.4444452847574; Fri, 27 Sep 2019 10:13:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9790531628F5; Fri, 27 Sep 2019 17:13:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25E8B5D9C9; Fri, 27 Sep 2019 17:13:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BC0D54E58A; Fri, 27 Sep 2019 17:13:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8RHD79F016171 for ; Fri, 27 Sep 2019 13:13:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 862ED10001BC; Fri, 27 Sep 2019 17:13:07 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 947DF10013A7; Fri, 27 Sep 2019 17:13:03 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 27 Sep 2019 18:13:01 +0100 Message-Id: <20190927171301.10417-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] tools: fix regression passing command with virt-login-shell X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 27 Sep 2019 17:13:13 +0000 (UTC) It is documented that a command to run inside the container can be passed with the -c arg. virt-login-shell -c "ls -l /" This fixes commit 4feeb2d986b98013ebfb1d41ab6b9007b6cce6e2 Author: Daniel P. Berrang=C3=A9 Date: Thu Aug 1 10:58:31 2019 +0100 tools: split virt-login-shell into two binaries Signed-off-by: Daniel P. Berrang=C3=A9 --- tools/virt-login-shell.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index f92cc0a749..7d1e0ccc8a 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -38,12 +38,8 @@ int main(int argc, char **argv) { char uidstr[INT_BUFSIZE_BOUND(uid_t)]; char gidstr[INT_BUFSIZE_BOUND(gid_t)]; - const char *const newargv[] =3D { - LIBEXECDIR "/virt-login-shell-helper", - uidstr, - gidstr, - NULL, - }; + const char * newargv[6]; + size_t nargs =3D 0; char *newenv[] =3D { NULL, NULL, @@ -60,10 +56,23 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } =20 - if (argc !=3D 1) { - fprintf(stderr, "%s: no arguments expected\n", argv[0]); + newargv[nargs++] =3D LIBEXECDIR "/virt-login-shell-helper"; + if (argc =3D=3D 3) { + if (strcmp(argv[1], "-c") !=3D 0) { + fprintf(stderr, "%s: syntax: %s [-c CMDSTR]\n", argv[0], argv[= 0]); + exit(EXIT_FAILURE); + } + newargv[nargs++] =3D argv[1]; + newargv[nargs++] =3D argv[2]; + } else if (argc !=3D 1) { + fprintf(stderr, "%s: syntax: %s [-c CMDSTR]\n", argv[0], argv[0]); exit(EXIT_FAILURE); } + newargv[nargs++] =3D uidstr; + newargv[nargs++] =3D gidstr; + newargv[nargs++] =3D NULL; + + assert(nargs <=3D (sizeof(newargv)/sizeof(newargv[0]))); =20 if (term && asprintf(&(newenv[0]), "TERM=3D%s", term) < 0) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list