Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d86660ba6050
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3682bd3dd118
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Mar 30, 2015

  1. Changed default log location and permissions.

    Typical programs that log to eg /var/log are daemons or services. There is typically
    a single process or process group on a node. In contrast, Rubinius may be run by
    multiple users on a single node. Segregating the log file by user enables better
    control of the log file permissions.
    brixen committed Mar 30, 2015
    Copy the full SHA
    f96d095 View commit details
  2. Copy the full SHA
    3682bd3 View commit details
Showing with 32 additions and 28 deletions.
  1. +4 −4 library/rubinius/configuration.rb
  2. +20 −23 vm/environment.cpp
  3. +1 −0 vm/environment.hpp
  4. +1 −0 vm/shared_state.hpp
  5. +1 −0 vm/signal.cpp
  6. +4 −0 vm/signal.hpp
  7. +1 −1 vm/util/logger.cpp
8 changes: 4 additions & 4 deletions library/rubinius/configuration.rb
Original file line number Diff line number Diff line change
@@ -172,10 +172,10 @@
c.vm_variable "profiler.threshold", 1000000,
"The minimum number of nanoseconds a profiler node must have to be reported"

c.vm_variable "system.tmp", "$TMPDIR",
"Default temp/fallback directory for the process"

c.section "system" do |s|
s.vm_variable "tmp", "$TMPDIR",
"Default temp/fallback directory for the process"

s.vm_variable "fsapi.path", "$TMPDIR",
"Base directory of the Rubinius File System API files"

@@ -185,7 +185,7 @@
s.vm_variable "console.access", 0660,
"Permissions on the Rubinius Console files"

s.vm_variable "log", "/var/log/$PROGRAM_NAME.log",
s.vm_variable "log", "$TMPDIR/$USER-$PROGRAM_NAME.log",
"Logging facility to use: 'syslog', 'console', or path"

s.vm_variable "log.level", "warn",
43 changes: 20 additions & 23 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
@@ -201,34 +201,25 @@ namespace rubinius {
} else if(!config.system_log.value.compare("console")) {
utilities::logger::open(utilities::logger::eConsoleLogger, RBX_PROGRAM_NAME, level);
} else {
const char* place_holder = "$PROGRAM_NAME";
size_t index = config.system_log.value.find(place_holder);
const char* tmpdir = "$TMPDIR";
size_t index = config.system_log.value.find(tmpdir);

if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(place_holder), RBX_PROGRAM_NAME);
config.system_log.value.replace(index, strlen(tmpdir), config.system_tmp);
}

int fd;
const char* program_name = "$PROGRAM_NAME";
index = config.system_log.value.find(program_name);

if((fd = open(config.system_log.value.c_str(), O_CREAT, 0644)) > 0) {
close(fd);
} else if(errno == EACCES) {
std::ostringstream path;

if(const char* s = strrchr(config.system_log.value.c_str(), '/')) {
path << (s + 1);
} else {
path << config.system_log.value.c_str();
}
if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(program_name), RBX_PROGRAM_NAME);
}

config.system_log.value.assign(config.system_tmp.value + path.str());
const char* user = "$USER";
index = config.system_log.value.find(user);

if((fd = open(config.system_log.value.c_str(), O_CREAT, 0644)) > 0) {
close(fd);
} else {
std::cerr << RBX_PROGRAM_NAME << ": unable to open log: "
<< config.system_log.value.c_str() << std::endl;
}
if(index != std::string::npos) {
config.system_log.value.replace(index, strlen(user), shared->username);
}

utilities::logger::open(utilities::logger::eFileLogger,
@@ -321,6 +312,7 @@ namespace rubinius {
config_parser.update_configuration(config);

set_tmp_path();
set_username();
set_fsapi_path();
}

@@ -340,9 +332,14 @@ namespace rubinius {
}
}

void Environment::set_username() {
struct passwd *user_passwd = getpwuid(getuid());

shared->username.assign(user_passwd->pw_name);
}

void Environment::set_fsapi_path() {
std::ostringstream path;
struct passwd *user_passwd = getpwuid(getuid());

if(!config.system_fsapi_path.value.compare("$TMPDIR")) {
path << config.system_tmp.value;
@@ -353,7 +350,7 @@ namespace rubinius {
if(cpath[cpath.size() - 1] != '/') path << "/";
}

path << "rbx-" << user_passwd->pw_name << "-" << getpid();
path << "rbx-" << shared->username << "-" << getpid();

shared->fsapi_path.assign(path.str());

1 change: 1 addition & 0 deletions vm/environment.hpp
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ namespace rubinius {
void load_string(std::string str);
void run_file(std::string path);
void set_tmp_path();
void set_username();
void set_fsapi_path();
void load_tool();
void run_from_filesystem();
1 change: 1 addition & 0 deletions vm/shared_state.hpp
Original file line number Diff line number Diff line change
@@ -142,6 +142,7 @@ namespace rubinius {
SymbolTable symbols;
LLVMState* llvm_state;
std::string fsapi_path;
std::string username;
uint32_t hash_seed;

public:
1 change: 1 addition & 0 deletions vm/signal.cpp
Original file line number Diff line number Diff line change
@@ -349,6 +349,7 @@ namespace rubinius {
logger::fatal("--- end system info ---");

logger::fatal("--- begin rubinius info ---");
logger::fatal("user: %s", signal_thread_->shared().username.c_str());
logger::fatal("pid: %d", getpid());
logger::fatal("program name: %s", RBX_PROGRAM_NAME);
logger::fatal("version: %s", RBX_VERSION);
4 changes: 4 additions & 0 deletions vm/signal.hpp
Original file line number Diff line number Diff line change
@@ -36,6 +36,10 @@ namespace rubinius {

SignalThread(STATE, Configuration& config);

SharedState& shared() {
return shared_;
}

void initialize(STATE);
void setup_default_handlers();

2 changes: 1 addition & 1 deletion vm/util/logger.cpp
Original file line number Diff line number Diff line change
@@ -256,7 +256,7 @@ namespace rubinius {

#define LOGGER_MAX_FILE 5242880
#define LOGGER_OPEN_FLAGS (O_CREAT | O_APPEND | O_WRONLY | O_CLOEXEC)
#define LOGGER_OPEN_PERMS 0644
#define LOGGER_OPEN_PERMS 0600

FileLogger::FileLogger(const char* identifier)
: Logger()