From 87dd3698f8876feb710250e1f78fc939df5bdc21 Mon Sep 17 00:00:00 2001 From: Nichamon Naksinehaboon Date: Wed, 30 Aug 2023 10:51:53 -0500 Subject: [PATCH] Fix the set_sec_mod handler Without the patch, the handler does not send the error code back to the interface when the given UID or GID is invalid. --- ldms/src/ldmsd/ldmsd_request.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ldms/src/ldmsd/ldmsd_request.c b/ldms/src/ldmsd/ldmsd_request.c index 6f2cad706..c9073002e 100644 --- a/ldms/src/ldmsd/ldmsd_request.c +++ b/ldms/src/ldmsd/ldmsd_request.c @@ -5539,6 +5539,7 @@ static int set_sec_mod_handler(ldmsd_req_ctxt_t reqc) if (isdigit(value[0])) { uid = strtol(value, &endptr, 0); if (uid < 0) { + reqc->errcode = EINVAL; (void) snprintf(reqc->line_buf, reqc->line_len, "The given UID '%s' is invalid.", value); @@ -5547,6 +5548,7 @@ static int set_sec_mod_handler(ldmsd_req_ctxt_t reqc) } else { struct passwd *pwd = getpwnam(value); if (!pwd) { + reqc->errcode = EINVAL; (void)snprintf(reqc->line_buf, reqc->line_len, "Unknown user '%s'", value); goto free_regex; @@ -5561,6 +5563,7 @@ static int set_sec_mod_handler(ldmsd_req_ctxt_t reqc) if (isdigit(value[0])) { gid = strtol(value, &endptr, 0); if (gid < 0) { + reqc->errcode = EINVAL; (void) snprintf(reqc->line_buf, reqc->line_len, "The given GID '%s' is invalid.", value); @@ -5569,8 +5572,10 @@ static int set_sec_mod_handler(ldmsd_req_ctxt_t reqc) } else { struct group *grp = getgrnam(value); if (!grp) { + reqc->errcode = EINVAL; (void) snprintf(reqc->line_buf, reqc->line_len, "Unknown group '%s'", value); + goto free_regex; } gid = grp->gr_gid; }