You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2018/09/27 09:15:45 UTC
ranger git commit: RANGER-2172: Good coding practices for unix
authentication Service in Ranger
Repository: ranger
Updated Branches:
refs/heads/ranger-0.7 53a7acd0d -> 822e76472
RANGER-2172: Good coding practices for unix authentication Service in Ranger
Signed-off-by: Sailaja Polavarapu <sp...@hortonworks.com>
(cherry picked from commit 1d47302f937e3fe1d565914c578faaf989e54424)
Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/822e7647
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/822e7647
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/822e7647
Branch: refs/heads/ranger-0.7
Commit: 822e76472c787aa1d18985430ecb5d5f0bc6457b
Parents: 53a7acd
Author: Vishal Suvagia <vi...@apache.org>
Authored: Thu Sep 27 14:28:02 2018 +0530
Committer: Pradeep <pr...@apache.org>
Committed: Thu Sep 27 14:30:41 2018 +0530
----------------------------------------------------------------------
src/main/assembly/usersync.xml | 4 ++--
unixauthnative/src/main/c/credValidator.c | 7 +++++--
unixauthpam/src/main/c/pamCredValidator.c | 9 ++++++---
3 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ranger/blob/822e7647/src/main/assembly/usersync.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/usersync.xml b/src/main/assembly/usersync.xml
index 66cf3dd..5d1efe8 100644
--- a/src/main/assembly/usersync.xml
+++ b/src/main/assembly/usersync.xml
@@ -113,7 +113,7 @@
</fileSet>
<fileSet>
<directoryMode>755</directoryMode>
- <fileMode>755</fileMode>
+ <fileMode>750</fileMode>
<outputDirectory>/native</outputDirectory>
<directory>unixauthnative/target</directory>
<includes>
@@ -122,7 +122,7 @@
</fileSet>
<fileSet>
<directoryMode>755</directoryMode>
- <fileMode>755</fileMode>
+ <fileMode>750</fileMode>
<outputDirectory>/native</outputDirectory>
<directory>unixauthpam/target</directory>
<includes>
http://git-wip-us.apache.org/repos/asf/ranger/blob/822e7647/unixauthnative/src/main/c/credValidator.c
----------------------------------------------------------------------
diff --git a/unixauthnative/src/main/c/credValidator.c b/unixauthnative/src/main/c/credValidator.c
index 1c17e92..e426bdd 100644
--- a/unixauthnative/src/main/c/credValidator.c
+++ b/unixauthnative/src/main/c/credValidator.c
@@ -23,11 +23,14 @@
#include <sys/types.h>
#include <crypt.h>
+#define STRLEN 64
+
int main(int ac, char **av, char **ev)
{
- char username[64] ;
- char password[64] ;
+ char username[STRLEN] ;
+ char password[STRLEN] ;
char line[512] ;
+ char format[20];
struct passwd *pwp;
struct spwd *spwd ;
http://git-wip-us.apache.org/repos/asf/ranger/blob/822e7647/unixauthpam/src/main/c/pamCredValidator.c
----------------------------------------------------------------------
diff --git a/unixauthpam/src/main/c/pamCredValidator.c b/unixauthpam/src/main/c/pamCredValidator.c
index 0b45a6f..60d38ae 100644
--- a/unixauthpam/src/main/c/pamCredValidator.c
+++ b/unixauthpam/src/main/c/pamCredValidator.c
@@ -32,6 +32,8 @@
#include <sys/types.h>
#include <security/pam_appl.h>
+#define STRLEN 64
+
int pamconv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) {
if (num_msg != 1 || msg[0]->msg_style != PAM_PROMPT_ECHO_OFF) {
fprintf(stderr, "ERROR: Unexpected PAM conversation '%d/%s'\n", msg[0]->msg_style, msg[0]->msg);
@@ -56,16 +58,17 @@ struct pam_conv conv = { pamconv, NULL };
int main(int ac, char **av, char **ev)
{
- char username[64] ;
- char password[64] ;
+ char username[STRLEN] ;
+ char password[STRLEN] ;
char line[512] ;
+ char format[20];
int retval;
pam_handle_t *pamh = NULL;
sprintf(format, "LOGIN:%%%ds %%%ds", STRLEN-1, STRLEN-1);
fgets(line,512,stdin) ;
- sscanf(line, "LOGIN:%s %s",username,password) ;
+ sscanf(line, format, username,password) ;
conv.appdata_ptr = (char *) password;
retval = pam_start("ranger-remote", username, &conv, &pamh);