summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2023-05-11 14:26:47 -0400
committerSteve Dickson <steved@redhat.com>2023-05-11 15:04:09 -0400
commite00ab3c0616fe6d83ab0710d9e7d989c299088f7 (patch)
tree1a16e1b8bd6465733e8484461b7431d15aa078e6
parent4f1520f18068519a4cc488b1cea823a4f5ad2de6 (diff)
downloadnfs-utils-e00ab3c0616fe6d83ab0710d9e7d989c299088f7.tar.gz
fsidd: provide better default socket name.
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. Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--support/reexport/fsidd.c10
-rw-r--r--support/reexport/reexport.c3
-rw-r--r--support/reexport/reexport.h2
3 files changed, 10 insertions, 5 deletions
diff --git a/support/reexport/fsidd.c b/support/reexport/fsidd.c
index 3fef1ef..37649d0 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 eddc9bf..d597a2f 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 3bed03a..856c308 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 */