YARN-2161. Fix build on macosx: YARN parts (Binglin Chang via aw)
This commit is contained in:
parent
151281bfca
commit
e5a531a8a7
|
@ -404,6 +404,8 @@ Release 2.6.0 - UNRELEASED
|
||||||
TestFairScheduler.testContinuousScheduling.
|
TestFairScheduler.testContinuousScheduling.
|
||||||
(Ratandeep Ratti and kasha via kasha)
|
(Ratandeep Ratti and kasha via kasha)
|
||||||
|
|
||||||
|
YARN-2161. Fix build on macosx: YARN parts (Binglin Chang via aw)
|
||||||
|
|
||||||
Release 2.5.1 - 2014-09-05
|
Release 2.5.1 - 2014-09-05
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -20,6 +20,9 @@ set(CMAKE_BUILD_TYPE, Release)
|
||||||
|
|
||||||
include(../../../../../hadoop-common-project/hadoop-common/src/JNIFlags.cmake NO_POLICY_SCOPE)
|
include(../../../../../hadoop-common-project/hadoop-common/src/JNIFlags.cmake NO_POLICY_SCOPE)
|
||||||
|
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
CHECK_FUNCTION_EXISTS(fcloseall HAVE_FCLOSEALL)
|
||||||
|
|
||||||
function(output_directory TGT DIR)
|
function(output_directory TGT DIR)
|
||||||
SET_TARGET_PROPERTIES(${TGT} PROPERTIES
|
SET_TARGET_PROPERTIES(${TGT} PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
|
||||||
|
|
|
@ -20,4 +20,6 @@
|
||||||
|
|
||||||
#cmakedefine HADOOP_CONF_DIR "@HADOOP_CONF_DIR@"
|
#cmakedefine HADOOP_CONF_DIR "@HADOOP_CONF_DIR@"
|
||||||
|
|
||||||
|
#cmakedefine HAVE_FCLOSEALL "@HAVE_FCLOSEALL@"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,7 +103,12 @@ char *resolve_config_path(const char* file_name, const char *root) {
|
||||||
real_fname = buffer;
|
real_fname = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (real_fname == NULL) ? NULL : realpath(real_fname, NULL);
|
char * ret = (real_fname == NULL) ? NULL : realpath(real_fname, NULL);
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "resolve_config_path(file_name=%s,root=%s)=%s\n",
|
||||||
|
file_name, root ? root : "null", ret ? ret : "null");
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "container-executor.h"
|
#include "container-executor.h"
|
||||||
|
|
||||||
|
#include <libgen.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fts.h>
|
#include <fts.h>
|
||||||
|
@ -450,39 +451,59 @@ char *get_tmp_directory(const char *work_dir) {
|
||||||
* with the desired permissions.
|
* with the desired permissions.
|
||||||
*/
|
*/
|
||||||
int mkdirs(const char* path, mode_t perm) {
|
int mkdirs(const char* path, mode_t perm) {
|
||||||
char *buffer = strdup(path);
|
struct stat sb;
|
||||||
char *token;
|
char * npath;
|
||||||
int cwd = open("/", O_RDONLY);
|
char * p;
|
||||||
if (cwd == -1) {
|
if (stat(path, &sb) == 0) {
|
||||||
fprintf(LOGFILE, "Can't open / in %s - %s\n", path, strerror(errno));
|
if (S_ISDIR (sb.st_mode)) {
|
||||||
free(buffer);
|
return 0;
|
||||||
return -1;
|
} else {
|
||||||
}
|
fprintf(LOGFILE, "Path %s is file not dir\n", path);
|
||||||
for(token = strtok(buffer, "/"); token != NULL; token = strtok(NULL, "/")) {
|
|
||||||
if (mkdirat(cwd, token, perm) != 0) {
|
|
||||||
if (errno != EEXIST) {
|
|
||||||
fprintf(LOGFILE, "Can't create directory %s in %s - %s\n",
|
|
||||||
token, path, strerror(errno));
|
|
||||||
close(cwd);
|
|
||||||
free(buffer);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int new_dir = openat(cwd, token, O_RDONLY);
|
npath = strdup(path);
|
||||||
close(cwd);
|
if (npath == NULL) {
|
||||||
cwd = new_dir;
|
fprintf(LOGFILE, "Not enough memory to copy path string");
|
||||||
if (cwd == -1) {
|
return -1;
|
||||||
fprintf(LOGFILE, "Can't open %s in %s - %s\n", token, path,
|
}
|
||||||
|
/* Skip leading slashes. */
|
||||||
|
p = npath;
|
||||||
|
while (*p == '/') {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (NULL != (p = strchr(p, '/'))) {
|
||||||
|
*p = '\0';
|
||||||
|
if (stat(npath, &sb) != 0) {
|
||||||
|
if (mkdir(npath, perm) != 0) {
|
||||||
|
fprintf(LOGFILE, "Can't create directory %s in %s - %s\n", npath,
|
||||||
|
path, strerror(errno));
|
||||||
|
free(npath);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (!S_ISDIR (sb.st_mode)) {
|
||||||
|
fprintf(LOGFILE, "Path %s is file not dir\n", npath);
|
||||||
|
free(npath);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*p++ = '/'; /* restore slash */
|
||||||
|
while (*p == '/')
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the final directory component. */
|
||||||
|
if (mkdir(npath, perm) != 0) {
|
||||||
|
fprintf(LOGFILE, "Can't create directory %s - %s\n", npath,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
free(buffer);
|
free(npath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
free(npath);
|
||||||
free(buffer);
|
|
||||||
close(cwd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to prepare the container directories.
|
* Function to prepare the container directories.
|
||||||
* It creates the container work and log directories.
|
* It creates the container work and log directories.
|
||||||
|
@ -582,7 +603,7 @@ int is_whitelisted(const char *user) {
|
||||||
char **users = whitelist;
|
char **users = whitelist;
|
||||||
if (whitelist != NULL) {
|
if (whitelist != NULL) {
|
||||||
for(; *users; ++users) {
|
for(; *users; ++users) {
|
||||||
if (strncmp(*users, user, LOGIN_NAME_MAX) == 0) {
|
if (strncmp(*users, user, sysconf(_SC_LOGIN_NAME_MAX)) == 0) {
|
||||||
free_values(whitelist);
|
free_values(whitelist);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1089,16 @@ int launch_container_as_user(const char *user, const char *app_id,
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_FCLOSEALL
|
||||||
fcloseall();
|
fcloseall();
|
||||||
|
#else
|
||||||
|
// only those fds are opened assuming no bug
|
||||||
|
fclose(LOGFILE);
|
||||||
|
fclose(ERRORFILE);
|
||||||
|
fclose(stdin);
|
||||||
|
fclose(stdout);
|
||||||
|
fclose(stderr);
|
||||||
|
#endif
|
||||||
umask(0027);
|
umask(0027);
|
||||||
if (chdir(work_dir) != 0) {
|
if (chdir(work_dir) != 0) {
|
||||||
fprintf(LOGFILE, "Can't change directory to %s -%s\n", work_dir,
|
fprintf(LOGFILE, "Can't change directory to %s -%s\n", work_dir,
|
||||||
|
@ -1351,6 +1381,10 @@ void chown_dir_contents(const char *dir_path, uid_t uid, gid_t gid) {
|
||||||
* hierarchy: the top directory of the hierarchy for the NM
|
* hierarchy: the top directory of the hierarchy for the NM
|
||||||
*/
|
*/
|
||||||
int mount_cgroup(const char *pair, const char *hierarchy) {
|
int mount_cgroup(const char *pair, const char *hierarchy) {
|
||||||
|
#ifndef __linux
|
||||||
|
fprintf(LOGFILE, "Failed to mount cgroup controller, not supported\n");
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
char *controller = malloc(strlen(pair));
|
char *controller = malloc(strlen(pair));
|
||||||
char *mount_path = malloc(strlen(pair));
|
char *mount_path = malloc(strlen(pair));
|
||||||
char hier_path[PATH_MAX];
|
char hier_path[PATH_MAX];
|
||||||
|
@ -1387,5 +1421,6 @@ int mount_cgroup(const char *pair, const char *hierarchy) {
|
||||||
free(mount_path);
|
free(mount_path);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ int write_config_file(char *file_name) {
|
||||||
}
|
}
|
||||||
fprintf(file, "banned.users=bannedUser\n");
|
fprintf(file, "banned.users=bannedUser\n");
|
||||||
fprintf(file, "min.user.id=500\n");
|
fprintf(file, "min.user.id=500\n");
|
||||||
fprintf(file, "allowed.system.users=allowedUser,bin\n");
|
fprintf(file, "allowed.system.users=allowedUser,daemon\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -222,20 +222,20 @@ void test_check_user() {
|
||||||
printf("FAIL: failed check for system user root\n");
|
printf("FAIL: failed check for system user root\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (check_user("bin") == NULL) {
|
if (check_user("daemon") == NULL) {
|
||||||
printf("FAIL: failed check for whitelisted system user bin\n");
|
printf("FAIL: failed check for whitelisted system user daemon\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_resolve_config_path() {
|
void test_resolve_config_path() {
|
||||||
printf("\nTesting resolve_config_path\n");
|
printf("\nTesting resolve_config_path\n");
|
||||||
if (strcmp(resolve_config_path("/etc/passwd", NULL), "/etc/passwd") != 0) {
|
if (strcmp(resolve_config_path("/bin/ls", NULL), "/bin/ls") != 0) {
|
||||||
printf("FAIL: failed to resolve config_name on an absolute path name: /etc/passwd\n");
|
printf("FAIL: failed to resolve config_name on an absolute path name: /bin/ls\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (strcmp(resolve_config_path("../etc/passwd", "/etc/passwd"), "/etc/passwd") != 0) {
|
if (strcmp(resolve_config_path("../bin/ls", "/bin/ls"), "/bin/ls") != 0) {
|
||||||
printf("FAIL: failed to resolve config_name on a relative path name: ../etc/passwd (relative to /etc/passwd)");
|
printf("FAIL: failed to resolve config_name on a relative path name: ../bin/ls (relative to /bin/ls)");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ void test_signal_container_group() {
|
||||||
printf("FAIL: fork failed\n");
|
printf("FAIL: fork failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (child == 0) {
|
} else if (child == 0) {
|
||||||
setpgrp();
|
setpgid(0,0);
|
||||||
if (change_user(user_detail->pw_uid, user_detail->pw_gid) != 0) {
|
if (change_user(user_detail->pw_uid, user_detail->pw_gid) != 0) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue