Marinus
Marinus

Reputation: 2210

pam_script doesn't send stdout to the user during execution only when script completes

pam_script doesn't send output to the user when executing a script, only when the script completes. The example below simulates instructions to users and some api calls to complete the process. There is no user interaction. The output is only sent to the user when the script completes.

auth required pam_exec.so stdout /lib/x86_64-linux-gnu/security/test.py

#!/usr/bin/env python3
import sys
import time

# simulate sending instructions (10 lines) to the user, which needs to be displayed
for i in range(10):
    print('some important information')
    sys.stdout.flush()

# simulate doing some api calls to conclude the authentication process
for i in range(5):
    print('making api calls')
    sys.stdout.flush()
    time.sleep(1)

# success 
sys.exit(0)

Upvotes: 0

Views: 32

Answers (0)

Related Questions