You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by me...@apache.org on 2018/12/19 12:00:57 UTC
[ranger] 34/36: RANGER-2307: Better error message,
and a NULL check for the native code
This is an automated email from the ASF dual-hosted git repository.
mehul pushed a commit to branch ranger-1.2
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit c9b727d6201e0ca9e899be9c253e26a86af370b1
Author: Zsombor Gegesy <zs...@apache.org>
AuthorDate: Fri Dec 7 10:47:53 2018 +0100
RANGER-2307: Better error message, and a NULL check for the native code
---
unixauthnative/src/main/c/credValidator.c | 7 ++++++-
unixauthpam/src/main/c/pamCredValidator.c | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/unixauthnative/src/main/c/credValidator.c b/unixauthnative/src/main/c/credValidator.c
index e426bdd..d79eb3b 100644
--- a/unixauthnative/src/main/c/credValidator.c
+++ b/unixauthnative/src/main/c/credValidator.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <sys/types.h>
#include <crypt.h>
+#include <errno.h>
#define STRLEN 64
@@ -48,11 +49,15 @@ int main(int ac, char **av, char **ev)
spwd = getspnam(pwp->pw_name) ;
if (spwd == (struct spwd *)NULL) {
- fprintf(stdout, "FAILED: unable to get (shadow) password for %s\n", username) ;
+ fprintf(stdout, "FAILED: unable to get (shadow) password for '%s', because '%s'\n", username, strerror(errno));
exit(1) ;
}
else {
char *gen = crypt(password,spwd->sp_pwdp) ;
+ if (gen == (char *)NULL) {
+ fprintf(stdout, "FAILED: crypt failed with: '%s'\n", strerror(errno));
+ exit(1);
+ }
if (strcmp(spwd->sp_pwdp,gen) == 0) {
fprintf(stdout, "OK:\n") ;
exit(0);
diff --git a/unixauthpam/src/main/c/pamCredValidator.c b/unixauthpam/src/main/c/pamCredValidator.c
index 60d38ae..8ec9f0e 100644
--- a/unixauthpam/src/main/c/pamCredValidator.c
+++ b/unixauthpam/src/main/c/pamCredValidator.c
@@ -83,7 +83,7 @@ int main(int ac, char **av, char **ev)
retval = pam_authenticate(pamh, 0);
if (retval != PAM_SUCCESS) {
- fprintf(stdout, "FAILED: Password did not match.\n") ;
+ fprintf(stdout, "FAILED: Password did not match(%s).\n", pam_strerror(pamh, retval)) ;
if (pamh) {
pam_end(pamh, retval);
}