Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3920041rwr; Sun, 7 May 2023 23:22:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Abrobr1gN2ZfCxDRx59Db78KOjBgBQ2YXO7Oq8vqKm/mFRmOOM4Iuk96jDWGwEqGfkKMg X-Received: by 2002:a17:902:7d89:b0:1aa:dba7:4bce with SMTP id a9-20020a1709027d8900b001aadba74bcemr8884640plm.49.1683526922353; Sun, 07 May 2023 23:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683526922; cv=none; d=google.com; s=arc-20160816; b=nKXfIXpKTIU46RbugbEgjhcxI7eBdzrsZ+p+wOZmnPfXKV5oodaFRhqL4T/Wnghzld 0P1ohMueYzgYk2SuwYvSOJAHobjkySaJrNix9k7AvfCg2hLoiS2Boq2g39zkYQOY4uO+ UrcSyOqbAAG0R5Kw8EnZ96F1ND/VgEfxNHqfICfcgWDVPt0g9NrzgRAPtqS0Al3jQWnc IX74XNZoB5rQoR4oq2KVOPH9gLHCt9tGyfQ2x+1eS0q3nPJEMoM0L3dzeO1WGaQCB/U6 wv+1Rfer29abacM3hUnmrOmxpoBc5pcvAOnxrxqKJSan8BOW6o+/RvWD7vKvjalpj3d1 mZCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=1bwegpWKqZGmA9wD3M8D0Kqjkw11Xvs3rGP/ihfzxMQ=; b=ujmqFP8qjc5V245blIIcH/NBnD4B1dflLQ68LvBzf8sLEWeOWU+StkIfddPYyumF8z /mKFeJ8slFZdZdGUy5EINKSrCM4C/g/gtKlWazRnTx3vjKNL0tQpOq1o9WbIo7kIIcks 6BHo/+gQqkfD5j3tjtu2WqbhNhBQG/aUNO490hTkRlTjCn/hOiPCvTT1kMIL72sSmg/v T8DPA7rrd0YGctLL3Hr61g8xRldKHXjqbUK0eNdYjLTu6XcTg0ebrgpRzTz0rVja8195 hZ4OpXYdgVhtb9Lor+eEitNPGpNu39PlIrq4NFZj3UUwVqfpV00fE2MmB8bjsFWwv8kv WRsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jFwMAzNQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=YXnpo4Cc; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jj22-20020a170903049600b001a6d08dc834si1093601plb.22.2023.05.07.23.21.47; Sun, 07 May 2023 23:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jFwMAzNQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=YXnpo4Cc; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232546AbjEHGUb (ORCPT + 99 others); Mon, 8 May 2023 02:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232637AbjEHGUa (ORCPT ); Mon, 8 May 2023 02:20:30 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E63EB30FB for ; Sun, 7 May 2023 23:20:28 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 887331FD9F; Mon, 8 May 2023 06:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683526827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1bwegpWKqZGmA9wD3M8D0Kqjkw11Xvs3rGP/ihfzxMQ=; b=jFwMAzNQqOhc6dCgqqU/vCLXtLKn0J08onGUHzA1IMfsEYPytm57KAyj555Jnd1mQes8Ev 4jaf/LRkSPv4+miHMfra+D8k8P5COewJpnLApCvFXxdPrHrmfLWjyujlIpVZr27PPqPXk9 C3DoVrKWuZMyq616KbzXbtsQlaEcyxI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683526827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1bwegpWKqZGmA9wD3M8D0Kqjkw11Xvs3rGP/ihfzxMQ=; b=YXnpo4CcRz4cMPkBVnvPzavx+/tQcOioxoTIsdDE9zDJ8YDqxxYLWpSkKbMWc6nBvixS0q DqgSLCprXMPDh5AA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4EF6E13499; Mon, 8 May 2023 06:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HI5wAaqUWGRmGAAAMHmgww (envelope-from ); Mon, 08 May 2023 06:20:26 +0000 Subject: [PATCH 2/2] fsidd: provide better default socket name. From: NeilBrown To: Steve Dickson , Richard Weinberger Cc: linux-nfs@vger.kernel.org Date: Mon, 08 May 2023 16:19:11 +1000 Message-ID: <168352675194.17279.12797722278244839616.stgit@noble.brown> In-Reply-To: <168352657591.17279.393573102599959056.stgit@noble.brown> References: <168352657591.17279.393573102599959056.stgit@noble.brown> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Having the default socket name be in the current directory is a poor choice for a daemon that is expected to run as root. It is also likely better to use an "abstract" socket name. abstract names do not exist in the filesystem namespace and are local to a network namespace. Using an abstract name ensures that the nfsd, mountd, and fsidd are all in the same network namespace. This patch: - uses a single #define for the default socket name, rather than 2; - allows the socket name to start with '@' which is interpreted to be a request to use the abstract name space (systemd uses the same convention). - changes the default to "@/run/fsid.sock". I don't know of a formal standard for choosing names in the abstract name space, the defacto standard (seen in "ss -xa|grep @") is to use a name similar to what might be used in the filesystem. Signed-off-by: NeilBrown --- support/reexport/fsidd.c | 10 ++++++---- support/reexport/reexport.c | 3 +++ support/reexport/reexport.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/support/reexport/fsidd.c b/support/reexport/fsidd.c index 3fef1ef3512b..37649d065ce6 100644 --- a/support/reexport/fsidd.c +++ b/support/reexport/fsidd.c @@ -18,11 +18,10 @@ #include "conffile.h" #include "reexport_backend.h" +#include "reexport.h" #include "xcommon.h" #include "xlog.h" -#define FSID_SOCKET_NAME "fsid.sock" - static struct event_base *evbase; static struct reexpdb_backend_plugin *dbbackend = &sqlite_plug_ops; @@ -167,11 +166,14 @@ int main(void) sock_file = conf_get_str_with_def("reexport", "fsidd_socket", FSID_SOCKET_NAME); - unlink(sock_file); - memset(&addr, 0, sizeof(struct sockaddr_un)); addr.sun_family = AF_UNIX; strncpy(addr.sun_path, sock_file, sizeof(addr.sun_path) - 1); + if (addr.sun_path[0] == '@') + /* "abstract" socket namespace */ + addr.sun_path[0] = 0; + else + unlink(sock_file); srv = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_NONBLOCK, 0); if (srv == -1) { diff --git a/support/reexport/reexport.c b/support/reexport/reexport.c index eddc9bf413f6..d597a2f73c93 100644 --- a/support/reexport/reexport.c +++ b/support/reexport/reexport.c @@ -38,6 +38,9 @@ static bool connect_fsid_service(void) memset(&addr, 0, sizeof(struct sockaddr_un)); addr.sun_family = AF_UNIX; strncpy(addr.sun_path, sock_file, sizeof(addr.sun_path) - 1); + if (addr.sun_path[0] == '@') + /* "abstract" socket namespace */ + addr.sun_path[0] = 0; s = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (s == -1) { diff --git a/support/reexport/reexport.h b/support/reexport/reexport.h index 3bed03a9a0bb..856c3085a1dd 100644 --- a/support/reexport/reexport.h +++ b/support/reexport/reexport.h @@ -13,6 +13,6 @@ int reexpdb_fsidnum_by_path(char *path, uint32_t *fsidnum, int may_create); int reexpdb_apply_reexport_settings(struct exportent *ep, char *flname, int flline); void reexpdb_uncover_subvolume(uint32_t fsidnum); -#define FSID_SOCKET_NAME "fsid.sock" +#define FSID_SOCKET_NAME "@/run/fsid.sock" #endif /* REEXPORT_H */