Skip to contentSkip to conversation

gssd: daemonize earlier

PATCH In review Scott Mayhew 2 participants 3 messages Oct 17, 2019 – Oct 24, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 gssd: daemonize earlier

daemon_init() calls closeall() which closes all fd's >= 4. This causes rpc.gssd to fail when it's configured to use the gssproxy interposer plugin (via "use-gss-proxy=1" in nfs.conf or GSS_USE_PROXY="yes" in the environment) *and* libtirpc debugging is enabled (i.e. at least one "-r" on the command line):

1. During startup if rpc debugging is enabled then libtirpc_set_debug() is called, which calls openlog() which consumes fd 3.
2. If the gssproxy interposer plugin is enabled then when gssd_check_mechs() is called, a socket is created (fd 4) and connected to /var/lib/gssproxy/default.sock. The fd is stored internally in a struct gpm_ctx.
3. daemon_init() runs and closes all fd's >= 4.
4. event_init() runs which calls epoll_create() which returns an epoll fd of 4.
5. Later when handling an upcall, gssd calls gssd_acquire_krb5_cred() which winds up closing the gpm_ctx->fd which was 4.
6. event_dispatch() calls epoll_wait() with epfd=4, and -EBADF is returned. gssd logs the message ""ERROR: event_dispatch() returned!" and exits.

The solution is to call daemon_init() earlier.

---
 utils/gssd/gssd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/gssd/gssd.c +2 -2
index 19ad4da..c38dedb 100644
@@ -1020,11 +1020,11 @@ main(int argc, char *argv[])
 			    "support setting debug levels\n");
 #endif
 
+	daemon_init(fg);
+
 	if (gssd_check_mechs() != 0)
 		errx(1, "Problem with gssapi library");
 
-	daemon_init(fg);
-
 	event_init();
 
 	pipefs_dir = opendir(pipefs_path);
Signature · 1 line
2.17.2
#1 lore raw

Note this is v1 patch. I forgot to check my git config before creating the patch :)

-Scott

Quoted 49 lines · Scott Mayhew

daemon_init() calls closeall() which closes all fd's >= 4. This causes rpc.gssd to fail when it's configured to use the gssproxy interposer plugin (via "use-gss-proxy=1" in nfs.conf or GSS_USE_PROXY="yes" in the environment) *and* libtirpc debugging is enabled (i.e. at least one "-r" on the command line):

1. During startup if rpc debugging is enabled then libtirpc_set_debug() is called, which calls openlog() which consumes fd 3.
2. If the gssproxy interposer plugin is enabled then when gssd_check_mechs() is called, a socket is created (fd 4) and connected to /var/lib/gssproxy/default.sock. The fd is stored internally in a struct gpm_ctx.
3. daemon_init() runs and closes all fd's >= 4.
4. event_init() runs which calls epoll_create() which returns an epoll fd of 4.
5. Later when handling an upcall, gssd calls gssd_acquire_krb5_cred() which winds up closing the gpm_ctx->fd which was 4.
6. event_dispatch() calls epoll_wait() with epfd=4, and -EBADF is returned. gssd logs the message ""ERROR: event_dispatch() returned!" and exits.

The solution is to call daemon_init() earlier.

---
 utils/gssd/gssd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/gssd/gssd.c +2 -2
index 19ad4da..c38dedb 100644
@@ -1020,11 +1020,11 @@ main(int argc, char *argv[])
 			    "support setting debug levels\n");
 #endif
 
+	daemon_init(fg);
+
 	if (gssd_check_mechs() != 0)
 		errx(1, "Problem with gssapi library");
 
-	daemon_init(fg);
-
 	event_init();
 
 	pipefs_dir = opendir(pipefs_path);
Signature · 1 line
2.17.2
#2 lore raw
In reply to Scott Mayhew
Quoted 21 lines · Scott Mayhew

daemon_init() calls closeall() which closes all fd's >= 4. This causes rpc.gssd to fail when it's configured to use the gssproxy interposer plugin (via "use-gss-proxy=1" in nfs.conf or GSS_USE_PROXY="yes" in the environment) *and* libtirpc debugging is enabled (i.e. at least one "-r" on the command line):

1. During startup if rpc debugging is enabled then libtirpc_set_debug() is called, which calls openlog() which consumes fd 3.
2. If the gssproxy interposer plugin is enabled then when gssd_check_mechs() is called, a socket is created (fd 4) and connected to /var/lib/gssproxy/default.sock. The fd is stored internally in a struct gpm_ctx.
3. daemon_init() runs and closes all fd's >= 4.
4. event_init() runs which calls epoll_create() which returns an epoll fd of 4.
5. Later when handling an upcall, gssd calls gssd_acquire_krb5_cred() which winds up closing the gpm_ctx->fd which was 4.
6. event_dispatch() calls epoll_wait() with epfd=4, and -EBADF is returned. gssd logs the message ""ERROR: event_dispatch() returned!" and exits.

Quoted 3 lines

The solution is to call daemon_init() earlier.

Committed...

steved.

Quoted 23 lines
---
 utils/gssd/gssd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/gssd/gssd.c +2 -2
index 19ad4da..c38dedb 100644
@@ -1020,11 +1020,11 @@ main(int argc, char *argv[])
 			    "support setting debug levels\n");
 #endif
 
+	daemon_init(fg);
+
 	if (gssd_check_mechs() != 0)
 		errx(1, "Problem with gssapi library");
 
-	daemon_init(fg);
-
 	event_init();
 
 	pipefs_dir = opendir(pipefs_path);