void cfg_set_global_paths(GlobalConfig *self) { cfg_args_set(self->lexer->globals, "syslog-ng-root", get_installation_path_for(PATH_PREFIX)); cfg_args_set(self->lexer->globals, "syslog-ng-data", get_installation_path_for(PATH_DATADIR)); cfg_args_set(self->lexer->globals, "module-path", module_path); cfg_args_set(self->lexer->globals, "include-path", get_installation_path_for(PATH_SYSCONFDIR)); cfg_args_set(self->lexer->globals, "autoload-compiled-modules", "1"); }
gboolean get_installer_version(gchar **inst_version) { gchar line[1024]; gboolean result = FALSE; FILE *f_install = fopen(get_installation_path_for(PATH_INSTALL_DAT), "r"); if (!f_install) return FALSE; while (fgets(line, sizeof(line), f_install) != NULL) { if (strncmp(line, INSTALL_DAT_INSTALLER_VERSION, strlen(INSTALL_DAT_INSTALLER_VERSION)) == 0) { gchar *pos = strchr(line, '='); if (pos) { *inst_version = strdup(pos+1); result = TRUE; break; } } } fclose(f_install); return result; }
/** * g_process_change_dir: * * Change the current working directory to the value specified by the user * and verify that the daemon would be able to dump core to that directory * if that is requested. **/ static void g_process_change_dir(void) { const gchar *cwd = NULL; if (process_opts.mode != G_PM_FOREGROUND) { if (process_opts.cwd) cwd = process_opts.cwd; else if (process_opts.pidfile_dir) cwd = process_opts.pidfile_dir; if (!cwd) cwd = get_installation_path_for(SYSLOG_NG_PATH_PIDFILEDIR); if (cwd) if (chdir(cwd)) g_process_message("Error changing to directory=%s, errcode=%d", cwd, errno); } /* this check is here to avoid having to change directory early in the startup process */ if ((process_opts.core) && access(".", W_OK) < 0) { gchar buf[256]; if (!getcwd(buf, sizeof(buf))) strncpy(buf, "unable-to-query", sizeof(buf)); g_process_message("Unable to write to current directory, core dumps will not be generated; dir='%s', error='%s'", buf, g_strerror(errno)); } }
int main(int argc, char *argv[]) { const gchar *mode_string; GOptionContext *ctx; gint mode; GError *error = NULL; int result; control_name = get_installation_path_for(PATH_CONTROL_SOCKET); mode_string = get_mode(&argc, &argv); if (!mode_string) { usage(argv[0]); } ctx = NULL; for (mode = 0; modes[mode].mode; mode++) { if (strcmp(modes[mode].mode, mode_string) == 0) { ctx = g_option_context_new(mode_string); #if GLIB_CHECK_VERSION (2, 12, 0) g_option_context_set_summary(ctx, modes[mode].description); #endif g_option_context_add_main_entries(ctx, modes[mode].options, NULL); g_option_context_add_main_entries(ctx, slng_options, NULL); break; } } if (!ctx) { fprintf(stderr, "Unknown command\n"); usage(argv[0]); } if (!g_option_context_parse(ctx, &argc, &argv, &error)) { fprintf(stderr, "Error parsing command line arguments: %s\n", error ? error->message : "Invalid arguments"); g_clear_error(&error); g_option_context_free(ctx); return 1; } g_option_context_free(ctx); control_client = control_client_new(control_name); result = modes[mode].main(argc, argv, modes[mode].mode); control_client_free(control_client); return result; }
static const gchar * get_time_zone_basedir(void) { int i = 0; if (!time_zone_basedir) { for (i = 0; time_zone_path_list[i] != NULL && !is_file_directory(get_installation_path_for(time_zone_path_list[i])); i++) ; time_zone_basedir = time_zone_path_list[i]; } return time_zone_basedir; }
jstring __create_class_path(ClassLoader *self, JNIEnv *java_env, const gchar *class_path) { GString *g_class_path = g_string_new(get_installation_path_for(SYSLOG_NG_JAVA_MODULE_PATH)); jstring str_class_path = NULL; g_string_append(g_class_path, "/" SYSLOG_NG_JAR); if (class_path && (strlen(class_path) > 0)) { g_string_append_c(g_class_path, ':'); g_string_append(g_class_path, class_path); } str_class_path = CALL_JAVA_FUNCTION(java_env, NewStringUTF, g_class_path->str); g_string_free(g_class_path, TRUE); return str_class_path; }
int main(int argc, char *argv[]) { GError *error = NULL; int result; setlocale(LC_ALL, ""); control_name = get_installation_path_for(PATH_CONTROL_SOCKET); if (argc > 1 && _is_help(argv[1])) { print_usage(argv[0], modes); exit(0); } GString *cmdname_accumulator = g_string_new(argv[0]); CommandDescriptor *active_mode = find_active_mode(modes, &argc, argv, cmdname_accumulator); GOptionContext *ctx = setup_help_context(cmdname_accumulator->str, active_mode); g_string_free(cmdname_accumulator, TRUE); if (!ctx) { fprintf(stderr, "Unknown command\n"); print_usage(argv[0], modes); exit(1); } if (!g_option_context_parse(ctx, &argc, &argv, &error)) { fprintf(stderr, "Error parsing command line arguments: %s\n", error ? error->message : "Invalid arguments"); g_clear_error(&error); g_option_context_free(ctx); return 1; } control_client = control_client_new(control_name); result = active_mode->main(argc, argv, active_mode->mode, ctx); g_option_context_free(ctx); control_client_free(control_client); return result; }
/** * g_process_format_pidfile_name: * @buf: buffer to store the pidfile name * @buflen: size of @buf * * Format the pid file name according to the settings specified by the * process. **/ static const gchar * g_process_format_pidfile_name(gchar *buf, gsize buflen) { const gchar *pidfile = process_opts.pidfile; if (pidfile == NULL) { g_snprintf(buf, buflen, "%s/%s.pid", process_opts.pidfile_dir ? process_opts.pidfile_dir : get_installation_path_for(SYSLOG_NG_PATH_PIDFILEDIR), process_opts.name); pidfile = buf; } else if (pidfile[0] != '/') { /* complete path to pidfile not specified, assume it is a relative path to pidfile_dir */ g_snprintf(buf, buflen, "%s/%s", process_opts.pidfile_dir ? process_opts.pidfile_dir : get_installation_path_for( SYSLOG_NG_PATH_PIDFILEDIR), pidfile); pidfile = buf; } return pidfile; }
void cfg_set_global_paths(GlobalConfig *self) { gchar *include_path; cfg_args_set(self->lexer->globals, "syslog-ng-root", get_installation_path_for(SYSLOG_NG_PATH_PREFIX)); cfg_args_set(self->lexer->globals, "syslog-ng-data", get_installation_path_for(SYSLOG_NG_PATH_DATADIR)); cfg_args_set(self->lexer->globals, "syslog-ng-include", get_installation_path_for(SYSLOG_NG_PATH_CONFIG_INCLUDEDIR)); cfg_args_set(self->lexer->globals, "scl-root", get_installation_path_for(SYSLOG_NG_PATH_SCLDIR)); cfg_args_set(self->lexer->globals, "module-path", resolvedConfigurablePaths.initial_module_path); cfg_args_set(self->lexer->globals, "autoload-compiled-modules", "1"); include_path = g_strdup_printf("%s:%s", get_installation_path_for(SYSLOG_NG_PATH_SYSCONFDIR), get_installation_path_for(SYSLOG_NG_PATH_CONFIG_INCLUDEDIR)); cfg_args_set(self->lexer->globals, "include-path", include_path); g_free(include_path); }
void version(void) { if (!get_installer_version(&installer_version) || installer_version == NULL) { installer_version = SYSLOG_NG_VERSION; } printf(SYSLOG_NG_PACKAGE_NAME " " SYSLOG_NG_VERSION "\n" "Installer-Version: %s\n" "Revision: " SYSLOG_NG_SOURCE_REVISION "\n", installer_version); #if WITH_COMPILE_DATE printf("Compile-Date: " __DATE__ " " __TIME__ "\n"); #endif printf("Module-Directory: %s\n", get_installation_path_for(SYSLOG_NG_PATH_MODULEDIR)); printf("Module-Path: %s\n", resolvedConfigurablePaths.initial_module_path); printf("Available-Modules: "); plugin_list_modules(stdout, FALSE); printf("Enable-Debug: %s\n" "Enable-GProf: %s\n" "Enable-Memtrace: %s\n" "Enable-IPv6: %s\n" "Enable-Spoof-Source: %s\n" "Enable-TCP-Wrapper: %s\n" "Enable-Linux-Caps: %s\n", ON_OFF_STR(SYSLOG_NG_ENABLE_DEBUG), ON_OFF_STR(SYSLOG_NG_ENABLE_GPROF), ON_OFF_STR(SYSLOG_NG_ENABLE_MEMTRACE), ON_OFF_STR(SYSLOG_NG_ENABLE_IPV6), ON_OFF_STR(SYSLOG_NG_ENABLE_SPOOF_SOURCE), ON_OFF_STR(SYSLOG_NG_ENABLE_TCP_WRAPPER), ON_OFF_STR(SYSLOG_NG_ENABLE_LINUX_CAPS)); }
static const gchar * _get_xsddir_in_production(void) { return get_installation_path_for(SYSLOG_NG_PATH_XSDDIR); }