Skip to content

Commit

Permalink
imp: fix segfault on missing user
Browse files Browse the repository at this point in the history
Problem: if a compute node cannot resolve the target userid,
the imp segfaults due to an unchecked error condition:

  #0  0x000000556a7a7680 imp_exec_privileged (flux-imp + 0x7680)
  flux-framework/flux-core#1  0x000000556a7a3b3c imp_parent (flux-imp + 0x3b3c)
  flux-framework/flux-core#2  0x0000007fac65fe18 __libc_start_main (libc.so.6 + 0x20e18)
  flux-framework/flux-core#3  0x000000556a7a3c18 $x (flux-imp + 0x3c18)
  flux-framework/flux-core#4  0x000000556a7a3c18 $x (flux-imp + 0x3c18)

Check for userid lookup failure and print a helpful message, then die.

Fixes flux-framework#170
  • Loading branch information
garlick committed Aug 10, 2023
1 parent 7fa2550 commit 3808998
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/imp/exec/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ int imp_exec_privileged (struct imp_state *imp, struct kv *kv)
if (imp_supports_pam (exec)) {
#if HAVE_PAM
struct passwd *user_pwd = passwd_from_uid (exec->userid);
if (!user_pwd) {
char hostname[1024] = "unknown";
(void)gethostname (hostname, sizeof (hostname));
imp_die (1,
"exec: userid %d is invalid on %s",
(int)exec->userid,
hostname);
}
if (pam_setup (user_pwd->pw_name) < 0)
imp_die (1, "exec: PAM stack failure");
#else
Expand Down

0 comments on commit 3808998

Please sign in to comment.