Skip to content

Commit

Permalink
Better server error output
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvanes committed Jul 1, 2022
1 parent 6d1a33b commit d8e7c52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
24 changes: 5 additions & 19 deletions src/pam_weblogin.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@

#include "pam_weblogin.h"

/* see https://stackoverflow.com/questions/2410976/how-to-define-a-string-literal-in-gcc-command-line
* and note that # is the CPP "stringizing" operator */
#define STR(x) #x
#define TOSTR(X) STR(x)

#ifndef GIT_COMMIT
#DEFINE GIT_COMMIT 0000
#endif

#ifndef JSONPARSER_GIT_COMMIT
#DEFINE JSONPARSER_GIT_COMMIT 0000
#endif


PAM_EXTERN int pam_sm_setcred(UNUSED pam_handle_t *pamh, UNUSED int flags, UNUSED int argc, UNUSED const char *argv[])
{
return PAM_SUCCESS;
Expand Down Expand Up @@ -99,8 +85,8 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
free(data);

if (challenge_response == NULL) {
log_message(LOG_ERR, "Error making request");
tty_output(pamh, "Could not contact auth server");
log_message(LOG_ERR, SERVER_ERROR);
tty_output(pamh, SERVER_ERROR);
pam_result = PAM_SYSTEM_ERR;
goto finalize;
}
Expand Down Expand Up @@ -129,7 +115,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
/* Now we need to have a session_id and a challenge ! */
if (!session_id || !challenge)
{
tty_output(pamh, "Server error!");
tty_output(pamh, SERVER_ERROR);
goto finalize;
}

Expand Down Expand Up @@ -165,8 +151,8 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
free(data);

if (verify_response == NULL) {
log_message(LOG_ERR, "Error making request");
tty_output(pamh, "Could not contact auth server");
log_message(LOG_ERR, SERVER_ERROR);
tty_output(pamh, SERVER_ERROR);
pam_result = PAM_SYSTEM_ERR;
break;
}
Expand Down
15 changes: 15 additions & 0 deletions src/pam_weblogin.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* see https://stackoverflow.com/questions/2410976/how-to-define-a-string-literal-in-gcc-command-line
* and note that # is the CPP "stringizing" operator */
#define STR(x) #x
#define TOSTR(X) STR(x)

#define API_START_PATH "start"
#define API_START_RESPONSE_CODE 201

Expand All @@ -8,3 +13,13 @@

#define PROMPT_USERNAME "Username: "
#define PROMPT_PIN "Pin: "

#define SERVER_ERROR "Server error!"

#ifndef GIT_COMMIT
#DEFINE GIT_COMMIT 0000
#endif

#ifndef JSONPARSER_GIT_COMMIT
#DEFINE JSONPARSER_GIT_COMMIT 0000
#endif

0 comments on commit d8e7c52

Please sign in to comment.