diff options
author | Koichiro IWAO <meta@vmeta.jp> | 2015-03-10 20:15:48 +0900 |
---|---|---|
committer | Koichiro IWAO <meta@vmeta.jp> | 2015-03-10 23:10:00 +0900 |
commit | ba2237a3c48d142f435b592c1d45d23253096469 (patch) | |
tree | 8fdeec33251b778aadd29205f88de83b243cc38a /xrdp | |
parent | c3164eac76af63d71cdcf8d0d8cf63673f1e244b (diff) | |
download | xrdp-proprietary-ba2237a3c48d142f435b592c1d45d23253096469.tar.gz xrdp-proprietary-ba2237a3c48d142f435b592c1d45d23253096469.zip |
xrdp: fix -h -v option if xrdp.ini is invalid
- log_start should be called after help and version
- Fixes neutrinolabs/xrdp#33.
Diffstat (limited to 'xrdp')
-rw-r--r-- | xrdp/xrdp.c | 96 |
1 files changed, 49 insertions, 47 deletions
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index a80687b1..24953c2d 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -319,7 +319,6 @@ main(int argc, char **argv) test = 1; host_be = !((int)(*(unsigned char *)(&test))); #if defined(B_ENDIAN) - if (!host_be) #endif #if defined(L_ENDIAN) @@ -357,6 +356,51 @@ main(int argc, char **argv) g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH); + startup_params = (struct xrdp_startup_params *) + g_malloc(sizeof(struct xrdp_startup_params), 1); + + if (xrdp_process_params(argc, argv, startup_params) != 0) + { + g_writeln("Unknown Parameter"); + g_writeln("xrdp -h for help"); + g_writeln(""); + g_deinit(); + g_exit(0); + } + + g_snprintf(pid_file, 255, "%s/xrdp.pid", XRDP_PID_PATH); + no_daemon = 0; + + if (startup_params->help) + { + g_writeln(""); + g_writeln("xrdp: A Remote Desktop Protocol server."); + g_writeln("Copyright (C) Jay Sorg 2004-2014"); + g_writeln("See http://www.xrdp.org for more information."); + g_writeln(""); + g_writeln("Usage: xrdp [options]"); + g_writeln(" --help: show help"); + g_writeln(" --nodaemon: don't fork into background"); + g_writeln(" --kill: shut down xrdp"); + g_writeln(" --port: tcp listen port"); + g_writeln(" --fork: fork on new connection"); + g_writeln(""); + g_deinit(); + g_exit(0); + } + + if (startup_params->version) + { + g_writeln(""); + g_writeln("xrdp: A Remote Desktop Protocol server."); + g_writeln("Copyright (C) Jay Sorg 2004-2014"); + g_writeln("See http://www.xrdp.org for more information."); + g_writeln("Version %s", PACKAGE_VERSION); + g_writeln(""); + g_deinit(); + g_exit(0); + } + /* starting logging subsystem */ error = log_start(cfg_file, "XRDP"); @@ -380,21 +424,16 @@ main(int argc, char **argv) g_exit(1); } - startup_params = (struct xrdp_startup_params *) - g_malloc(sizeof(struct xrdp_startup_params), 1); - if (xrdp_process_params(argc, argv, startup_params) != 0) + + if (g_file_exist(pid_file)) /* xrdp.pid */ { - g_writeln("Unknown Parameter"); - g_writeln("xrdp -h for help"); - g_writeln(""); + g_writeln("It looks like xrdp is allready running,"); + g_writeln("if not delete the xrdp.pid file and try again"); g_deinit(); g_exit(0); } - g_snprintf(pid_file, 255, "%s/xrdp.pid", XRDP_PID_PATH); - no_daemon = 0; - if (startup_params->kill) { g_writeln("stopping xrdp"); @@ -435,43 +474,6 @@ main(int argc, char **argv) no_daemon = 1; } - if (startup_params->help) - { - g_writeln(""); - g_writeln("xrdp: A Remote Desktop Protocol server."); - g_writeln("Copyright (C) Jay Sorg 2004-2014"); - g_writeln("See http://www.xrdp.org for more information."); - g_writeln(""); - g_writeln("Usage: xrdp [options]"); - g_writeln(" --help: show help"); - g_writeln(" --nodaemon: don't fork into background"); - g_writeln(" --kill: shut down xrdp"); - g_writeln(" --port: tcp listen port"); - g_writeln(" --fork: fork on new connection"); - g_writeln(""); - g_deinit(); - g_exit(0); - } - - if (startup_params->version) - { - g_writeln(""); - g_writeln("xrdp: A Remote Desktop Protocol server."); - g_writeln("Copyright (C) Jay Sorg 2004-2014"); - g_writeln("See http://www.xrdp.org for more information."); - g_writeln("Version %s", PACKAGE_VERSION); - g_writeln(""); - g_deinit(); - g_exit(0); - } - - if (g_file_exist(pid_file)) /* xrdp.pid */ - { - g_writeln("It looks like xrdp is allready running,"); - g_writeln("if not delete the xrdp.pid file and try again"); - g_deinit(); - g_exit(0); - } if (!no_daemon) { |