Skip to content

Commit

Permalink
Merge pull request #210 from mldailey/master
Browse files Browse the repository at this point in the history
Fix non-interactive sessions when using groups option (Issue #206)
  • Loading branch information
mbish authored Nov 16, 2021
2 parents b1bd02f + 034fe52 commit cc6bccf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions login_duo/login_duo.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ do_auth(struct login_ctx *ctx, const char *cmd)
#endif

prompts = cfg.prompts;

/* Detect non-interactive sessions */
if ((p = getenv("SSH_ORIGINAL_COMMAND")) != NULL ||
!isatty(STDIN_FILENO)) {
headless = 1;
}

/* Check group membership. */
matched = duo_check_groups(pw, cfg.groups, cfg.groups_cnt);
if (matched == -1) {
Expand Down Expand Up @@ -253,13 +260,11 @@ do_auth(struct login_ctx *ctx, const char *cmd)
}

/* Special handling for non-interactive sessions */
if ((p = getenv("SSH_ORIGINAL_COMMAND")) != NULL ||
!isatty(STDIN_FILENO)) {
if (headless) {
/* Try to support automatic one-shot login */
duo_set_conv_funcs(duo, NULL, NULL, NULL);
flags = (DUO_FLAG_SYNC|DUO_FLAG_AUTO);
prompts = 1;
headless = 1;
} else if (cfg.autopush) { /* Special handling for autopush */
duo_set_conv_funcs(duo, NULL, __autopush_status_fn, NULL);
flags = (DUO_FLAG_SYNC|DUO_FLAG_AUTO);
Expand Down

0 comments on commit cc6bccf

Please sign in to comment.