HADOOP-12296. when setnetgrent returns 0 in linux, exception should be thrown. Contributed by Chang Li
This commit is contained in:
parent
0383a3973b
commit
b9d25c3ee2
|
@ -1416,6 +1416,9 @@ Release 2.7.3 - UNRELEASED
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
|
HADOOP-12296. when setnetgrent returns 0 in linux, exception should be
|
||||||
|
thrown (Chang Li via jlowe)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -57,6 +57,7 @@ Java_org_apache_hadoop_security_JniBasedUnixGroupsNetgroupMapping_getUsersForNet
|
||||||
int setnetgrentCalledFlag = 0;
|
int setnetgrentCalledFlag = 0;
|
||||||
|
|
||||||
// if not NULL then THROW exception
|
// if not NULL then THROW exception
|
||||||
|
char *errorType = NULL;
|
||||||
char *errorMessage = NULL;
|
char *errorMessage = NULL;
|
||||||
|
|
||||||
cgroup = (*env)->GetStringUTFChars(env, jgroup, NULL);
|
cgroup = (*env)->GetStringUTFChars(env, jgroup, NULL);
|
||||||
|
@ -94,7 +95,14 @@ Java_org_apache_hadoop_security_JniBasedUnixGroupsNetgroupMapping_getUsersForNet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(__linux__)
|
||||||
|
else {
|
||||||
|
errorType = "java/io/IOException";
|
||||||
|
errorMessage =
|
||||||
|
"no netgroup of this name is known or some other error occurred";
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// build return data (java array)
|
// build return data (java array)
|
||||||
|
|
||||||
|
@ -103,7 +111,7 @@ Java_org_apache_hadoop_security_JniBasedUnixGroupsNetgroupMapping_getUsersForNet
|
||||||
(*env)->FindClass(env, "java/lang/String"),
|
(*env)->FindClass(env, "java/lang/String"),
|
||||||
NULL);
|
NULL);
|
||||||
if (jusers == NULL) {
|
if (jusers == NULL) {
|
||||||
errorMessage = "java/lang/OutOfMemoryError";
|
errorType = "java/lang/OutOfMemoryError";
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +122,7 @@ Java_org_apache_hadoop_security_JniBasedUnixGroupsNetgroupMapping_getUsersForNet
|
||||||
for(current = userListHead; current != NULL; current = current->next) {
|
for(current = userListHead; current != NULL; current = current->next) {
|
||||||
jstring juser = (*env)->NewStringUTF(env, current->string);
|
jstring juser = (*env)->NewStringUTF(env, current->string);
|
||||||
if (juser == NULL) {
|
if (juser == NULL) {
|
||||||
errorMessage = "java/lang/OutOfMemoryError";
|
errorType = "java/lang/OutOfMemoryError";
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
(*env)->SetObjectArrayElement(env, jusers, i++, juser);
|
(*env)->SetObjectArrayElement(env, jusers, i++, juser);
|
||||||
|
@ -134,8 +142,8 @@ END:
|
||||||
}
|
}
|
||||||
|
|
||||||
// return results or THROW
|
// return results or THROW
|
||||||
if(errorMessage) {
|
if(errorType) {
|
||||||
THROW(env, errorMessage, NULL);
|
THROW(env, errorType, errorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
return jusers;
|
return jusers;
|
||||||
|
|
Loading…
Reference in New Issue