From nobody Sat Nov 30 16:27:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1601653341; cv=none; d=zohomail.com; s=zohoarc; b=UKDN3DJTj+NJ5+K8cigcLlNx/L8pVW4aepV02OKjHp8ZnAIAOMbu9oeolNcuqpiJqx3iIf+YRo0RKoHEN9VLiw80ZFXLNts0RcDXPTddFTVbibncGWFA0EhihRzpFeZt1dOWHBV67T4fSPZOnA3D1tu17bDy8e/fNhqSaR/xNWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601653341; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6NXymCcIW4Fjm67kMAu1GZlcSOUTMK3m1fQFdWrEW6A=; b=mczzl/zCUPHHLwxaeU+i+91awj+DUU5Ht0IAEx0jGTkmYJDVil+hXMeGvHRw8lY4xDNLBAupobkxRRk/mbFjhI1Ohmq1Z00ji0N0GmHhmIHFjrQg7f+N8cNOI4B2ngnFME6BluF8tuPlSeHjIV0HPdie2HmoagYAwf0bY0s0BKI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601653341360134.70339786973432; Fri, 2 Oct 2020 08:42:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.2234.6625 (Exim 4.92) (envelope-from ) id 1kONBx-000718-SO; Fri, 02 Oct 2020 15:41:53 +0000 Received: by outflank-mailman (output) from mailman id 2234.6625; Fri, 02 Oct 2020 15:41:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBx-00070g-FG; Fri, 02 Oct 2020 15:41:53 +0000 Received: by outflank-mailman (input) for mailman id 2234; Fri, 02 Oct 2020 15:41:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBw-0006vD-9T for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:52 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 763a8954-9454-401c-b98d-f5c3d1e992f8; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 33DA2ACC8; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBw-0006vD-9T for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:52 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 763a8954-9454-401c-b98d-f5c3d1e992f8; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 33DA2ACC8; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 763a8954-9454-401c-b98d-f5c3d1e992f8 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601653305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6NXymCcIW4Fjm67kMAu1GZlcSOUTMK3m1fQFdWrEW6A=; b=ht1KggQYReLOBEjjwP8uq8Grnk1/oAKhl8LjXUDMC35tiXMauCdt+3LQX/Dd9mbJ5L9EVe c2c7BPdeMhSo/q+1HDhGueqb09UTbBu62wTChL9mndUUJaT/1N8NBnpraUp2ITS1YjzaRi uM21An7wQm2n4kUXcnaIe4QMd9krXz0= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH 1/5] tools/xenstore: remove socket-only option from xenstore client Date: Fri, 2 Oct 2020 17:41:37 +0200 Message-Id: <20201002154141.11677-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002154141.11677-1-jgross@suse.com> References: <20201002154141.11677-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" The Xenstore access commands (xenstore-*) have the possibility to limit connection to Xenstore to a local socket (option "-s"). This is an option making no sense at all, as either there is only a socket, so the option would be a nop, or there is no socket at all (in case Xenstore is running in a stubdom or the client is called in a domU), so specifying the option would just lead to failure. So drop that option completely. Signed-off-by: Juergen Gross --- docs/man/xenstore-chmod.1.pod | 4 ---- docs/man/xenstore-ls.1.pod | 4 ---- docs/man/xenstore-read.1.pod | 4 ---- docs/man/xenstore-write.1.pod | 4 ---- tools/xenstore/xenstore_client.c | 8 ++------ 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/docs/man/xenstore-chmod.1.pod b/docs/man/xenstore-chmod.1.pod index d76f34723d..d221f5dffc 100644 --- a/docs/man/xenstore-chmod.1.pod +++ b/docs/man/xenstore-chmod.1.pod @@ -46,10 +46,6 @@ write, and set permissions). =20 Apply the permissions to the key and all its I. =20 -=3Ditem B<-s> - -Connect to the Xenstore daemon using a local socket only. - =3Ditem B<-u> =20 Apply the permissions to the key and all its I. diff --git a/docs/man/xenstore-ls.1.pod b/docs/man/xenstore-ls.1.pod index 8dac931e94..a9f8b32653 100644 --- a/docs/man/xenstore-ls.1.pod +++ b/docs/man/xenstore-ls.1.pod @@ -50,10 +50,6 @@ I the permissions for any domain not explicitly lis= ted in subsequent entries. The key owner always has full access (read, write, and set permissions). =20 -=3Ditem B<-s> - -Connect to the Xenstore daemon using a local socket only. - =3Dback =20 =3Dhead1 BUGS diff --git a/docs/man/xenstore-read.1.pod b/docs/man/xenstore-read.1.pod index f5a7bb7e46..c7768cbbe5 100644 --- a/docs/man/xenstore-read.1.pod +++ b/docs/man/xenstore-read.1.pod @@ -16,10 +16,6 @@ Read values of one or more Xenstore Is. =20 Prefix value with key name. =20 -=3Ditem B<-s> - -Connect to the Xenstore daemon using a local socket only. - =3Ditem B<-R> =20 Read raw value, skip escaping non-printable characters (\x..). diff --git a/docs/man/xenstore-write.1.pod b/docs/man/xenstore-write.1.pod index d1b011236a..a0b1bca333 100644 --- a/docs/man/xenstore-write.1.pod +++ b/docs/man/xenstore-write.1.pod @@ -13,10 +13,6 @@ provided to write them at once - in one Xenstore transac= tion. =20 =3Dover =20 -=3Ditem B<-s> - -Connect to the Xenstore daemon using a local socket only. - =3Ditem B<-R> =20 Write raw value, skip parsing escaped characters (\x..). diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_cli= ent.c index ae7ed3eb9e..8015bfe5be 100644 --- a/tools/xenstore/xenstore_client.c +++ b/tools/xenstore/xenstore_client.c @@ -530,7 +530,7 @@ main(int argc, char **argv) { struct xs_handle *xsh; xs_transaction_t xth =3D XBT_NULL; - int ret =3D 0, socket =3D 0; + int ret =3D 0; int prefix =3D 0; int tidy =3D 0; int upto =3D 0; @@ -565,7 +565,6 @@ main(int argc, char **argv) static struct option long_options[] =3D { {"help", 0, 0, 'h'}, {"flat", 0, 0, 'f'}, /* MODE_ls */ - {"socket", 0, 0, 's'}, {"prefix", 0, 0, 'p'}, /* MODE_read || MODE_list || MODE_ls */ {"tidy", 0, 0, 't'}, /* MODE_rm */ {"upto", 0, 0, 'u'}, /* MODE_chmod */ @@ -593,9 +592,6 @@ main(int argc, char **argv) usage(mode, switch_argv, argv[0]); } break; - case 's': - socket =3D 1; - break; case 'p': if ( mode =3D=3D MODE_read || mode =3D=3D MODE_list || mode =3D=3D MO= DE_ls ) prefix =3D 1; @@ -675,7 +671,7 @@ main(int argc, char **argv) max_width =3D ws.ws_col - 2; } =20 - xsh =3D xs_open(socket ? XS_OPEN_SOCKETONLY : 0); + xsh =3D xs_open(0); if (xsh =3D=3D NULL) err(1, "xs_open"); =20 again: --=20 2.26.2 From nobody Sat Nov 30 16:27:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1601653342; cv=none; d=zohomail.com; s=zohoarc; b=LOx86YVw/XJcwzScD45/pZLe9EpOgTQblNbrMsHoJZZWct1hAxc1haDymasbTacSsF5qHvYf61qr8vosB+21sp0s1oUw/H103KoTQlEsMSOEnOolSgUiRu19YCupPFYoMu1xzfDbJickQGNVVfcGGAeZVvzOZY+2+wwYu3+jnt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601653342; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gcLMBVGwJcyyJDDSc6Pbxmq7yh49BQo92DhFtrzVoNM=; b=FtAIZLMyUxYXKbodBgmDxBsZQQLri0dXAFudOpdHnDPO+Zpdu/6Es0/tg9pN5UDe3SGxrJilerPu+2xinBij3J7MRkqfl07Wl4GOn1+ofQfA14OtvuVuxnoR0ze5Ag4bY0+DpENlUraCNkRCgSwgr+3rxbJ7lycT3KtuAIO72Pw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601653342639116.71996704026571; Fri, 2 Oct 2020 08:42:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.2235.6640 (Exim 4.92) (envelope-from ) id 1kONC3-00077l-2Y; Fri, 02 Oct 2020 15:41:59 +0000 Received: by outflank-mailman (output) from mailman id 2235.6640; Fri, 02 Oct 2020 15:41:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONC2-00077c-Td; Fri, 02 Oct 2020 15:41:58 +0000 Received: by outflank-mailman (input) for mailman id 2235; Fri, 02 Oct 2020 15:41:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONC1-0006vD-9j for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:57 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d4c67228-f86e-46c4-a739-4b1b0520460d; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5D3F0B265; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONC1-0006vD-9j for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:57 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d4c67228-f86e-46c4-a739-4b1b0520460d; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5D3F0B265; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d4c67228-f86e-46c4-a739-4b1b0520460d X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601653305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gcLMBVGwJcyyJDDSc6Pbxmq7yh49BQo92DhFtrzVoNM=; b=cXGOQcxRf2cFvKIIkdGEJ5gTvTQYqgbCwNcJpjgsizwJvcz+x7s2n3yA7QRwCR214ol4s5 g06OLukDAvd++ZJxbOoRL8KLOxK6gl0AzQaQJb7XPTs5pmp49iVC07/ifS/gu7+6doJxe3 Ry/QPwjF2Z2YjFj2uQmn8KcNSdl/Hrc= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH 2/5] tools/libs/store: ignore XS_OPEN_SOCKETONLY flag Date: Fri, 2 Oct 2020 17:41:38 +0200 Message-Id: <20201002154141.11677-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002154141.11677-1-jgross@suse.com> References: <20201002154141.11677-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" When opening the connection to Xenstore via xs_open() it makes no sense to limit the connection to the socket based one. So just ignore the XS_OPEN_SOCKETONLY flag. Signed-off-by: Juergen Gross --- tools/libs/store/include/xenstore.h | 2 -- tools/libs/store/xs.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/libs/store/include/xenstore.h b/tools/libs/store/include= /xenstore.h index 25b31881c8..cbc7206a0f 100644 --- a/tools/libs/store/include/xenstore.h +++ b/tools/libs/store/include/xenstore.h @@ -66,8 +66,6 @@ typedef uint32_t xs_transaction_t; * * Connections made with xs_open(0) (which might be shared page or * socket based) are only guaranteed to work in the parent after * fork. - * * Connections made with xs_open(XS_OPEN_SOCKETONLY) will be usable - * in either the parent or the child after fork, but not both. * * xs_daemon_open*() and xs_domain_open() are deprecated synonyms * for xs_open(0). * * XS_OPEN_READONLY has no bearing on any of this. diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c index aa1d24b8b9..320734416f 100644 --- a/tools/libs/store/xs.c +++ b/tools/libs/store/xs.c @@ -319,7 +319,7 @@ struct xs_handle *xs_open(unsigned long flags) else xsh =3D get_handle(xs_daemon_socket()); =20 - if (!xsh && !(flags & XS_OPEN_SOCKETONLY)) + if (!xsh) xsh =3D get_handle(xs_domain_dev()); =20 if (xsh && (flags & XS_UNWATCH_FILTER)) --=20 2.26.2 From nobody Sat Nov 30 16:27:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1601653350; cv=none; d=zohomail.com; s=zohoarc; b=iWy1Rw8S3T1PRzTc7C6aP6Gt5SxgQ4nRK/Lpxhc2f6//bd13InYraEYLAZoMRJyVLnHktUcToUzTE8Ie0d5eGHu5CWLUm34/ntLIY1Yx9KETzX4mSbPK+nDSJOCnfYcwnE5wwygeCszDTkSox6NBFDBDSyvm5ayLc1DzD0rcpiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601653350; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FNF+aRfDbKHMZCseaVDAhmaSRPG1QxwjSNnLmsmdBpU=; b=jbsNZvjrkc3B+bqqj8P2ITz+GTEnR7R0DGNALc3FY/5vEPn6xd+ETEOjvu1AeH/EKwvAYrS8AqJaNdcOoFVn6OAQbC6/I0bRgX2F4rZJgWj3c2ynwRst9+K6ySg6kX/+748ohHvUBpwx6hzsnyC1+onx7D0B5pv7Go5qC6W/GqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601653350909733.0412710311919; Fri, 2 Oct 2020 08:42:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.2236.6652 (Exim 4.92) (envelope-from ) id 1kONC7-0007Dh-Jl; Fri, 02 Oct 2020 15:42:03 +0000 Received: by outflank-mailman (output) from mailman id 2236.6652; Fri, 02 Oct 2020 15:42:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONC7-0007DU-FH; Fri, 02 Oct 2020 15:42:03 +0000 Received: by outflank-mailman (input) for mailman id 2236; Fri, 02 Oct 2020 15:42:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONC6-0006vD-9v for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:42:02 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f0fb1f41-52ea-41f8-ad4f-6c9b0555a9f3; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 79682B269; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONC6-0006vD-9v for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:42:02 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f0fb1f41-52ea-41f8-ad4f-6c9b0555a9f3; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 79682B269; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f0fb1f41-52ea-41f8-ad4f-6c9b0555a9f3 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601653305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FNF+aRfDbKHMZCseaVDAhmaSRPG1QxwjSNnLmsmdBpU=; b=s3zAfuAk3ObNwVSkUaMaGpk4An9Odhdv0ughwfA6YdsIF1MFhYKHPsYLqpmhPVWfui+5p/ TKm1nFm2CI/IkuxovkbX7hD3Rup6TTu9giyVecUuqTnPGZRkDFesJzFKGmQHfOg9p3BfSU 5UAlA7q0eJySJUqoxPrndPrgGACaNs0= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH 3/5] tools/libs/store: drop read-only functionality Date: Fri, 2 Oct 2020 17:41:39 +0200 Message-Id: <20201002154141.11677-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002154141.11677-1-jgross@suse.com> References: <20201002154141.11677-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Today it is possible to open the connection in read-only mode via xs_daemon_open_readonly(). This is working only with Xenstore running as a daemon in the same domain as the user. Additionally it doesn't add any security as accessing the socket used for that functionality requires the same privileges as the socket used for full Xenstore access. So just drop the read-only semantics in all cases, leaving the interface existing only for compatibility reasons. This in turn requires to just ignore the XS_OPEN_READONLY flag. Signed-off-by: Juergen Gross --- tools/libs/store/include/xenstore.h | 8 -------- tools/libs/store/xs.c | 7 ++----- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/tools/libs/store/include/xenstore.h b/tools/libs/store/include= /xenstore.h index cbc7206a0f..158e69ef83 100644 --- a/tools/libs/store/include/xenstore.h +++ b/tools/libs/store/include/xenstore.h @@ -60,15 +60,12 @@ typedef uint32_t xs_transaction_t; /* Open a connection to the xs daemon. * Attempts to make a connection over the socket interface, * and if it fails, then over the xenbus interface. - * Mode 0 specifies read-write access, XS_OPEN_READONLY for - * read-only access. * * * Connections made with xs_open(0) (which might be shared page or * socket based) are only guaranteed to work in the parent after * fork. * * xs_daemon_open*() and xs_domain_open() are deprecated synonyms * for xs_open(0). - * * XS_OPEN_READONLY has no bearing on any of this. * * Returns a handle or NULL. */ @@ -83,11 +80,6 @@ void xs_close(struct xs_handle *xsh /* NULL ok */); */ struct xs_handle *xs_daemon_open(void); struct xs_handle *xs_domain_open(void); - -/* Connect to the xs daemon (readonly for non-root clients). - * Returns a handle or NULL. - * Deprecated, please use xs_open(XS_OPEN_READONLY) instead - */ struct xs_handle *xs_daemon_open_readonly(void); =20 /* Close the connection to the xs daemon. diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c index 320734416f..4ac73ec317 100644 --- a/tools/libs/store/xs.c +++ b/tools/libs/store/xs.c @@ -302,7 +302,7 @@ struct xs_handle *xs_daemon_open(void) =20 struct xs_handle *xs_daemon_open_readonly(void) { - return xs_open(XS_OPEN_READONLY); + return xs_open(0); } =20 struct xs_handle *xs_domain_open(void) @@ -314,10 +314,7 @@ struct xs_handle *xs_open(unsigned long flags) { struct xs_handle *xsh =3D NULL; =20 - if (flags & XS_OPEN_READONLY) - xsh =3D get_handle(xs_daemon_socket_ro()); - else - xsh =3D get_handle(xs_daemon_socket()); + xsh =3D get_handle(xs_daemon_socket()); =20 if (!xsh) xsh =3D get_handle(xs_domain_dev()); --=20 2.26.2 From nobody Sat Nov 30 16:27:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1601653340; cv=none; d=zohomail.com; s=zohoarc; b=J8Lo7I2+R0JPPX45CFgiY47M3lel+ZaS0KnOeouDYhP3eMsO8fZivPNJ1XKV5hLBB4oYpQzU/s414cnVpMmm40O3pSXgIBy1aIUulEpsZFlYQyLmI++W8KcxBBaA+ZtJ4mE5H1jIbwZu2h6iavC2TbC/rYLLYY8OwLEY6Ko0Yrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601653340; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KbrEsrqdNvWQhuDT/WAXgzByQyKfzuLyEZut1PWtipw=; b=JrlVYYdJLcWpxM1ZN1ayXm4Gtu/3ZNICvWbPRerSo2dSKloq8zlW0OBueWdtXGsfZQmS6zK5sVpRP+Y6ZmEyBeJKSNJScl0jxTx1vMfC40gGmOiTOysVI2S3VW9ovJPOjbg6xcYB+kDki8Ak/A7L2CbzrsrRRiKASCpoxUTRXi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601653340967559.2601108788648; Fri, 2 Oct 2020 08:42:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.2232.6604 (Exim 4.92) (envelope-from ) id 1kONBu-0006xa-Ux; Fri, 02 Oct 2020 15:41:50 +0000 Received: by outflank-mailman (output) from mailman id 2232.6604; Fri, 02 Oct 2020 15:41:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBu-0006xT-Qj; Fri, 02 Oct 2020 15:41:50 +0000 Received: by outflank-mailman (input) for mailman id 2232; Fri, 02 Oct 2020 15:41:48 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBs-0006v4-SS for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:48 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e1913937-ddf9-40d7-ae63-0f09078a303c; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 992C7B264; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBs-0006v4-SS for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:48 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e1913937-ddf9-40d7-ae63-0f09078a303c; Fri, 02 Oct 2020 15:41:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 992C7B264; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e1913937-ddf9-40d7-ae63-0f09078a303c X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601653305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KbrEsrqdNvWQhuDT/WAXgzByQyKfzuLyEZut1PWtipw=; b=OmTqquRryuHi+lVJnfyqJwl4ttcKsNieBVa6/IZlRTuW2hu1FvWSMDDifafqjMjySb+fDx qfjonnZ17444IlZXaT9sRUEs1vKQZ0jjZrBzGWEo3BjNFWavlgE87Ddek5RdPaX1quKESc SrJmjjR+SjnFYQ5qXk91H/qR0eMGWIw= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [PATCH 4/5] tools: drop all deprecated usages of xs_*_open() and friends in tools Date: Fri, 2 Oct 2020 17:41:40 +0200 Message-Id: <20201002154141.11677-5-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002154141.11677-1-jgross@suse.com> References: <20201002154141.11677-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Switch all usages of xs_daemon_open*() and xs_domain_open() to use xs_open() instead. While at it switch xs_daemon_close() users to xs_close(). Signed-off-by: Juergen Gross --- tools/console/client/main.c | 2 +- tools/console/daemon/utils.c | 4 ++-- tools/libs/light/libxl.c | 6 ++---- tools/libs/light/libxl_exec.c | 6 +++--- tools/libs/light/libxl_fork.c | 2 +- tools/libs/stat/xenstat.c | 4 ++-- tools/libs/vchan/init.c | 10 ++++------ tools/misc/xen-lowmemd.c | 4 ++-- tools/python/xen/lowlevel/xs/xs.c | 6 +++--- tools/tests/mce-test/tools/xen-mceinj.c | 4 ++-- tools/xenbackendd/xenbackendd.c | 4 ++-- tools/xenpmd/xenpmd.c | 6 +++--- 12 files changed, 27 insertions(+), 31 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index f92ad3d8cf..088be28dff 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -398,7 +398,7 @@ int main(int argc, char **argv) exit(EINVAL); } =20 - xs =3D xs_daemon_open(); + xs =3D xs_open(0); if (xs =3D=3D NULL) { err(errno, "Could not contact XenStore"); } diff --git a/tools/console/daemon/utils.c b/tools/console/daemon/utils.c index 97d7798b33..f9dd8a60c5 100644 --- a/tools/console/daemon/utils.c +++ b/tools/console/daemon/utils.c @@ -104,7 +104,7 @@ void daemonize(const char *pidfile) bool xen_setup(void) { =09 - xs =3D xs_daemon_open(); + xs =3D xs_open(0); if (xs =3D=3D NULL) { dolog(LOG_ERR, "Failed to contact xenstore (%m). Is it running?"); @@ -131,7 +131,7 @@ bool xen_setup(void) =20 out: if (xs) - xs_daemon_close(xs); + xs_close(xs); if (xc) xc_interface_close(xc); return false; diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index 621acc88f3..d2a87157a2 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -103,9 +103,7 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, rc =3D ERROR_FAIL; goto out; } =20 - ctx->xsh =3D xs_daemon_open(); - if (!ctx->xsh) - ctx->xsh =3D xs_domain_open(); + ctx->xsh =3D xs_open(0); if (!ctx->xsh) { LOGEV(ERROR, errno, "cannot connect to xenstore"); rc =3D ERROR_FAIL; goto out; @@ -171,7 +169,7 @@ int libxl_ctx_free(libxl_ctx *ctx) =20 if (ctx->xch) xc_interface_close(ctx->xch); libxl_version_info_dispose(&ctx->version_info); - if (ctx->xsh) xs_daemon_close(ctx->xsh); + if (ctx->xsh) xs_close(ctx->xsh); if (ctx->xce) xenevtchn_close(ctx->xce); =20 libxl__poller_put(ctx, ctx->poller_app); diff --git a/tools/libs/light/libxl_exec.c b/tools/libs/light/libxl_exec.c index 47c9c8f1ba..a8b949b193 100644 --- a/tools/libs/light/libxl_exec.c +++ b/tools/libs/light/libxl_exec.c @@ -178,7 +178,7 @@ int libxl__xenstore_child_wait_deprecated(libxl__gc *gc, unsigned int num; char **l =3D NULL; =20 - xsh =3D xs_daemon_open(); + xsh =3D xs_open(0); if (xsh =3D=3D NULL) { LOG(ERROR, "Unable to open xenstore connection"); goto err; @@ -206,7 +206,7 @@ int libxl__xenstore_child_wait_deprecated(libxl__gc *gc, =20 free(p); xs_unwatch(xsh, path, path); - xs_daemon_close(xsh); + xs_close(xsh); return rc; again: free(p); @@ -226,7 +226,7 @@ again: LOG(ERROR, "%s not ready", what); =20 xs_unwatch(xsh, path, path); - xs_daemon_close(xsh); + xs_close(xsh); err: return -1; } diff --git a/tools/libs/light/libxl_fork.c b/tools/libs/light/libxl_fork.c index 9a4709b9a4..5d47dceb8a 100644 --- a/tools/libs/light/libxl_fork.c +++ b/tools/libs/light/libxl_fork.c @@ -663,7 +663,7 @@ int libxl__ev_child_xenstore_reopen(libxl__gc *gc, cons= t char *what) { int rc; =20 assert(!CTX->xsh); - CTX->xsh =3D xs_daemon_open(); + CTX->xsh =3D xs_open(0); if (!CTX->xsh) { LOGE(ERROR, "%s: xenstore reopen failed", what); rc =3D ERROR_FAIL; goto out; diff --git a/tools/libs/stat/xenstat.c b/tools/libs/stat/xenstat.c index 6f93d4e982..e49689aa2d 100644 --- a/tools/libs/stat/xenstat.c +++ b/tools/libs/stat/xenstat.c @@ -107,7 +107,7 @@ xenstat_handle *xenstat_init(void) return NULL; } =20 - handle->xshandle =3D xs_daemon_open_readonly(); /* open handle to xenstor= e*/ + handle->xshandle =3D xs_open(0); /* open handle to xenstore*/ if (handle->xshandle =3D=3D NULL) { perror("unable to open xenstore"); xc_interface_close(handle->xc_handle); @@ -125,7 +125,7 @@ void xenstat_uninit(xenstat_handle * handle) for (i =3D 0; i < NUM_COLLECTORS; i++) collectors[i].uninit(handle); xc_interface_close(handle->xc_handle); - xs_daemon_close(handle->xshandle); + xs_close(handle->xshandle); free(handle->priv); free(handle); } diff --git a/tools/libs/vchan/init.c b/tools/libs/vchan/init.c index ad4b64fbe3..c8510e6ce9 100644 --- a/tools/libs/vchan/init.c +++ b/tools/libs/vchan/init.c @@ -251,7 +251,7 @@ static int init_xs_srv(struct libxenvchan *ctrl, int do= main, const char* xs_base char ref[16]; char* domid_str =3D NULL; xs_transaction_t xs_trans =3D XBT_NULL; - xs =3D xs_domain_open(); + xs =3D xs_open(0); if (!xs) goto fail; domid_str =3D xs_read(xs, 0, "domid", NULL); @@ -293,7 +293,7 @@ retry_transaction: } fail_xs_open: free(domid_str); - xs_daemon_close(xs); + xs_close(xs); fail: return ret; } @@ -408,9 +408,7 @@ struct libxenvchan *libxenvchan_client_init(struct xent= oollog_logger *logger, ctrl->write.order =3D ctrl->read.order =3D 0; ctrl->is_server =3D 0; =20 - xs =3D xs_daemon_open(); - if (!xs) - xs =3D xs_domain_open(); + xs =3D xs_open(0); if (!xs) goto fail; =20 @@ -452,7 +450,7 @@ struct libxenvchan *libxenvchan_client_init(struct xent= oollog_logger *logger, =20 out: if (xs) - xs_daemon_close(xs); + xs_close(xs); return ctrl; fail: libxenvchan_close(ctrl); diff --git a/tools/misc/xen-lowmemd.c b/tools/misc/xen-lowmemd.c index 79ad34cb4a..a3a2741242 100644 --- a/tools/misc/xen-lowmemd.c +++ b/tools/misc/xen-lowmemd.c @@ -24,7 +24,7 @@ void cleanup(void) if (xch) xc_interface_close(xch); if (xs_handle) - xs_daemon_close(xs_handle); + xs_close(xs_handle); } =20 /* Never shrink dom0 below 1 GiB */ @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) return 2; } =20 - xs_handle =3D xs_daemon_open(); + xs_handle =3D xs_open(0); if (xs_handle =3D=3D NULL) { perror("Failed to open xenstore connection"); diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/= xs/xs.c index b7d4b6ef5d..0dad7fa5f2 100644 --- a/tools/python/xen/lowlevel/xs/xs.c +++ b/tools/python/xen/lowlevel/xs/xs.c @@ -791,7 +791,7 @@ static PyObject *xspy_close(XsHandle *self) PySequence_SetItem(self->watches, i, Py_None); } =20 - xs_daemon_close(xh); + xs_close(xh); self->xh =3D NULL; =20 Py_INCREF(Py_None); @@ -985,7 +985,7 @@ xshandle_init(XsHandle *self, PyObject *args, PyObject = *kwds) &readonly)) goto fail; =20 - self->xh =3D (readonly ? xs_daemon_open_readonly() : xs_daemon_open()); + self->xh =3D xs_open(0); if (!self->xh) goto fail; =20 @@ -999,7 +999,7 @@ xshandle_init(XsHandle *self, PyObject *args, PyObject = *kwds) static void xshandle_dealloc(XsHandle *self) { if (self->xh) { - xs_daemon_close(self->xh); + xs_close(self->xh); self->xh =3D NULL; } =20 diff --git a/tools/tests/mce-test/tools/xen-mceinj.c b/tools/tests/mce-test= /tools/xen-mceinj.c index 380e42190c..1187d01e5f 100644 --- a/tools/tests/mce-test/tools/xen-mceinj.c +++ b/tools/tests/mce-test/tools/xen-mceinj.c @@ -411,13 +411,13 @@ static long xs_get_dom_mem(int domid) unsigned int plen; struct xs_handle *xs; =20 - xs =3D xs_daemon_open(); + xs =3D xs_open(0); if (!xs) return -1; =20 sprintf(path, "/local/domain/%d/memory/target", domid); memstr =3D xs_read(xs, XBT_NULL, path, &plen); - xs_daemon_close(xs); + xs_close(xs); =20 if (!memstr || !plen) return -1; diff --git a/tools/xenbackendd/xenbackendd.c b/tools/xenbackendd/xenbackend= d.c index b6d92984e0..21884af772 100644 --- a/tools/xenbackendd/xenbackendd.c +++ b/tools/xenbackendd/xenbackendd.c @@ -122,7 +122,7 @@ usage(void) static int xen_setup(void) { - xs =3D xs_daemon_open(); + xs =3D xs_open(0); if (xs =3D=3D NULL) { dolog(LOG_ERR, "Failed to contact xenstore (%s). Is it running?", @@ -138,7 +138,7 @@ xen_setup(void) =20 out: if (xs) { - xs_daemon_close(xs); + xs_close(xs); xs =3D NULL; } return -1; diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c index 1c801caa71..35fd1c931a 100644 --- a/tools/xenpmd/xenpmd.c +++ b/tools/xenpmd/xenpmd.c @@ -502,18 +502,18 @@ int main(int argc, char *argv[]) #ifndef RUN_STANDALONE daemonize(); #endif - xs =3D (struct xs_handle *)xs_daemon_open(); + xs =3D xs_open(0); if ( xs =3D=3D NULL )=20 return -1; =20 if ( write_one_time_battery_info() =3D=3D 0 )=20 { - xs_daemon_close(xs); + xs_close(xs); return -1; } =20 wait_for_and_update_battery_status_request(); - xs_daemon_close(xs); + xs_close(xs); return 0; } =20 --=20 2.26.2 From nobody Sat Nov 30 16:27:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1601653341; cv=none; d=zohomail.com; s=zohoarc; b=Oxd0Cl+68j24W1MhuaFGd2pZ0pS3naCwxZpJ4JO2Oz3AQXj5ieqgEp53TYXgNG7pemkyaJpsVfXFlFF7Oyjm+g7a8Xhgtv6ldjgdy1wdDgpW+z0NiXewGiVlaBZEBCMtfmU3aU+Ui+X0shqkL2TEGC61OcOsvFOdBHalBehW8Ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601653341; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IVXyqd8+BJ9r6/80OoSoimGVYzfPs4ujpYo9jzSMuLs=; b=WFANiwPGqyZ1OHPT9HShK8r+c8q/cklc79JO1g7RTVOOwGj3ospLT/S3DyvJqkXk23wA581XfBrek4WXQwTQOST9HX+QTGOtTICIyzopbt70LXVc8yiYlCtGYtHAXCMYVnKnZEtaPovZbb2fhIJeMyGrqRdYMdGFoGvXkC7Z7uU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601653341145122.12277505500765; Fri, 2 Oct 2020 08:42:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.2233.6616 (Exim 4.92) (envelope-from ) id 1kONBx-000708-8i; Fri, 02 Oct 2020 15:41:53 +0000 Received: by outflank-mailman (output) from mailman id 2233.6616; Fri, 02 Oct 2020 15:41:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBx-000700-43; Fri, 02 Oct 2020 15:41:53 +0000 Received: by outflank-mailman (input) for mailman id 2233; Fri, 02 Oct 2020 15:41:51 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBv-0006v4-Lm for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:51 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d6be06e3-4dd6-46e8-99d2-81f82e469325; Fri, 02 Oct 2020 15:41:47 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B62D0B26A; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kONBv-0006v4-Lm for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 15:41:51 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d6be06e3-4dd6-46e8-99d2-81f82e469325; Fri, 02 Oct 2020 15:41:47 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B62D0B26A; Fri, 2 Oct 2020 15:41:45 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d6be06e3-4dd6-46e8-99d2-81f82e469325 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601653305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IVXyqd8+BJ9r6/80OoSoimGVYzfPs4ujpYo9jzSMuLs=; b=lGKrfw3ovFXY/f0HnxIqVDT9WUvjzxqKl5mkUEO2DdqbN7vwbeFGwpigFPMLDAIq8iQHxh 2BgPOERbcaKx/yQJxlihiJIPA2K/9pohTxv68O+RxGDgtUBu8bnJ6DWOkbb59nQj8lUi1+ MMCN6fS6iw7rzh31iqkZ/2m7gjLkzAQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH 5/5] tools/xenstore: drop creation of read-only socket in xenstored Date: Fri, 2 Oct 2020 17:41:41 +0200 Message-Id: <20201002154141.11677-6-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002154141.11677-1-jgross@suse.com> References: <20201002154141.11677-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" With xs_daemon_open_readonly() now no longer using the read-only socket the creation of that socket can be dropped. Signed-off-by: Juergen Gross --- tools/xenstore/xenstored_core.c | 55 +++++++------------------------ tools/xenstore/xenstored_core.h | 3 -- tools/xenstore/xenstored_domain.c | 4 +-- tools/xenstore/xs_lib.c | 8 +---- 4 files changed, 14 insertions(+), 56 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index 9700772d40..b4be374d3f 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -71,7 +71,6 @@ static unsigned int current_array_size; static unsigned int nr_fds; =20 static int sock =3D -1; -static int ro_sock =3D -1; =20 static bool verbose =3D false; LIST_HEAD(connections); @@ -311,8 +310,7 @@ fail: return -1; } =20 -static void initialize_fds(int *p_sock_pollfd_idx, int *p_ro_sock_pollfd_i= dx, - int *ptimeout) +static void initialize_fds(int *p_sock_pollfd_idx, int *ptimeout) { struct connection *conn; struct wrl_timestampt now; @@ -325,8 +323,6 @@ static void initialize_fds(int *p_sock_pollfd_idx, int = *p_ro_sock_pollfd_idx, =20 if (sock !=3D -1) *p_sock_pollfd_idx =3D set_fd(sock, POLLIN|POLLPRI); - if (ro_sock !=3D -1) - *p_ro_sock_pollfd_idx =3D set_fd(ro_sock, POLLIN|POLLPRI); if (reopen_log_pipe[0] !=3D -1) reopen_log_pipe0_pollfd_idx =3D set_fd(reopen_log_pipe[0], POLLIN|POLLPRI); @@ -472,9 +468,6 @@ static enum xs_perm_type perm_for_conn(struct connectio= n *conn, unsigned int i; enum xs_perm_type mask =3D XS_PERM_READ|XS_PERM_WRITE|XS_PERM_OWNER; =20 - if (!conn->can_write) - mask &=3D ~XS_PERM_WRITE; - /* Owners and tools get it all... */ if (!domain_is_unprivileged(conn) || perms[0].id =3D=3D conn->id || (conn->target && perms[0].id =3D=3D conn->target->id)) @@ -1422,7 +1415,6 @@ struct connection *new_connection(connwritefn_t *writ= e, connreadfn_t *read) new->pollfd_idx =3D -1; new->write =3D write; new->read =3D read; - new->can_write =3D true; new->transaction_started =3D 0; INIT_LIST_HEAD(&new->out_list); INIT_LIST_HEAD(&new->watches); @@ -1435,7 +1427,7 @@ struct connection *new_connection(connwritefn_t *writ= e, connreadfn_t *read) } =20 #ifdef NO_SOCKETS -static void accept_connection(int sock, bool canwrite) +static void accept_connection(int sock) { } #else @@ -1477,7 +1469,7 @@ static int readfd(struct connection *conn, void *data= , unsigned int len) return rc; } =20 -static void accept_connection(int sock, bool canwrite) +static void accept_connection(int sock) { int fd; struct connection *conn; @@ -1487,10 +1479,9 @@ static void accept_connection(int sock, bool canwrit= e) return; =20 conn =3D new_connection(writefd, readfd); - if (conn) { + if (conn) conn->fd =3D fd; - conn->can_write =3D canwrite; - } else + else close(fd); } #endif @@ -1794,28 +1785,21 @@ static void destroy_fds(void) { if (sock >=3D 0) close(sock); - if (ro_sock >=3D 0) - close(ro_sock); } =20 static void init_sockets(void) { struct sockaddr_un addr; const char *soc_str =3D xs_daemon_socket(); - const char *soc_str_ro =3D xs_daemon_socket_ro(); =20 /* Create sockets for them to listen to. */ atexit(destroy_fds); sock =3D socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) barf_perror("Could not create socket"); - ro_sock =3D socket(PF_UNIX, SOCK_STREAM, 0); - if (ro_sock < 0) - barf_perror("Could not create socket"); =20 /* FIXME: Be more sophisticated, don't mug running daemon. */ unlink(soc_str); - unlink(soc_str_ro); =20 addr.sun_family =3D AF_UNIX; =20 @@ -1825,17 +1809,10 @@ static void init_sockets(void) if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) !=3D 0) barf_perror("Could not bind socket to %s", soc_str); =20 - if(strlen(soc_str_ro) >=3D sizeof(addr.sun_path)) - barf_perror("socket string '%s' too long", soc_str_ro); - strcpy(addr.sun_path, soc_str_ro); - if (bind(ro_sock, (struct sockaddr *)&addr, sizeof(addr)) !=3D 0) - barf_perror("Could not bind socket to %s", soc_str_ro); - - if (chmod(soc_str, 0600) !=3D 0 - || chmod(soc_str_ro, 0660) !=3D 0) + if (chmod(soc_str, 0600) !=3D 0) barf_perror("Could not chmod sockets"); =20 - if (listen(sock, 1) !=3D 0 || listen(ro_sock, 1) !=3D 0) + if (listen(sock, 1) !=3D 0) barf_perror("Could not listen on sockets"); } #endif @@ -1893,7 +1870,7 @@ int priv_domid =3D 0; int main(int argc, char *argv[]) { int opt; - int sock_pollfd_idx =3D -1, ro_sock_pollfd_idx =3D -1; + int sock_pollfd_idx =3D -1; bool dofork =3D true; bool outputpid =3D false; bool no_domain_init =3D false; @@ -2010,7 +1987,7 @@ int main(int argc, char *argv[]) tracefile =3D talloc_strdup(NULL, tracefile); =20 /* Get ready to listen to the tools. */ - initialize_fds(&sock_pollfd_idx, &ro_sock_pollfd_idx, &timeout); + initialize_fds(&sock_pollfd_idx, &timeout); =20 /* Tell the kernel we're up and running. */ xenbus_notify_running(); @@ -2051,21 +2028,11 @@ int main(int argc, char *argv[]) barf_perror("sock poll failed"); break; } else if (fds[sock_pollfd_idx].revents & POLLIN) { - accept_connection(sock, true); + accept_connection(sock); sock_pollfd_idx =3D -1; } } =20 - if (ro_sock_pollfd_idx !=3D -1) { - if (fds[ro_sock_pollfd_idx].revents & ~POLLIN) { - barf_perror("ro sock poll failed"); - break; - } else if (fds[ro_sock_pollfd_idx].revents & POLLIN) { - accept_connection(ro_sock, false); - ro_sock_pollfd_idx =3D -1; - } - } - if (xce_pollfd_idx !=3D -1) { if (fds[xce_pollfd_idx].revents & ~POLLIN) { barf_perror("xce_handle poll failed"); @@ -2128,7 +2095,7 @@ int main(int argc, char *argv[]) } } =20 - initialize_fds(&sock_pollfd_idx, &ro_sock_pollfd_idx, &timeout); + initialize_fds(&sock_pollfd_idx, &timeout); } } =20 diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_cor= e.h index c4c32bc88f..1df6ad94ab 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -77,9 +77,6 @@ struct connection /* Who am I? 0 for socket connections. */ unsigned int id; =20 - /* Is this a read-only connection? */ - bool can_write; - /* Buffered incoming data. */ struct buffered_data *in; =20 diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index 0d5495745b..a2f144f6dd 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -372,7 +372,7 @@ int do_introduce(struct connection *conn, struct buffer= ed_data *in) if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) return EINVAL; =20 - if (domain_is_unprivileged(conn) || !conn->can_write) + if (domain_is_unprivileged(conn)) return EACCES; =20 domid =3D atoi(vec[0]); @@ -438,7 +438,7 @@ int do_set_target(struct connection *conn, struct buffe= red_data *in) if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) return EINVAL; =20 - if (domain_is_unprivileged(conn) || !conn->can_write) + if (domain_is_unprivileged(conn)) return EACCES; =20 domid =3D atoi(vec[0]); diff --git a/tools/xenstore/xs_lib.c b/tools/xenstore/xs_lib.c index 3e43f8809d..9f1dc6d559 100644 --- a/tools/xenstore/xs_lib.c +++ b/tools/xenstore/xs_lib.c @@ -63,13 +63,7 @@ const char *xs_daemon_socket(void) =20 const char *xs_daemon_socket_ro(void) { - static char buf[PATH_MAX]; - const char *s =3D xs_daemon_path(); - if (s =3D=3D NULL) - return NULL; - if (snprintf(buf, sizeof(buf), "%s_ro", s) >=3D PATH_MAX) - return NULL; - return buf; + return xs_daemon_path(); } =20 const char *xs_domain_dev(void) --=20 2.26.2