From patchwork Fri Oct 2 15:41:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11813863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E75BC92C for ; Fri, 2 Oct 2020 15:42:40 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B44E92074B for ; Fri, 2 Oct 2020 15:42:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="ht1KggQY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B44E92074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2234.6625; Fri, 02 Oct 2020 15:41:53 +0000 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" 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 X-Inumbo-ID: 763a8954-9454-401c-b98d-f5c3d1e992f8 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) 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= 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) 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 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). Apply the permissions to the key and all its I. -=item B<-s> - -Connect to the Xenstore daemon using a local socket only. - =item B<-u> 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 listed in subsequent entries. The key owner always has full access (read, write, and set permissions). -=item B<-s> - -Connect to the Xenstore daemon using a local socket only. - =back =head1 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. Prefix value with key name. -=item B<-s> - -Connect to the Xenstore daemon using a local socket only. - =item B<-R> 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 transaction. =over -=item B<-s> - -Connect to the Xenstore daemon using a local socket only. - =item B<-R> Write raw value, skip parsing escaped characters (\x..). diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.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 = XBT_NULL; - int ret = 0, socket = 0; + int ret = 0; int prefix = 0; int tidy = 0; int upto = 0; @@ -565,7 +565,6 @@ main(int argc, char **argv) static struct option long_options[] = { {"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 = 1; - break; case 'p': if ( mode == MODE_read || mode == MODE_list || mode == MODE_ls ) prefix = 1; @@ -675,7 +671,7 @@ main(int argc, char **argv) max_width = ws.ws_col - 2; } - xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0); + xsh = xs_open(0); if (xsh == NULL) err(1, "xs_open"); again: From patchwork Fri Oct 2 15:41:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11813867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB40C112E for ; Fri, 2 Oct 2020 15:42:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D0FF2074B for ; Fri, 2 Oct 2020 15:42:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="cXGOQcxR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D0FF2074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2235.6640; Fri, 02 Oct 2020 15:41:59 +0000 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" 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 X-Inumbo-ID: d4c67228-f86e-46c4-a739-4b1b0520460d 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) 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= 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) 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 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 = get_handle(xs_daemon_socket()); - if (!xsh && !(flags & XS_OPEN_SOCKETONLY)) + if (!xsh) xsh = get_handle(xs_domain_dev()); if (xsh && (flags & XS_UNWATCH_FILTER)) From patchwork Fri Oct 2 15:41:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11813873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1040E112E for ; Fri, 2 Oct 2020 15:43:10 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D02BF2074B for ; Fri, 2 Oct 2020 15:43:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="s3zAfuAk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D02BF2074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2236.6652; Fri, 02 Oct 2020 15:42:03 +0000 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" 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 X-Inumbo-ID: f0fb1f41-52ea-41f8-ad4f-6c9b0555a9f3 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) 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= 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) 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 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); /* 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) struct xs_handle *xs_daemon_open_readonly(void) { - return xs_open(XS_OPEN_READONLY); + return xs_open(0); } struct xs_handle *xs_domain_open(void) @@ -314,10 +314,7 @@ struct xs_handle *xs_open(unsigned long flags) { struct xs_handle *xsh = NULL; - if (flags & XS_OPEN_READONLY) - xsh = get_handle(xs_daemon_socket_ro()); - else - xsh = get_handle(xs_daemon_socket()); + xsh = get_handle(xs_daemon_socket()); if (!xsh) xsh = get_handle(xs_domain_dev()); From patchwork Fri Oct 2 15:41:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11813861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C531C92C for ; Fri, 2 Oct 2020 15:42:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 977D32074B for ; Fri, 2 Oct 2020 15:42:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="OmTqquRr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 977D32074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2232.6604; Fri, 02 Oct 2020 15:41:50 +0000 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" 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 X-Inumbo-ID: e1913937-ddf9-40d7-ae63-0f09078a303c 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) 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= 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) From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu , =?utf-8?q?Marek_Marczykowski-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 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); } - xs = xs_daemon_open(); + xs = xs_open(0); if (xs == 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) { - xs = xs_daemon_open(); + xs = xs_open(0); if (xs == NULL) { dolog(LOG_ERR, "Failed to contact xenstore (%m). Is it running?"); @@ -131,7 +131,7 @@ bool xen_setup(void) 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 = ERROR_FAIL; goto out; } - ctx->xsh = xs_daemon_open(); - if (!ctx->xsh) - ctx->xsh = xs_domain_open(); + ctx->xsh = xs_open(0); if (!ctx->xsh) { LOGEV(ERROR, errno, "cannot connect to xenstore"); rc = ERROR_FAIL; goto out; @@ -171,7 +169,7 @@ int libxl_ctx_free(libxl_ctx *ctx) 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); 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 = NULL; - xsh = xs_daemon_open(); + xsh = xs_open(0); if (xsh == NULL) { LOG(ERROR, "Unable to open xenstore connection"); goto err; @@ -206,7 +206,7 @@ int libxl__xenstore_child_wait_deprecated(libxl__gc *gc, 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); 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, const char *what) { int rc; assert(!CTX->xsh); - CTX->xsh = xs_daemon_open(); + CTX->xsh = xs_open(0); if (!CTX->xsh) { LOGE(ERROR, "%s: xenstore reopen failed", what); rc = 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; } - handle->xshandle = xs_daemon_open_readonly(); /* open handle to xenstore*/ + handle->xshandle = xs_open(0); /* open handle to xenstore*/ if (handle->xshandle == NULL) { perror("unable to open xenstore"); xc_interface_close(handle->xc_handle); @@ -125,7 +125,7 @@ void xenstat_uninit(xenstat_handle * handle) for (i = 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 domain, const char* xs_base char ref[16]; char* domid_str = NULL; xs_transaction_t xs_trans = XBT_NULL; - xs = xs_domain_open(); + xs = xs_open(0); if (!xs) goto fail; domid_str = 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 xentoollog_logger *logger, ctrl->write.order = ctrl->read.order = 0; ctrl->is_server = 0; - xs = xs_daemon_open(); - if (!xs) - xs = xs_domain_open(); + xs = xs_open(0); if (!xs) goto fail; @@ -452,7 +450,7 @@ struct libxenvchan *libxenvchan_client_init(struct xentoollog_logger *logger, 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); } /* Never shrink dom0 below 1 GiB */ @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) return 2; } - xs_handle = xs_daemon_open(); + xs_handle = xs_open(0); if (xs_handle == 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); } - xs_daemon_close(xh); + xs_close(xh); self->xh = NULL; Py_INCREF(Py_None); @@ -985,7 +985,7 @@ xshandle_init(XsHandle *self, PyObject *args, PyObject *kwds) &readonly)) goto fail; - self->xh = (readonly ? xs_daemon_open_readonly() : xs_daemon_open()); + self->xh = xs_open(0); if (!self->xh) goto fail; @@ -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 = NULL; } 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; - xs = xs_daemon_open(); + xs = xs_open(0); if (!xs) return -1; sprintf(path, "/local/domain/%d/memory/target", domid); memstr = xs_read(xs, XBT_NULL, path, &plen); - xs_daemon_close(xs); + xs_close(xs); if (!memstr || !plen) return -1; diff --git a/tools/xenbackendd/xenbackendd.c b/tools/xenbackendd/xenbackendd.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 = xs_daemon_open(); + xs = xs_open(0); if (xs == NULL) { dolog(LOG_ERR, "Failed to contact xenstore (%s). Is it running?", @@ -138,7 +138,7 @@ xen_setup(void) out: if (xs) { - xs_daemon_close(xs); + xs_close(xs); xs = 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 = (struct xs_handle *)xs_daemon_open(); + xs = xs_open(0); if ( xs == NULL ) return -1; if ( write_one_time_battery_info() == 0 ) { - xs_daemon_close(xs); + xs_close(xs); return -1; } wait_for_and_update_battery_status_request(); - xs_daemon_close(xs); + xs_close(xs); return 0; } From patchwork Fri Oct 2 15:41:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11813865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15B5C112E for ; Fri, 2 Oct 2020 15:42:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF9DE20795 for ; Fri, 2 Oct 2020 15:42:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="lGKrfw3o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF9DE20795 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2233.6616; Fri, 02 Oct 2020 15:41:53 +0000 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" 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 X-Inumbo-ID: d6be06e3-4dd6-46e8-99d2-81f82e469325 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) 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= 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) 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 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_core.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; static int sock = -1; -static int ro_sock = -1; static bool verbose = false; LIST_HEAD(connections); @@ -311,8 +310,7 @@ fail: return -1; } -static void initialize_fds(int *p_sock_pollfd_idx, int *p_ro_sock_pollfd_idx, - 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, if (sock != -1) *p_sock_pollfd_idx = set_fd(sock, POLLIN|POLLPRI); - if (ro_sock != -1) - *p_ro_sock_pollfd_idx = set_fd(ro_sock, POLLIN|POLLPRI); if (reopen_log_pipe[0] != -1) reopen_log_pipe0_pollfd_idx = set_fd(reopen_log_pipe[0], POLLIN|POLLPRI); @@ -472,9 +468,6 @@ static enum xs_perm_type perm_for_conn(struct connection *conn, unsigned int i; enum xs_perm_type mask = XS_PERM_READ|XS_PERM_WRITE|XS_PERM_OWNER; - if (!conn->can_write) - mask &= ~XS_PERM_WRITE; - /* Owners and tools get it all... */ if (!domain_is_unprivileged(conn) || perms[0].id == conn->id || (conn->target && perms[0].id == conn->target->id)) @@ -1422,7 +1415,6 @@ struct connection *new_connection(connwritefn_t *write, connreadfn_t *read) new->pollfd_idx = -1; new->write = write; new->read = read; - new->can_write = true; new->transaction_started = 0; INIT_LIST_HEAD(&new->out_list); INIT_LIST_HEAD(&new->watches); @@ -1435,7 +1427,7 @@ struct connection *new_connection(connwritefn_t *write, connreadfn_t *read) } #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; } -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 canwrite) return; conn = new_connection(writefd, readfd); - if (conn) { + if (conn) conn->fd = fd; - conn->can_write = canwrite; - } else + else close(fd); } #endif @@ -1794,28 +1785,21 @@ static void destroy_fds(void) { if (sock >= 0) close(sock); - if (ro_sock >= 0) - close(ro_sock); } static void init_sockets(void) { struct sockaddr_un addr; const char *soc_str = xs_daemon_socket(); - const char *soc_str_ro = xs_daemon_socket_ro(); /* Create sockets for them to listen to. */ atexit(destroy_fds); sock = socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) barf_perror("Could not create socket"); - ro_sock = socket(PF_UNIX, SOCK_STREAM, 0); - if (ro_sock < 0) - barf_perror("Could not create socket"); /* FIXME: Be more sophisticated, don't mug running daemon. */ unlink(soc_str); - unlink(soc_str_ro); addr.sun_family = AF_UNIX; @@ -1825,17 +1809,10 @@ static void init_sockets(void) if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) barf_perror("Could not bind socket to %s", soc_str); - if(strlen(soc_str_ro) >= 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)) != 0) - barf_perror("Could not bind socket to %s", soc_str_ro); - - if (chmod(soc_str, 0600) != 0 - || chmod(soc_str_ro, 0660) != 0) + if (chmod(soc_str, 0600) != 0) barf_perror("Could not chmod sockets"); - if (listen(sock, 1) != 0 || listen(ro_sock, 1) != 0) + if (listen(sock, 1) != 0) barf_perror("Could not listen on sockets"); } #endif @@ -1893,7 +1870,7 @@ int priv_domid = 0; int main(int argc, char *argv[]) { int opt; - int sock_pollfd_idx = -1, ro_sock_pollfd_idx = -1; + int sock_pollfd_idx = -1; bool dofork = true; bool outputpid = false; bool no_domain_init = false; @@ -2010,7 +1987,7 @@ int main(int argc, char *argv[]) tracefile = talloc_strdup(NULL, tracefile); /* Get ready to listen to the tools. */ - initialize_fds(&sock_pollfd_idx, &ro_sock_pollfd_idx, &timeout); + initialize_fds(&sock_pollfd_idx, &timeout); /* 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 = -1; } } - if (ro_sock_pollfd_idx != -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 = -1; - } - } - if (xce_pollfd_idx != -1) { if (fds[xce_pollfd_idx].revents & ~POLLIN) { barf_perror("xce_handle poll failed"); @@ -2128,7 +2095,7 @@ int main(int argc, char *argv[]) } } - initialize_fds(&sock_pollfd_idx, &ro_sock_pollfd_idx, &timeout); + initialize_fds(&sock_pollfd_idx, &timeout); } } diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.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; - /* Is this a read-only connection? */ - bool can_write; - /* Buffered incoming data. */ struct buffered_data *in; diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.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 buffered_data *in) if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) return EINVAL; - if (domain_is_unprivileged(conn) || !conn->can_write) + if (domain_is_unprivileged(conn)) return EACCES; domid = atoi(vec[0]); @@ -438,7 +438,7 @@ int do_set_target(struct connection *conn, struct buffered_data *in) if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) return EINVAL; - if (domain_is_unprivileged(conn) || !conn->can_write) + if (domain_is_unprivileged(conn)) return EACCES; domid = 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) const char *xs_daemon_socket_ro(void) { - static char buf[PATH_MAX]; - const char *s = xs_daemon_path(); - if (s == NULL) - return NULL; - if (snprintf(buf, sizeof(buf), "%s_ro", s) >= PATH_MAX) - return NULL; - return buf; + return xs_daemon_path(); } const char *xs_domain_dev(void)