Skip to content

Commit 43aef30

Browse files
committed
Reverted due to issue YARN-5765. Revert "YARN-5287. LinuxContainerExecutor fails to set proper permission. Contributed by Ying Zhang"
This reverts commit 131d58a. server-nodemanager/src/main/native/container-executor/test/test- container-executor.c
1 parent b7070f3 commit 43aef30

File tree

3 files changed

+1
-61
lines changed

3 files changed

+1
-61
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -615,15 +615,6 @@ int create_validate_dir(const char* npath, mode_t perm, const char* path,
615615
if (check_dir(npath, sb.st_mode, perm, finalComponent) == -1) {
616616
return -1;
617617
}
618-
} else {
619-
// Explicitly set permission after creating the directory in case
620-
// umask has been set to a restrictive value, i.e., 0077.
621-
if (chmod(npath, perm) != 0) {
622-
int permInt = perm & (S_IRWXU | S_IRWXG | S_IRWXO);
623-
fprintf(LOGFILE, "Can't chmod %s to the required permission %o - %s\n",
624-
npath, permInt, strerror(errno));
625-
return -1;
626-
}
627618
}
628619
} else {
629620
if (check_dir(npath, sb.st_mode, perm, finalComponent) == -1) {
@@ -654,7 +645,7 @@ int check_dir(const char* npath, mode_t st_mode, mode_t desired, int finalCompon
654645
* Function to prepare the container directories.
655646
* It creates the container work and log directories.
656647
*/
657-
int create_container_directories(const char* user, const char *app_id,
648+
static int create_container_directories(const char* user, const char *app_id,
658649
const char *container_id, char* const* local_dir, char* const* log_dir, const char *work_dir) {
659650
// create dirs as 0750
660651
const mode_t perms = S_IRWXU | S_IRGRP | S_IXGRP;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,3 @@ int is_docker_support_enabled();
297297
* Run a docker command passing the command file as an argument
298298
*/
299299
int run_docker(const char *command_file);
300-
301-
/**
302-
* Function to prepare the container directories.
303-
* It creates the container work and log directories.
304-
*/
305-
int create_container_directories(const char* user, const char *app_id,
306-
const char *container_id, char* const* local_dir,
307-
char* const* log_dir, const char *work_dir);
308-
309-
int create_log_dirs(const char *app_id, char * const * log_dirs);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,43 +1013,6 @@ void test_recursive_unlink_children() {
10131013
}
10141014
}
10151015

1016-
/**
1017-
* This test is used to verify that app and container directories can be
1018-
* created with required permissions when umask has been set to a restrictive
1019-
* value of 077.
1020-
*/
1021-
void test_dir_permissions() {
1022-
printf("\nTesting dir permissions\n");
1023-
1024-
// Set umask to 077
1025-
umask(077);
1026-
1027-
// Change user to the yarn user. This only takes effect when we're
1028-
// running as root.
1029-
if (seteuid(user_detail->pw_uid) != 0) {
1030-
printf("FAIL: failed to seteuid to user - %s\n", strerror(errno));
1031-
exit(1);
1032-
}
1033-
1034-
// Create container directories for "app_5"
1035-
char* container_dir = get_container_work_directory(TEST_ROOT "/local-1",
1036-
yarn_username, "app_5", "container_1");
1037-
create_log_dirs("app_5", log_dirs);
1038-
create_container_directories(yarn_username, "app_5", "container_1",
1039-
local_dirs, log_dirs, container_dir);
1040-
1041-
// Verify directories have been created with required permissions
1042-
mode_t container_dir_perm = S_IRWXU | S_IRGRP | S_IXGRP;
1043-
struct stat sb;
1044-
if (stat(container_dir, &sb) != 0 ||
1045-
check_dir(container_dir, sb.st_mode, container_dir_perm, 1) != 0) {
1046-
printf("FAIL: failed to create container directory %s "
1047-
"with required permissions\n", container_dir);
1048-
exit(1);
1049-
}
1050-
1051-
free(container_dir);
1052-
}
10531016

10541017
/**
10551018
* This test is used to verify that trim() works correctly
@@ -1253,10 +1216,6 @@ int main(int argc, char **argv) {
12531216
test_run_container();
12541217
}
12551218

1256-
// This test needs to be run in a subshell, so that when it changes umask
1257-
// and user, it doesn't give up our privs.
1258-
run_test_in_child("test_dir_permissions", test_dir_permissions);
1259-
12601219
/*
12611220
* try to seteuid(0). if it doesn't work, carry on anyway.
12621221
* we're going to capture the return value to get rid of a

0 commit comments

Comments
 (0)