Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify conditions and add explanation #2

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pam-tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ def pam_auth(user, password, stack, expectfail):
failed = False

click.echo(f'authenticating user { user } in PAM stack {stack}, status: PAM code {p.code}, PAM reason {p.reason}')
if (not expectfail and not failed) or (expectfail and failed):
sys.exit(0)
sys.exit(1)
# we expect no error (false) and it errors (true) -> not false and true -> true
# we expect no error (false) and it does not error (false) -> not false and false -> false
# we expect an error (true) and it errors (true) -> not true and true -> false
# we expect an error (true) and it does not error (false) -> not true and false -> false
if (not expectfail and failed) or (expectfail and not failed):
sys.exit(1)
sys.exit(0)


if __name__ == '__main__':
Expand Down