From 19fa26a27ebf9e1294a7b242ec34d089ee4580a2 Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Wed, 30 May 2018 03:48:04 +0900 Subject: [PATCH] sesman: don't print config in reader function reader function should just read. Add config_dump function to print read config. --- sesman/config.c | 178 ++++++++++++++++++++++++++++-------------------- sesman/config.h | 8 +++ 2 files changed, 112 insertions(+), 74 deletions(-) diff --git a/sesman/config.c b/sesman/config.c index 1fedbf30..9eb3b07a 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -171,15 +171,6 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, g_strncpy(cf->default_wm, "startwm.sh", 11); } - /* showing read config */ - g_printf("sesman config:\r\n"); - g_printf("\tListenAddress: %s\r\n", cf->listen_address); - g_printf("\tListenPort: %s\r\n", cf->listen_port); - g_printf("\tEnableUserWindowManager: %i\r\n", cf->enable_user_wm); - g_printf("\tUserWindowManager: %s\r\n", cf->user_wm); - g_printf("\tDefaultWindowManager: %s\r\n", cf->default_wm); - g_printf("\tAuthFilePath: %s\r\n", ((cf->auth_file_path) ? (cf->auth_file_path) : ("disabled"))); - return 0; } @@ -241,30 +232,6 @@ config_read_security(int file, struct config_security *sc, } } - /* printing security config */ - g_printf("security configuration:\r\n"); - g_printf("\tAllowRootLogin: %i\r\n", sc->allow_root); - g_printf("\tMaxLoginRetry: %i\r\n", sc->login_retry); - g_printf("\tAlwaysGroupCheck: %i\r\n", sc->ts_always_group_check); - - if (sc->ts_users_enable) - { - g_printf("\tTSUsersGroup: %i\r\n", sc->ts_users); - } - else - { - g_printf("\tNo TSUsersGroup defined\r\n"); - } - - if (sc->ts_admins_enable) - { - g_printf("\tTSAdminsGroup: %i\r\n", sc->ts_admins); - } - else - { - g_printf("\tNo TSAdminsGroup defined\r\n"); - } - return 0; } @@ -352,15 +319,6 @@ config_read_sessions(int file, struct config_sessions *se, struct list *param_n, } } - /* printing session config */ - g_printf("session configuration:\r\n"); - g_printf("\tMaxSessions: %i\r\n", se->max_sessions); - g_printf("\tX11DisplayOffset: %i\r\n", se->x11_display_offset); - g_printf("\tKillDisconnected: %i\r\n", se->kill_disconnected); - g_printf("\tIdleTimeLimit: %i\r\n", se->max_idle_time); - g_printf("\tDisconnectedTimeLimit: %i\r\n", se->max_disc_time); - g_printf("\tPolicy: %i\r\n", se->policy); - return 0; } @@ -384,14 +342,6 @@ config_read_rdp_params(int file, struct config_sesman *cs, struct list *param_n, list_add_item(cs->rdp_params, (long)g_strdup((char *)list_get_item(param_v, i))); } - /* printing X11rdp parameters */ - g_printf("X11rdp parameters:\r\n"); - - for (i = 0; i < cs->rdp_params->count; i++) - { - g_printf("\tParameter %02d %s\r\n", i, (char *)list_get_item(cs->rdp_params, i)); - } - return 0; } @@ -416,15 +366,6 @@ config_read_xorg_params(int file, struct config_sesman *cs, (long) g_strdup((char *) list_get_item(param_v, i))); } - /* printing Xorg parameters */ - g_printf("Xorg parameters:\r\n"); - - for (i = 0; i < cs->xorg_params->count; i++) - { - g_printf("\tParameter %02d %s\r\n", - i, (char *) list_get_item(cs->xorg_params, i)); - } - return 0; } @@ -448,14 +389,6 @@ config_read_vnc_params(int file, struct config_sesman *cs, struct list *param_n, list_add_item(cs->vnc_params, (long)g_strdup((char *)list_get_item(param_v, i))); } - /* printing Xvnc parameters */ - g_printf("Xvnc parameters:\r\n"); - - for (i = 0; i < cs->vnc_params->count; i++) - { - g_printf("\tParameter %02d %s\r\n", i, (char *)list_get_item(cs->vnc_params, i)); - } - return 0; } @@ -484,17 +417,114 @@ config_read_session_variables(int file, struct config_sesman *cs, (tintptr) g_strdup((char *) list_get_item(param_v, i))); } - /* printing session variables */ - g_writeln("%s parameters:", SESMAN_CFG_SESSION_VARIABLES); + return 0; +} - for (i = 0; i < cs->env_names->count; i++) +void +config_dump(struct config_sesman *config) +{ + int i; + struct config_sessions *se; + struct config_security *sc; + se = &(config->sess); + sc = &(config->sec); + + /* Global sesman configuration */ + g_writeln("Global configuration:"); + g_writeln(" ListenAddress: %s", config->listen_address); + g_writeln(" ListenPort: %s", config->listen_port); + g_writeln(" EnableUserWindowManager: %d", config->enable_user_wm); + g_writeln(" UserWindowManager: %s", config->user_wm); + g_writeln(" DefaultWindowManager: %s", config->default_wm); + g_writeln(" AuthFilePath: %s", + ((config->auth_file_path) ? (config->auth_file_path) : ("disabled"))); + + /* Session configuration */ + g_writeln("Session configuration:"); + g_writeln(" MaxSessions: %d", se->max_sessions); + g_writeln(" X11DisplayOffset: %d", se->x11_display_offset); + g_writeln(" KillDisconnected: %d", se->kill_disconnected); + g_writeln(" IdleTimeLimit: %d", se->max_idle_time); + g_writeln(" DisconnectedTimeLimit: %d", se->max_disc_time); + g_writeln(" Policy: %d", se->policy); + + /* Security configuration */ + g_writeln("Security configuration:"); + g_writeln(" AllowRootLogin: %d", sc->allow_root); + g_writeln(" MaxLoginRetry: %d", sc->login_retry); + g_writeln(" AlwaysGroupCheck: %d", sc->ts_always_group_check); + + g_printf( " TSUsersGroup: "); + if (sc->ts_users_enable) { - g_writeln(" Parameter %02d %s=%s", i, - (char *) list_get_item(cs->env_names, i), - (char *) list_get_item(cs->env_values, i)); + g_printf("%d", sc->ts_users); + } + else + { + g_printf("(not defined)"); + } + g_writeln("%s", ""); + + g_printf( " TSAdminsGroup: "); + if (sc->ts_admins_enable) + { + g_printf("%d", sc->ts_admins); + } + else + { + g_printf("(not defined)"); + } + g_writeln("%s", ""); + + + /* Xorg */ + if (config->xorg_params->count) + { + g_writeln("Xorg parameters:"); } - return 0; + for (i = 0; i < config->xorg_params->count; i++) + { + g_writeln(" Parameter %02d %s", + i, (char *) list_get_item(config->xorg_params, i)); + } + + /* Xvnc */ + if (config->vnc_params->count) + { + g_writeln("Xvnc parameters:"); + } + + for (i = 0; i < config->vnc_params->count; i++) + { + g_writeln(" Parameter %02d %s", + i, (char *)list_get_item(config->vnc_params, i)); + } + + /* X11rdp */ + if (config->rdp_params->count) + { + g_writeln("X11rdp parameters:"); + } + + for (i = 0; i < config->rdp_params->count; i++) + { + g_writeln(" Parameter %02d %s", + i, (char *)list_get_item(config->rdp_params, i)); + } + + /* SessionVariables */ + if (config->env_names->count) + { + g_writeln("%s parameters:", SESMAN_CFG_SESSION_VARIABLES); + } + + for (i = 0; i < config->env_names->count; i++) + { + g_writeln(" Parameter %02d %s=%s", + i, (char *) list_get_item(config->env_names, i), + (char *) list_get_item(config->env_values, i)); + } } void diff --git a/sesman/config.h b/sesman/config.h index ef188715..c7cb50fd 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -349,6 +349,14 @@ config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n, int config_read_session_variables(int file, struct config_sesman *cs, struct list *param_n, struct list *param_v); +/** + * + * @brief Dumps configuration + * @param pointer to a config_sesman struct + * + */ +void +config_dump(struct config_sesman *config); void config_free(struct config_sesman *cs);