Пример #1
0
static void upload_queue_drop(const char *name)
{
	_cleanup_free_ char *newname = NULL;
	_cleanup_free_ char *old_full = NULL;
	_cleanup_free_ char *new_full = NULL;
	char *basename;
	int ret;

	lpass_log(LOG_DEBUG, "UQ: dropping %s\n", name);

	make_upload_dir("upload-fail");

	basename = strrchr(name, '/');
	if (!basename) {
		unlink(name);
		return;
	}
	basename += 1;
	xasprintf(&newname, "upload-fail/%s", basename);

	old_full = config_path(name);
	new_full = config_path(newname);
	ret = rename(old_full, new_full);

	lpass_log(LOG_DEBUG, "UQ: rename returned %d (errno=%d)\n", ret, errno);

	upload_queue_cleanup_failures();
}
Пример #2
0
static void upload_queue_cleanup_failures()
{
	_cleanup_free_ char *base_path = config_path("upload-fail");
	DIR *dir = opendir(base_path);
	struct dirent *entry;
	char *p;
	struct stat sbuf;
	int ret;

	if (!dir)
		return;

	while ((entry = readdir(dir))) {
		_cleanup_free_ char *fn = NULL;

		if (entry->d_type != DT_REG)
			continue;
		for (p = entry->d_name; *p; ++p) {
			if (!isdigit(*p))
				break;
		}
		if (*p)
			continue;

		xasprintf(&fn, "%s/%s", base_path, entry->d_name);
		ret = stat(fn, &sbuf);
		if (ret)
			continue;

		if ((time(NULL) - sbuf.st_mtime) > FAIL_MAX_AGE) {
			unlink(fn);
		}
	}
	closedir(dir);
}
Пример #3
0
void config_touch(const char *name)
{
	_cleanup_free_ char *path = NULL;
	path = config_path(name);
	if (utime(path, NULL) < 0)
		die_errno("utime");
}
Пример #4
0
void config_write_buffer(const char *name, const char *buffer, size_t len)
{
	_cleanup_free_ char *tempname = NULL;
	_cleanup_free_ char *finalpath = config_path(name);
	int tempfd;
	FILE *tempfile = NULL;

	xasprintf(&tempname, "%s.XXXXXX", finalpath);
	tempfd = mkstemp(tempname);
	if (tempfd < 0)
		die_errno("mkstemp");
	tempfile = fdopen(tempfd, "w");
	if (!tempfile)
		goto error;
	if (fwrite(buffer, 1, len, tempfile) != len)
		goto error;
	fclose(tempfile);
	tempfile = NULL;
	if (rename(tempname, finalpath) < 0)
		goto error;
	return;

error:
	tempfd = errno;
	if (tempfile)
		fclose(tempfile);
	unlink(tempname);
	errno = tempfd;
	die_errno("config-%s", name);
}
Пример #5
0
static tn_hash *loadconf(void) 
{
    char path[PATH_MAX], localpath[PATH_MAX];
    tn_hash *htcnf = NULL, *local_htcnf = NULL;
    
    if (!config_path(path, localpath, sizeof(path)))
        return NULL;
    
    if (*path)
        htcnf = poldek_conf_load(path, POLDEK_LDCONF_FOREIGN);

    if (*localpath)
        local_htcnf = poldek_conf_load(localpath, POLDEK_LDCONF_FOREIGN);

    if (htcnf == NULL) {
        htcnf = local_htcnf;
        local_htcnf = NULL;
    }

    if (htcnf && local_htcnf) {
        tn_array *aliases = poldek_conf_get_sections(htcnf, "aliases");
        if (aliases) /* XXX: yep, hacky a bit; sections should be movable
                        via conf API */
            n_hash_insert(local_htcnf, "global_aliases", n_ref(aliases));
        
        n_hash_free(htcnf);
        htcnf = local_htcnf;
        local_htcnf = NULL;
    }
    
    return htcnf;
}
Пример #6
0
void new_config(void)
/* configure numbered item menu */
{
USHORT cdis[10];

	clear_mem(cdis, sizeof(cdis));
	if (vs.dcoor)
		cdis[3] = QCF_ASTERISK;

	switch(soft_qchoice(cdis, "configuration"))
	{
		case 0:		/* set temp path */
			config_path();
			break;
		case 1:
			save_default_settings();
			break;
		case 2:
			config_input();
			break;
		case 3:
			vs.dcoor = !vs.dcoor;
			break;
		default:
			break;
	}
}
Пример #7
0
bool config_exists(const char *name)
{
	_cleanup_free_ char *path = NULL;
	struct stat sbuf;

	path = config_path(name);
	return stat(path, &sbuf) != -1;
}
Пример #8
0
krb5_error_code
smb_krb5_init_context_basic(TALLOC_CTX *tmp_ctx,
			    struct tevent_context *ev,
			    struct loadparm_context *lp_ctx,
			    krb5_context *_krb5_context)
{
	krb5_error_code ret;
	char **config_files;
	const char *config_file, *realm;
	krb5_context krb5_ctx;

	initialize_krb5_error_table();

	ret = krb5_init_context(&krb5_ctx);
	if (ret) {
		DEBUG(1,("krb5_init_context failed (%s)\n",
			 error_message(ret)));
		return ret;
	}

	config_file = config_path(tmp_ctx, lp_ctx, "krb5.conf");
	if (!config_file) {
		krb5_free_context(krb5_ctx);
		return ENOMEM;
	}

	/* Use our local krb5.conf file by default */
	ret = krb5_prepend_config_files_default(config_file == NULL?"":config_file, &config_files);
	if (ret) {
		DEBUG(1,("krb5_prepend_config_files_default failed (%s)\n",
			 smb_get_krb5_error_message(krb5_ctx, ret, tmp_ctx)));
		krb5_free_context(krb5_ctx);
		return ret;
	}

	ret = krb5_set_config_files(krb5_ctx, config_files);
	krb5_free_config_files(config_files);
	if (ret) {
		DEBUG(1,("krb5_set_config_files failed (%s)\n",
			 smb_get_krb5_error_message(krb5_ctx, ret, tmp_ctx)));
		krb5_free_context(krb5_ctx);
		return ret;
	}

	realm = lp_realm(lp_ctx);
	if (realm != NULL) {
		ret = krb5_set_default_realm(krb5_ctx, realm);
		if (ret) {
			DEBUG(1,("krb5_set_default_realm failed (%s)\n",
				 smb_get_krb5_error_message(krb5_ctx, ret, tmp_ctx)));
			krb5_free_context(krb5_ctx);
			return ret;
		}
	}

	*_krb5_context = krb5_ctx;
	return 0;
}
Пример #9
0
time_t config_mtime(const char *name)
{
	_cleanup_free_ char *path = NULL;
	struct stat sbuf;

	path = config_path(name);
	if (stat(path, &sbuf) < 0)
		return 0;

	return sbuf.st_mtime;
}
Пример #10
0
static void upload_queue_drop(const char *name)
{
	_cleanup_free_ char *newname = NULL;
	_cleanup_free_ char *old_full = NULL;
	_cleanup_free_ char *new_full = NULL;
	char *basename;

	make_upload_dir("upload-fail");

	basename = strrchr(name, '/');
	if (!basename) {
		unlink(name);
		return;
	}
	basename += 1;
	xasprintf(&newname, "upload-fail/%s", basename);

	old_full = config_path(name);
	new_full = config_path(newname);
	rename(old_full, new_full);

	upload_queue_cleanup_failures();
}
Пример #11
0
static void upload_queue_run(const struct session *session, unsigned const char key[KDF_HASH_LEN])
{
	_cleanup_free_ char *pid = NULL;
	upload_queue_kill();
	pid_t child = fork();
	if (child < 0)
		die_errno("fork(agent)");
	if (child == 0) {
		_cleanup_free_ char *upload_log_path = NULL;

		int null = open("/dev/null", 0);
		int upload_log = null;

		if (lpass_log_level() >= 0) {
			upload_log_path = config_path("lpass.log");
			upload_log = open(upload_log_path,
					  O_WRONLY | O_CREAT | O_APPEND, 0600);
		}
		if (null >= 0) {
			dup2(null, 0);
			dup2(upload_log, 1);
			dup2(null, 2);
			close(null);
			close(upload_log);
		}
		setsid();
		IGNORE_RESULT(chdir("/"));
		process_set_name("lpass [upload queue]");
		signal(SIGHUP, upload_queue_cleanup);
		signal(SIGINT, upload_queue_cleanup);
		signal(SIGQUIT, upload_queue_cleanup);
		signal(SIGTERM, upload_queue_cleanup);
		signal(SIGALRM, upload_queue_cleanup);
		setvbuf(stdout, NULL, _IOLBF, 0);

		if (http_init()) {
			lpass_log(LOG_ERROR, "UQ: unable to restart curl\n");
			_exit(EXIT_FAILURE);
		}

		lpass_log(LOG_DEBUG, "UQ: starting queue run\n");
		upload_queue_upload_all(session, key);
		lpass_log(LOG_DEBUG, "UQ: queue run complete\n");
		upload_queue_cleanup(0);
		_exit(EXIT_SUCCESS);
	}
	pid = xultostr(child);
	config_write_string("uploader.pid", pid);
}
Пример #12
0
 /// Root configuration constructor
 valcfg(const std::string& a_fname, const config_path& a_root_path = config_path())
     : m_config(m_config_root)
     , m_validator(Validator::cfg_validator::instance())
     , m_root_path(a_root_path)
 {
     config_tree::read_info(a_fname, m_config);
     try {
         m_validator.validate(m_config, true);
     } catch (config_error& e) {
         std::cerr << "Configuration error in " << e.path() << ": "
                   << e.what() << std::endl;
         std::cerr << "Configuration schema to follow:\n\n"
                   << m_validator.usage() << std::endl;
         throw;
     }
 }
Пример #13
0
static void make_upload_dir(const char *path)
{
	_cleanup_free_ char *base_path = NULL;
	struct stat sbuf;
	int ret;

	base_path = config_path(path);

	ret = stat(base_path, &sbuf);
	if ((ret == -1 && errno == ENOENT) || !S_ISDIR(sbuf.st_mode)) {
		unlink(base_path);
		if (mkdir(base_path, 0700) < 0)
			die_errno("mkdir(%s)", base_path);
	} else if (ret == -1)
		die_errno("stat(%s)", base_path);

}
Пример #14
0
redmine::result redmine::config::save() {
  std::ofstream file(config_path());
  CHECK_MSG(!file.is_open(), "could not write config file\n", return FAILURE);
  json::array Profiles;
  for (auto &profile : profiles) {
    json::object Profile;
    Profile.add("name", profile.name);
    Profile.add("url", profile.url);
    Profile.add("key", profile.key);
    Profile.add("port", profile.port);
    Profile.add("use_ssl", profile.use_ssl);
    Profile.add("verify_ssl", profile.verify_ssl);
    Profiles.append(Profile);
  }
  json::object Config;
  Config.add("browser", browser);
  Config.add("editor", editor);
  Config.add("profile_name", profile_name);
  Config.add("profiles", Profiles);
  file << json::write(Config, "  ");
  return SUCCESS;
}
Пример #15
0
bool mount_fstab(const std::string &fstab_path)
{
    bool ret = true;

    std::vector<util::fstab_rec> fstab;
    std::vector<util::fstab_rec *> recs_system;
    std::vector<util::fstab_rec *> recs_cache;
    std::vector<util::fstab_rec *> recs_data;
    std::vector<util::fstab_rec *> flags_system;
    std::vector<util::fstab_rec *> flags_cache;
    std::vector<util::fstab_rec *> flags_data;
    std::string target_system;
    std::string target_cache;
    std::string target_data;
    std::string path_fstab_gen;
    std::string path_completed;
    std::string path_failed;
    std::string base_name;
    std::string dir_name;
    struct stat st;
    std::shared_ptr<Rom> rom;
    std::string rom_id;

    Roms roms;
    roms.add_builtin();

    base_name = util::base_name(fstab_path);
    dir_name = util::dir_name(fstab_path);

    path_fstab_gen += dir_name;
    path_fstab_gen += "/.";
    path_fstab_gen += base_name;
    path_fstab_gen += ".gen";
    path_completed += dir_name;
    path_completed += "/.";
    path_completed += base_name;
    path_completed += ".completed";
    path_failed += dir_name;
    path_failed += "/.";
    path_failed += base_name;
    path_failed += ".failed";

    auto on_finish = util::finally([&] {
        if (ret) {
            util::create_empty_file(path_completed);
            LOGI("Successfully mounted partitions");
        } else {
            util::create_empty_file(path_failed);
        }
    });

    // This is a oneshot operation
    if (stat(path_completed.c_str(), &st) == 0) {
        LOGV("Filesystems already successfully mounted");
        return true;
    }

    if (stat(path_failed.c_str(), &st) == 0) {
        LOGE("Failed to mount partitions ealier. No further attempts will be made");
        return false;
    }

    // Remount rootfs as read-write so a new fstab file can be written
    if (mount("", "/", "", MS_REMOUNT, "") < 0) {
        LOGE("Failed to remount rootfs as rw: {}", strerror(errno));
    }

    // Read original fstab
    fstab = util::read_fstab(fstab_path);
    if (fstab.empty()) {
        LOGE("Failed to read {}", fstab_path);
        return false;
    }

    // Generate new fstab without /system, /cache, or /data entries
    file_ptr out(std::fopen(path_fstab_gen.c_str(), "wb"), std::fclose);
    if (!out) {
        LOGE("Failed to open {} for writing: {}",
             path_fstab_gen, strerror(errno));
        return false;
    }

    for (util::fstab_rec &rec : fstab) {
        if (rec.mount_point == "/system") {
            recs_system.push_back(&rec);
        } else if (rec.mount_point == "/cache") {
            recs_cache.push_back(&rec);
        } else if (rec.mount_point == "/data") {
            recs_data.push_back(&rec);
        } else {
            std::fprintf(out.get(), "%s\n", rec.orig_line.c_str());
        }
    }

    out.reset();

    // /system and /data are always in the fstab. The patcher should create
    // an entry for /cache for the ROMs that mount it manually in one of the
    // init scripts
    if (recs_system.empty() || recs_cache.empty() || recs_data.empty()) {
        LOGE("fstab does not contain all of /system, /cache, and /data!");
        return false;
    }

    // Mount raw partitions to /raw/*
    if (!util::kernel_cmdline_get_option("romid", &rom_id)
            && !util::file_first_line("/romid", &rom_id)) {
        LOGE("Failed to determine ROM ID");
        return false;
    }

    if (Roms::is_named_rom(rom_id)) {
        rom = Roms::create_named_rom(rom_id);
    } else {
        rom = roms.find_by_id(rom_id);
        if (!rom) {
            LOGE("Unknown ROM ID: {}", rom_id);
            return false;
        }
    }

    LOGD("ROM ID is: {}", rom_id);

    // Set property for the Android app to use
    if (!util::set_property("ro.multiboot.romid", rom_id)) {
        LOGE("Failed to set 'ro.multiboot.romid' to '{}'", rom_id);
    }

    // Because of how Android deals with partitions, if, say, the source path
    // for the /system bind mount resides on /cache, then the cache partition
    // must be mounted with the system partition's flags. In this future, this
    // may be avoided by mounting every partition with some more liberal flags,
    // since the current setup does not allow two bind mounted locations to
    // reside on the same partition.

    if (util::starts_with(rom->system_path, "/cache")) {
        flags_system = recs_cache;
    } else {
        flags_system = recs_system;
    }

    if (util::starts_with(rom->cache_path, "/system")) {
        flags_cache = recs_system;
    } else {
        flags_cache = recs_cache;
    }

    flags_data = recs_data;

    if (mkdir("/raw", 0755) < 0) {
        LOGE("Failed to create /raw");
        return false;
    }

    if (!create_dir_and_mount(recs_system, flags_system, "/raw/system")) {
        LOGE("Failed to mount /raw/system");
        return false;
    }
    if (!create_dir_and_mount(recs_cache, flags_cache, "/raw/cache")) {
        LOGE("Failed to mount /raw/cache");
        return false;
    }
    if (!create_dir_and_mount(recs_data, flags_data, "/raw/data")) {
        LOGE("Failed to mount /raw/data");
        return false;
    }

    // Make paths use /raw/...
    if (rom->system_path.empty()
            || rom->cache_path.empty()
            || rom->data_path.empty()) {
        LOGE("Invalid or empty paths");
        return false;
    }

    target_system += "/raw";
    target_system += rom->system_path;
    target_cache += "/raw";
    target_cache += rom->cache_path;
    target_data += "/raw";
    target_data += rom->data_path;

    if (!util::bind_mount(target_system, 0771, "/system", 0771)) {
        return false;
    }

    if (!util::bind_mount(target_cache, 0771, "/cache", 0771)) {
        return false;
    }

    if (!util::bind_mount(target_data, 0771, "/data", 0771)) {
        return false;
    }

    // Bind mount internal SD directory
    if (!util::bind_mount("/raw/data/media", 0771, "/data/media", 0771)) {
        return false;
    }

    // Prevent installd from dying because it can't unmount /data/media for
    // multi-user migration. Since <= 4.2 devices aren't supported anyway,
    // we'll bypass this.
    file_ptr fp(std::fopen("/data/.layout_version", "wb"), std::fclose);
    if (fp) {
        const char *layout_version;
        if (get_api_version() >= 21) {
            layout_version = "3";
        } else {
            layout_version = "2";
        }

        fwrite(layout_version, 1, strlen(layout_version), fp.get());
        fp.reset();
    } else {
        LOGE("Failed to open /data/.layout_version to disable migration");
    }

    static std::string context("u:object_r:install_data_file:s0");
    if (lsetxattr("/data/.layout_version", "security.selinux",
                  context.c_str(), context.size() + 1, 0) < 0) {
        LOGE("{}: Failed to set SELinux context: {}",
             "/data/.layout_version", strerror(errno));
    }


    // Global app sharing
    std::string config_path("/data/media/0/MultiBoot/");
    config_path += rom->id;
    config_path += "/config.json";

    RomConfig config;
    if (config.load_file(config_path)) {
        if (config.indiv_app_sharing && (config.global_app_sharing
                || config.global_paid_app_sharing)) {
            LOGW("Both individual and global sharing are enabled");
            LOGW("Global sharing settings will be ignored");
        } else {
            if (config.global_app_sharing || config.global_paid_app_sharing) {
                if (!util::bind_mount("/raw/data/app-lib", 0771,
                                      "/data/app-lib", 0771)) {
                    return false;
                }
            }
            if (config.global_app_sharing) {
                if (!util::bind_mount("/raw/data/app", 0771,
                                      "/data/app", 0771)) {
                    return false;
                }
            }
            if (config.global_paid_app_sharing) {
                if (!util::bind_mount("/raw/data/app-asec", 0771,
                                      "/data/app-asec", 0771)) {
                    return false;
                }
            }
        }
    }

    return true;
}
Пример #16
0
bool config_unlink(const char *name)
{
	_cleanup_free_ char *path = config_path(name);
	return unlink(path) == 0;
}
Пример #17
0
redmine::result redmine::config::load(redmine::options &options) {
  std::string path(config_path());
  std::ifstream file(path);
  CHECK(!file.is_open(), fprintf(stderr, "could not open: %s\n", path.c_str());
        return INVALID_CONFIG);
  std::string str((std::istreambuf_iterator<char>(file)),
                  std::istreambuf_iterator<char>());
  auto Root = json::read(str);
  CHECK_JSON_TYPE(Root, json::TYPE_OBJECT);
  CHECK(options.debug, printf("%s\n", json::write(Root, "  ").c_str()));

  // TODO: Properly handle missing config file with interactive creation.

  // TODO: Actually report config load error to stderr!
  auto Browser = Root.object().get("browser");
  if (Browser) {
    CHECK_JSON_TYPE(*Browser, json::TYPE_STRING);
    browser = Browser->string();
  }

  auto Editor = Root.object().get("editor");
  if (Editor) {
    CHECK_JSON_TYPE(*Editor, json::TYPE_STRING);
    editor = Editor->string();
  }

  auto ProfileName = Root.object().get("profile_name");
  CHECK_JSON_PTR(ProfileName, json::TYPE_STRING);
  profile_name = ProfileName->string();

  auto Profiles = Root.object().get("profiles");
  CHECK_JSON_PTR(Profiles, json::TYPE_ARRAY);

  for (auto &Profile : Profiles->array()) {
    redmine::config::profile profile;

    auto Name = Profile.object().get("name");
    CHECK_JSON_PTR(Name, json::TYPE_STRING);
    profile.name = Name->string();

    auto Url = Profile.object().get("url");
    CHECK_JSON_PTR(Url, json::TYPE_STRING);
    profile.url = Url->string();

    auto Key = Profile.object().get("key");
    CHECK_JSON_PTR(Key, json::TYPE_STRING);
    profile.key = Key->string();

    auto Port = Profile.object().get("port");
    CHECK_JSON_PTR(Port, json::TYPE_NUMBER);
    profile.port = Port->number<uint32_t>();

    auto UseSsl = Profile.object().get("use_ssl");
    if (UseSsl) {
      CHECK_JSON_TYPE(*UseSsl, json::TYPE_BOOL);
      profile.use_ssl = UseSsl->boolean();
    }

    auto VerifySsl = Profile.object().get("verify_ssl");
    if (VerifySsl) {
      CHECK_JSON_TYPE(*VerifySsl, json::TYPE_BOOL);
      profile.verify_ssl = VerifySsl->boolean();
    }

    profiles.push_back(profile);
  }

  for (auto &profile : profiles) {
    if (profile.name == profile_name) {
      current = &profiles.back();
    }
  }

  CHECK(!current,
        fprintf(stderr, "profile_name '%s' does not name a valid profile.\n",
                profile_name.c_str());
        return FAILURE);

  return SUCCESS;
}
Пример #18
0
  std::pair<boost::optional<boost::program_options::variables_map>, bool> main(
    int argc, char** argv,
    const char* const usage,
    const char* const notice,
    boost::program_options::options_description desc_params,
    const boost::program_options::positional_options_description& positional_options,
    const std::function<void(const std::string&, bool)> &print,
    const char *default_log_name,
    bool log_to_console)
  
  {
    namespace bf = boost::filesystem;
    namespace po = boost::program_options;
#ifdef WIN32
    _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

    const command_line::arg_descriptor<std::string> arg_log_level = {"log-level", "0-4 or categories", ""};
    const command_line::arg_descriptor<std::size_t> arg_max_log_file_size = {"max-log-file-size", "Specify maximum log file size [B]", MAX_LOG_FILE_SIZE};
    const command_line::arg_descriptor<std::size_t> arg_max_log_files = {"max-log-files", "Specify maximum number of rotated log files to be saved (no limit by setting to 0)", MAX_LOG_FILES};
    const command_line::arg_descriptor<uint32_t> arg_max_concurrency = {"max-concurrency", wallet_args::tr("Max number of threads to use for a parallel job"), DEFAULT_MAX_CONCURRENCY};
    const command_line::arg_descriptor<std::string> arg_log_file = {"log-file", wallet_args::tr("Specify log file"), ""};
    const command_line::arg_descriptor<std::string> arg_config_file = {"config-file", wallet_args::tr("Config file"), "", true};


    std::string lang = i18n_get_language();
    tools::on_startup();
    tools::set_strict_default_file_permissions(true);

    epee::string_tools::set_module_name_and_folder(argv[0]);

    po::options_description desc_general(wallet_args::tr("General options"));
    command_line::add_arg(desc_general, command_line::arg_help);
    command_line::add_arg(desc_general, command_line::arg_version);

    command_line::add_arg(desc_params, arg_log_file);
    command_line::add_arg(desc_params, arg_log_level);
    command_line::add_arg(desc_params, arg_max_log_file_size);
    command_line::add_arg(desc_params, arg_max_log_files);
    command_line::add_arg(desc_params, arg_max_concurrency);
    command_line::add_arg(desc_params, arg_config_file);

    i18n_set_language("translations", "monero", lang);

    po::options_description desc_all;
    desc_all.add(desc_general).add(desc_params);
    po::variables_map vm;
    bool should_terminate = false;
    bool r = command_line::handle_error_helper(desc_all, [&]()
    {
      auto parser = po::command_line_parser(argc, argv).options(desc_all).positional(positional_options);
      po::store(parser.run(), vm);

      if (command_line::get_arg(vm, command_line::arg_help))
      {
        Print(print) << "Aeon '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL;
        Print(print) << wallet_args::tr("This is the command line Aeon wallet. It needs to connect to a Aeon\n"
												  "daemon to work correctly.") << ENDL;
        Print(print) << wallet_args::tr("Usage:") << ENDL << "  " << usage;
        Print(print) << desc_all;
        should_terminate = true;
        return true;
      }
      else if (command_line::get_arg(vm, command_line::arg_version))
      {
        Print(print) << "Aeon '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";
        should_terminate = true;
        return true;
      }

      if(command_line::has_arg(vm, arg_config_file))
      {
        std::string config = command_line::get_arg(vm, arg_config_file);
        bf::path config_path(config);
        boost::system::error_code ec;
        if (bf::exists(config_path, ec))
        {
          po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_params), vm);
        }
        else
        {
          MERROR(wallet_args::tr("Can't find config file ") << config);
          return false;
        }
      }

      po::notify(vm);
      return true;
    });
    if (!r)
      return {boost::none, true};

    if (should_terminate)
      return {std::move(vm), should_terminate};

    std::string log_path;
    if (!command_line::is_arg_defaulted(vm, arg_log_file))
      log_path = command_line::get_arg(vm, arg_log_file);
    else
      log_path = mlog_get_default_log_path(default_log_name);
    mlog_configure(log_path, log_to_console, command_line::get_arg(vm, arg_max_log_file_size), command_line::get_arg(vm, arg_max_log_files));
    if (!command_line::is_arg_defaulted(vm, arg_log_level))
    {
      mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str());
    }
    else if (!log_to_console)
    {
      mlog_set_categories("");
    }

    if (notice)
      Print(print) << notice << ENDL;

    if (!command_line::is_arg_defaulted(vm, arg_max_concurrency))
      tools::set_max_concurrency(command_line::get_arg(vm, arg_max_concurrency));

    Print(print) << "Aeon '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";

    if (!command_line::is_arg_defaulted(vm, arg_log_level))
      MINFO("Setting log level = " << command_line::get_arg(vm, arg_log_level));
    else
      MINFO("Setting log levels = " << getenv("AEON_LOGS"));
    MINFO(wallet_args::tr("Logging to: ") << log_path);

    Print(print) << boost::format(wallet_args::tr("Logging to %s")) % log_path;

    return {std::move(vm), should_terminate};
  }
Пример #19
0
  void Environment::load_vm_options(int argc, char**argv) {
    /* We parse -X options from three sources in the following order:
     *
     *  1. The file $HOME/.rbxconfig if $HOME is defined.
     *  2. The file .rbxconfig in the current working directory.
     *  3. The RBXOPT environment variable.
     *  4. The command line options.
     *
     * This order permits environment and command line options to override
     * "application" configuration. Likewise, command line options can override
     * environment configuration.
     */

    char* home = getenv("HOME");
    if(home) {
      std::string config_path(home);
      config_path += "/.rbxconfig";

      if(FILE* fp = fopen(config_path.c_str(), "r")) {
        read_config_file(fp, config_parser);
      }
    }

    // Configuration file.
    if(FILE* fp = fopen(".rbxconfig", "r")) {
      read_config_file(fp, config_parser);
    } else if(FILE* fp = fopen(".rbxrc", "r")) {
      std::cerr << "Use of config file .rbxrc is deprecated, use .rbxconfig." << std::endl;
      read_config_file(fp, config_parser);
    }

    // Environment.
    char* rbxopt = getenv("RBXOPT");
    if(rbxopt) {
      char *e, *b = rbxopt = strdup(rbxopt);
      char *s = b + strlen(rbxopt);

      while(b < s) {
        while(*b && isspace(*b)) b++;

        e = b;
        while(*e && !isspace(*e)) e++;

        if(e - b > 0) {
          if(strncmp(b, "-X", 2) == 0) {
            *e = 0;
            config_parser.import_line(b + 2);
          }
          b = e + 1;
        }
      }

      free(rbxopt);
    }

    // Command line.
    for(int i=1; i < argc; i++) {
      char* arg = argv[i];

      if(strcmp(arg, "--") == 0) {
        break;
      }

      if(strncmp(arg, "-X", 2) == 0) {
        config_parser.import_line(arg + 2);

      /* If we hit the first non-option, break out so in the following
       * command line, the first 'rbx' doesn't consume '-Xprofile':
       *
       *   rbx bundle exec rbx -Xprofile blah
       */
      } else if(arg[0] != '-') {
        break;
      }
    }

    config_parser.update_configuration(config);

    set_tmp_path();
    set_username();
    set_pid();
    set_console_path();
    set_codedb_paths();
  }
Пример #20
0
/*
 * jt_tool()
 *
 * Execute an external program, optionally setting various environment
 * variables.
 *
 *	cmd		Name of command to execute.
 *	ops		Bitmask of operations to perform before the execution.
 *	argc		Argument count.
 *	argv		Command line arguments. The class name will be argv[1].
 *	suffix		Suffix to append to the class name.
 *
 * This routine does not return. If an error occurs, it exits with a failure
 * status.
 */
void
jt_tool(char *cmd, int ops, int argc, char **argv, char *suffix)
{
	/* The first two are static, since they are passed to jt_putenv() */
	static char newclasspath[MAXPATH];
	static char newlibpaths[NELEM(libpathvars)][MAXPATH];
	char *tetroot;
	char *classpath;
	char *libpath;
	int i;
	char **newargs;
	char *cp;

	/* Verify we have at least one argument */
	if (argc < 2)
		jt_err(argv[0], "incorrect argument count");

	/* Verify TET_ROOT is set in the environment */
	tetroot = getenv("TET_ROOT");
	if (tetroot == NULL || tetroot[0] == '\0')
		jt_err(argv[0], "TET_ROOT is NULL or not set in environment");

	/* If required, set the CLASSPATH environment variable to include the
	 * JET jar file.
	 */
	if (ops & OP_SETCLASSPATH)
	{
		classpath = getenv("CLASSPATH");
		if (classpath == NULL || classpath[0] == '\0')
		{
			sprintf(newclasspath,
				"CLASSPATH=.%c%s%clib%cjava%cjet.jar",
				PATHSEP, tetroot, DIRSEP, DIRSEP, DIRSEP);
		}
		else
		{
			sprintf(newclasspath,
				"CLASSPATH=%s%clib%cjava%cjet.jar%c%s%c.",
				tetroot, DIRSEP, DIRSEP, DIRSEP, PATHSEP,
				classpath, PATHSEP);
		}

		if (jt_putenv(newclasspath) != 0)
			jt_err(argv[0],
				"error setting CLASSPATH in environment");
	}

	/* If required, set the environment variable used as the search path
	 * for shared libraries to include the directory containing libjet.
	 */
	if (ops & OP_SETLIBPATH)
	{
		for (i = 0; i < NELEM(libpathvars); i++)
		{
			libpath = getenv(libpathvars[i]);
			if (libpath == NULL)
			{ 
				sprintf(newlibpaths[i], "%s=%s%clib%cjava",
					libpathvars[i], tetroot, DIRSEP,
					DIRSEP);
			}
			else
			{
				sprintf(newlibpaths[i], "%s=%s%clib%cjava%c%s",
					libpathvars[i], tetroot, DIRSEP,
					DIRSEP, PATHSEP, libpath);
			}

			if (jt_putenv(newlibpaths[i]) != 0)
				jt_err(argv[0],
					"error setting %s in environment",
					libpathvars[i]);
		}
	}

	/* Prepare command and new argument vector */
	newargs = malloc(sizeof(*newargs) * (argc + 1));
	if (newargs == NULL)
		jt_err(argv[0], "memory allocation failure");

	newargs[0] = cmd;

	newargs[1] = malloc(strlen(argv[1]) + strlen(suffix) + 1);
	if (newargs[1] == NULL)
		jt_err(argv[0], "memory allocation failure");

	/* Copy the classname and suffix into the first argument */
	sprintf(newargs[1], "%s%s", argv[1], suffix);

	/* Some versions of Sun's javac on Win32 don't recognize '/' as a
	 * directory separator when it comes to verifying that the class is in
	 * a correctly named file. So we swap to backslashes here.
	 */
	if (ops & OP_SWAPDIRSEP)
	{
		for (cp = newargs[1]; *cp != '\0'; cp++)
			if (ISDIRSEP(*cp))
				*cp = DIRSEP;
	}

	for (i = 2; i <= argc; i++)
		newargs[i] = argv[i];

	/* Exec command */
	cmd = config_path(cmd);
	jt_execvp(cmd, newargs);
	jt_err(argv[0], "error executing command \"%s\": %s", cmd,
		strerror(errno));
}
Пример #21
0
Файл: virt.cpp Проект: kohn/rsi
std::string VM_Controller::_make_tmp_config_file_name(std::string vm_name){
    std::string config_path("/tmp/");
    return config_path+vm_name+".xml";
}
Пример #22
0
//------------------------------------------------------------------------------
// Purpose    : Parse the command line and config file
// Parameters : argc, argv
// Returns    : Filled-in Options structure
//------------------------------------------------------------------------------
Options GetOptions(int argc, char * const argv[])
{

  // Read command line options
  Options opt;
  po::options_description desc("Allowed options");
  desc.add_options()
  ("help,h", "Show this message")
  ("callsign", po::value<string>(&opt.callsign), "Sender's Callsign")
  ("sequence", po::value<int>(&opt.sequence)->default_value(1),
   "Message Sequence Number")
  ("user", po::value<string>(&opt.user), "Google User Name")
  ("password", po::value<string>(&opt.password), "Google Password")
  ("from", po::value<string>(&opt.from), "FM Addee")
  ("to", po::value<string>(&opt.to), "TO Addee")
  ("info", po::value<string>(&opt.info), "INFO Addee")
  ("subject", po::value<string>(&opt.subject), "Message Subject")
  ("spreadsheet-name", po::value<string>(&opt.spreadsheet_name),
   "Spreadsheet Name")
  ("spreadsheet-id", po::value<string>(&opt.spreadsheet_id), "Spreadsheet ID")
  ("worksheet-name", po::value<string>(&opt.worksheet_name), "Worksheet Name")
  ("worksheet-id", po::value<string>(&opt.worksheet_id), "Worksheet ID")
  ;

  // Config file
  string config_file = ExpandDirectory("~/.thirteenrc");
  fs::path config_path(config_file);

  // Load configuration
  po::variables_map vm;
  try {
    po::store(po::parse_command_line(argc, argv, desc), vm);
    if(fs::exists(config_path)) {
      ifstream config_stream(config_file.c_str());
      po::store(po::parse_config_file(config_stream, desc), vm);
    }
  } catch(exception& e) {
    cerr << "Unable to parse command line: " << e.what() << endl;
    exit(1);
  }
  po::notify(vm);
  if (vm.count("help")) {
    cout << desc << "\n";
    exit(1);
  }

  // Test for errors
  vector<string> errors;
  if(!(opt.spreadsheet_name.size() || opt.spreadsheet_id.size())) {
    errors.push_back("Either a spreadsheet name or a spreadsheet"
                     " id must be specified");
  }
  if(!opt.user.size()) {
    errors.push_back("No Google Docs user specified");
  }
  if(!opt.password.size()) {
    errors.push_back("No Google Docs password specified");
  }
  if(!opt.from.size()) {
    errors.push_back("No FM addee specified");
  }
  if(!opt.to.size()) {
    errors.push_back("No TO addee specified");
  }
  if(!opt.info.size()) {
    errors.push_back("No INFO addee specified");
  }
  if(!opt.subject.size()) {
    errors.push_back("No subject specified");
  }
  if(errors.size()) {
    cout << "Error:" << endl;
    BOOST_FOREACH(string error, errors) {
      cout << "  " << error << endl;
    }
    exit(1);
  }
Пример #23
0
static char *upload_queue_next_entry(unsigned const char key[KDF_HASH_LEN], char **name, char **lock)
{
	unsigned long long smallest = ULLONG_MAX, current;
	_cleanup_free_ char *smallest_name = NULL;
	_cleanup_free_ char *base_path = config_path("upload-queue");
	_cleanup_free_ char *pidstr = NULL;
	pid_t pid;
	char *result, *p;
	DIR *dir = opendir(base_path);
	struct dirent *entry;

	if (!dir)
		return NULL;
	while ((entry = readdir(dir))) {
		if (entry->d_type != DT_REG)
			continue;
		for (p = entry->d_name; *p; ++p) {
			if (!isdigit(*p))
				break;
		}
		if (*p)
			continue;
		current = strtoull(entry->d_name, NULL, 10);
		if (!current)
			continue;
		if (current < smallest) {
			smallest = current;
			free(smallest_name);
			smallest_name = xstrdup(entry->d_name);
		}
	}
	closedir(dir);
	if (smallest == ULLONG_MAX)
		return NULL;

	xasprintf(name, "upload-queue/%s", smallest_name);
	xasprintf(lock, "%s.lock", *name);
	while (config_exists(*lock)) {
		free(pidstr);
		pidstr = config_read_encrypted_string(*lock, key);
		if (!pidstr) {
			config_unlink(*lock);
			break;
		}
		pid = strtoul(pidstr, NULL, 10);
		if (!pid) {
			config_unlink(*lock);
			break;
		}
		if (process_is_same_executable(pid))
			sleep(1);
		else {
			config_unlink(*lock);
			break;
		}
	}
	free(pidstr);
	pidstr = xultostr(getpid());
	config_write_encrypted_string(*lock, pidstr, key);
	result = config_read_encrypted_string(*name, key);
	if (!result) {
		/* could not decrypt: drop this file */
		upload_queue_drop(*name);
		config_unlink(*lock);
		return NULL;
	}
	return result;
}
Пример #24
0
int main(int argc, char const * argv[])
{
  try {

    _note_c("dbg/main", "Begin of main()");
    // TODO parse the debug options like set log level right here at start

    tools::sanitize_locale();

    epee::string_tools::set_module_name_and_folder(argv[0]);

    // Build argument description
    po::options_description all_options("All");
    po::options_description hidden_options("Hidden");
    po::options_description visible_options("Options");
    po::options_description core_settings("Settings");
    po::positional_options_description positional_options;
    {
      bf::path default_data_dir = daemonizer::get_default_data_dir();
      bf::path default_testnet_data_dir = {default_data_dir / "testnet"};

      // Misc Options

      command_line::add_arg(visible_options, command_line::arg_help);
      command_line::add_arg(visible_options, command_line::arg_version);
      command_line::add_arg(visible_options, daemon_args::arg_os_version);
      bf::path default_conf = default_data_dir / std::string(CRYPTONOTE_NAME ".conf");
      command_line::add_arg(visible_options, daemon_args::arg_config_file, default_conf.string());
      command_line::add_arg(visible_options, command_line::arg_test_dbg_lock_sleep);
      cryptonote::core::init_options(core_settings);

      // Settings
      bf::path default_log = default_data_dir / std::string(CRYPTONOTE_NAME ".log");
      command_line::add_arg(core_settings, daemon_args::arg_log_file, default_log.string());
      command_line::add_arg(core_settings, daemon_args::arg_log_level);

      daemonizer::init_options(hidden_options, visible_options);
      daemonize::t_executor::init_options(core_settings);

      // Hidden options
      command_line::add_arg(hidden_options, daemon_args::arg_command);

      visible_options.add(core_settings);
      all_options.add(visible_options);
      all_options.add(hidden_options);

      // Positional
      positional_options.add(daemon_args::arg_command.name, -1); // -1 for unlimited arguments
    }

    // Do command line parsing
    po::variables_map vm;
    bool ok = command_line::handle_error_helper(visible_options, [&]()
    {
      boost::program_options::store(
        boost::program_options::command_line_parser(argc, argv)
          .options(all_options).positional(positional_options).run()
      , vm
      );

      return true;
    });
    if (!ok) return 1;

    if (command_line::get_arg(vm, command_line::arg_help))
    {
      std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL;
      std::cout << "Usage: " + std::string{argv[0]} + " [options|settings] [daemon_command...]" << std::endl << std::endl;
      std::cout << visible_options << std::endl;
      return 0;
    }

    // Monero Version
    if (command_line::get_arg(vm, command_line::arg_version))
    {
      std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL;
      return 0;
    }

    // OS
    if (command_line::get_arg(vm, daemon_args::arg_os_version))
    {
      std::cout << "OS: " << tools::get_os_version_string() << ENDL;
      return 0;
    }

    epee::g_test_dbg_lock_sleep = command_line::get_arg(vm, command_line::arg_test_dbg_lock_sleep);

    std::string db_type = command_line::get_arg(vm, command_line::arg_db_type);

    // verify that blockchaindb type is valid
    if(cryptonote::blockchain_db_types.count(db_type) == 0)
    {
      std::cout << "Invalid database type (" << db_type << "), available types are:" << std::endl;
      for (const auto& type : cryptonote::blockchain_db_types)
      {
        std::cout << "\t" << type << std::endl;
      }
      return 0;
    }

    bool testnet_mode = command_line::get_arg(vm, command_line::arg_testnet_on);

    auto data_dir_arg = testnet_mode ? command_line::arg_testnet_data_dir : command_line::arg_data_dir;

    // data_dir
    //   default: e.g. ~/.bitmonero/ or ~/.bitmonero/testnet
    //   if data-dir argument given:
    //     absolute path
    //     relative path: relative to cwd

    // Create data dir if it doesn't exist
    boost::filesystem::path data_dir = boost::filesystem::absolute(
        command_line::get_arg(vm, data_dir_arg));
    tools::create_directories_if_necessary(data_dir.string());

    // FIXME: not sure on windows implementation default, needs further review
    //bf::path relative_path_base = daemonizer::get_relative_path_base(vm);
    bf::path relative_path_base = data_dir;

    std::string config = command_line::get_arg(vm, daemon_args::arg_config_file);

    boost::filesystem::path data_dir_path(data_dir);
    boost::filesystem::path config_path(config);
    if (!config_path.has_parent_path())
    {
      config_path = data_dir / config_path;
    }

    boost::system::error_code ec;
    if (bf::exists(config_path, ec))
    {
      po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), core_settings), vm);
    }
    po::notify(vm);

    // If there are positional options, we're running a daemon command
    {
      auto command = command_line::get_arg(vm, daemon_args::arg_command);

      if (command.size())
      {
        auto rpc_ip_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_ip);
        auto rpc_port_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_port);
        if (testnet_mode)
        {
          rpc_port_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_testnet_rpc_bind_port);
        }

        uint32_t rpc_ip;
        uint16_t rpc_port;
        if (!epee::string_tools::get_ip_int32_from_string(rpc_ip, rpc_ip_str))
        {
          std::cerr << "Invalid IP: " << rpc_ip_str << std::endl;
          return 1;
        }
        if (!epee::string_tools::get_xtype_from_string(rpc_port, rpc_port_str))
        {
          std::cerr << "Invalid port: " << rpc_port_str << std::endl;
          return 1;
        }

        daemonize::t_command_server rpc_commands{rpc_ip, rpc_port};
        if (rpc_commands.process_command_vec(command))
        {
          return 0;
        }
        else
        {
          std::cerr << "Unknown command" << std::endl;
          return 1;
        }
      }
    }

    // Start with log level 0
    epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_0);

    // Set log level
    {
      int new_log_level = command_line::get_arg(vm, daemon_args::arg_log_level);
      if(new_log_level < LOG_LEVEL_MIN || new_log_level > LOG_LEVEL_MAX)
      {
        LOG_PRINT_L0("Wrong log level value: " << new_log_level);
      }
      else if (epee::log_space::get_set_log_detalisation_level(false) != new_log_level)
      {
        epee::log_space::get_set_log_detalisation_level(true, new_log_level);
        int otshell_utils_log_level = 100 - (new_log_level * 20);
        gCurrentLogger.setDebugLevel(otshell_utils_log_level);
        LOG_PRINT_L0("LOG_LEVEL set to " << new_log_level);
      }
    }

    // log_file_path
    //   default: <data_dir>/<CRYPTONOTE_NAME>.log
    //   if log-file argument given:
    //     absolute path
    //     relative path: relative to data_dir

    // Set log file
    {
      bf::path log_file_path {data_dir / std::string(CRYPTONOTE_NAME ".log")};
      if (! vm["log-file"].defaulted())
        log_file_path = command_line::get_arg(vm, daemon_args::arg_log_file);
      log_file_path = bf::absolute(log_file_path, relative_path_base);

      epee::log_space::log_singletone::add_logger(
          LOGGER_FILE
        , log_file_path.filename().string().c_str()
        , log_file_path.parent_path().string().c_str()
        );
    }

    _note_c("dbg/main", "Moving from main() into the daemonize now.");

    return daemonizer::daemonize(argc, argv, daemonize::t_executor{}, vm);
  }
  catch (std::exception const & ex)
  {
    LOG_ERROR("Exception in main! " << ex.what());
  }
  catch (...)
  {
    LOG_ERROR("Exception in main!");
  }
  return 1;
}
Пример #25
0
FILE *config_fopen(const char *name, const char *mode)
{
	_cleanup_free_ char *path = config_path(name);
	return fopen(path, mode);
}
Пример #26
0
static inline char *agent_socket_path(void)
{
	return config_path("agent.sock");
}
Пример #27
0
bool daemon_backend::start(int argc, char* argv[], view::i_view* pview_handler)
{
  m_stop_singal_sent = false;
  if(pview_handler)
    m_pview = pview_handler;

  view::daemon_status_info dsi = AUTO_VAL_INIT(dsi);
  dsi.difficulty = "---";
  dsi.text_state = "Initializing...";
  pview_handler->update_daemon_status(dsi);

  //#ifdef WIN32
  //_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
  //#endif

  log_space::get_set_log_detalisation_level(true, LOG_LEVEL_0);
  LOG_PRINT_L0("Initing...");

  TRY_ENTRY();
  po::options_description desc_cmd_only("Command line options");
  po::options_description desc_cmd_sett("Command line options and settings options");

  command_line::add_arg(desc_cmd_only, command_line::arg_help);
  command_line::add_arg(desc_cmd_only, command_line::arg_version);
  command_line::add_arg(desc_cmd_only, command_line::arg_os_version);
  // tools::get_default_data_dir() can't be called during static initialization
  command_line::add_arg(desc_cmd_only, command_line::arg_data_dir, tools::get_default_data_dir());
  command_line::add_arg(desc_cmd_only, command_line::arg_config_file);

  command_line::add_arg(desc_cmd_sett, command_line::arg_log_file);
  command_line::add_arg(desc_cmd_sett, command_line::arg_log_level);
  command_line::add_arg(desc_cmd_sett, command_line::arg_console);
  command_line::add_arg(desc_cmd_sett, command_line::arg_show_details);
  command_line::add_arg(desc_cmd_sett, arg_alloc_win_console);


  currency::core::init_options(desc_cmd_sett);
  currency::core_rpc_server::init_options(desc_cmd_sett);
  nodetool::node_server<currency::t_currency_protocol_handler<currency::core> >::init_options(desc_cmd_sett);
  currency::miner::init_options(desc_cmd_sett);

  po::options_description desc_options("Allowed options");
  desc_options.add(desc_cmd_only).add(desc_cmd_sett);

  po::variables_map vm;
  bool r = command_line::handle_error_helper(desc_options, [&]()
  {
    po::store(po::parse_command_line(argc, argv, desc_options), vm);

    if (command_line::get_arg(vm, command_line::arg_help))
    {
      std::cout << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG << ENDL << ENDL;
      std::cout << desc_options << std::endl;
      return false;
    }

    m_data_dir = command_line::get_arg(vm, command_line::arg_data_dir);
    std::string config = command_line::get_arg(vm, command_line::arg_config_file);

    boost::filesystem::path data_dir_path(m_data_dir);
    boost::filesystem::path config_path(config);
    if (!config_path.has_parent_path())
    {
      config_path = data_dir_path / config_path;
    }

    boost::system::error_code ec;
    if (boost::filesystem::exists(config_path, ec))
    {
      po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_cmd_sett), vm);
    }
    po::notify(vm);

    return true;
  });
  if (!r)
    return false;

  //set up logging options
  if(command_line::has_arg(vm, arg_alloc_win_console))
  {
     log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
  }

  boost::filesystem::path log_file_path(command_line::get_arg(vm, command_line::arg_log_file));
  if (log_file_path.empty())
    log_file_path = log_space::log_singletone::get_default_log_file();
  std::string log_dir;
  log_dir = log_file_path.has_parent_path() ? log_file_path.parent_path().string() : log_space::log_singletone::get_default_log_folder();

  log_space::log_singletone::add_logger(LOGGER_FILE, log_file_path.filename().string().c_str(), log_dir.c_str());
  LOG_PRINT_L0(CURRENCY_NAME << " v" << PROJECT_VERSION_LONG);

  LOG_PRINT("Module folder: " << argv[0], LOG_LEVEL_0);

  bool res = true;
  currency::checkpoints checkpoints;
  res = currency::create_checkpoints(checkpoints);
  CHECK_AND_ASSERT_MES(res, false, "Failed to initialize checkpoints");
  m_ccore.set_checkpoints(std::move(checkpoints));

  m_main_worker_thread = std::thread([this, vm](){main_worker(vm);});

  return true;
  CATCH_ENTRY_L0("main", 1);
 }