Skip to content

Commit 7a21458

Browse files
committed
shell: fetch enclosing instance security.owner attribute
Problem: The job shell doesn't capture the owner of the enclosing instance, so there is no way to determine if the job is running in single vs multiuser mode. Capture the local broker security.owner attribute.
1 parent cc54bb9 commit 7a21458

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/shell/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
struct flux_shell {
2727
flux_jobid_t jobid;
2828
int broker_rank;
29+
uid_t broker_owner;
2930
char hostname [MAXHOSTNAMELEN + 1];
3031
int protocol_fd[2];
3132

src/shell/shell.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,25 @@ static int reconnect (flux_t *h, void *arg)
253253
return 0;
254254
}
255255

256+
static uid_t get_instance_owner (flux_t *h)
257+
{
258+
const char *s;
259+
char *endptr;
260+
int id;
261+
262+
if (!(s = flux_attr_get (h, "security.owner"))) {
263+
shell_log_errno ("error fetching security.owner attribute");
264+
return (uid_t) 0;
265+
}
266+
errno = 0;
267+
id = strtoul (s, &endptr, 10);
268+
if (errno != 0 || *endptr != '\0') {
269+
shell_log_error ("error parsing security.owner=%s", s);
270+
return (uid_t) 0;
271+
}
272+
return (uid_t) id;
273+
}
274+
256275
static void shell_connect_flux (flux_shell_t *shell)
257276
{
258277
uint32_t rank;
@@ -274,6 +293,8 @@ static void shell_connect_flux (flux_shell_t *shell)
274293
shell_log_errno ("error fetching broker rank");
275294
shell->broker_rank = rank;
276295

296+
shell->broker_owner = get_instance_owner (shell->h);
297+
277298
if (plugstack_call (shell->plugstack, "shell.connect", NULL) < 0)
278299
shell_log_errno ("shell.connect");
279300
}

0 commit comments

Comments
 (0)