From b2b42d28f37f8553f9183b90715aa2cd511a7f7d Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Mon, 9 Apr 2018 19:23:41 +0900 Subject: [PATCH] xrdp: add OpenSSL version to --version While here, cleanup --help, --version, and when unknown option. --- common/ssl_calls.c | 15 ++++++++++++- common/ssl_calls.h | 2 ++ xrdp/xrdp.c | 53 +++++++++++++++++++++++++++++----------------- xrdp/xrdp.h | 4 ++++ 4 files changed, 54 insertions(+), 20 deletions(-) diff --git a/common/ssl_calls.c b/common/ssl_calls.c index f659a196..809ce966 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "os_calls.h" #include "arch.h" @@ -78,7 +79,7 @@ DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) return 0; } - if (p != NULL) + if (p != NULL) { BN_free(dh->p); dh->p = p; @@ -1064,3 +1065,15 @@ ssl_get_protocols_from_string(const char *str, long *ssl_protocols) return rv; } +/*****************************************************************************/ +const char +*get_openssl_version() +{ +#if OPENSSL_VERSION_NUMBER < 0x10100000L + return SSLeay_version(SSLEAY_VERSION); +#else + return OpenSSL_version(OPENSSL_VERSION); +#endif + +} + diff --git a/common/ssl_calls.h b/common/ssl_calls.h index dc60a23e..75b650e6 100644 --- a/common/ssl_calls.h +++ b/common/ssl_calls.h @@ -114,5 +114,7 @@ const char * ssl_get_cipher_name(const struct ssl_st *ssl); int ssl_get_protocols_from_string(const char *str, long *ssl_protocols); +const char * +get_openssl_version(); #endif diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 437bd825..6e87d91f 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -45,6 +45,31 @@ static long g_sync_param1 = 0; static long g_sync_param2 = 0; static long (*g_sync_func)(long param1, long param2); +/*****************************************************************************/ +void +print_version(void) +{ + g_writeln("xrdp %s", PACKAGE_VERSION); + g_writeln(" A Remote Desktop Protocol Server."); + g_writeln(" Copyright (C) 2004-2018 Jay Sorg, " + "Neutrino Labs, and all contributors."); + g_writeln(" See https://github.com/neutrinolabs/xrdp for more information."); + g_writeln("%s", ""); + g_writeln(" Compiled with %s", get_openssl_version()); +} + +/*****************************************************************************/ +void +print_help(void) +{ + g_writeln("Usage: xrdp [options]"); + g_writeln(" -h, --help show help"); + g_writeln(" -n, --nodaemon don't fork into background"); + g_writeln(" -k, --kill shut down xrdp"); + g_writeln(" -p, --port tcp listen port"); + g_writeln(" -f, --fork fork on new connection"); +} + /*****************************************************************************/ /* This function is used to run a function from the main thread. Sync_func is the function pointer that will run from main thread @@ -393,9 +418,12 @@ main(int argc, char **argv) if (xrdp_process_params(argc, argv, startup_params) != 0) { - g_writeln("Unknown Parameter"); - g_writeln("xrdp -h for help"); + print_version(); g_writeln("%s", ""); + print_help(); + g_writeln("%s", ""); + + g_writeln("Unknown option"); g_deinit(); g_exit(1); } @@ -405,30 +433,17 @@ main(int argc, char **argv) if (startup_params->help) { + print_version(); g_writeln("%s", ""); - 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("%s", ""); - g_writeln("Usage: xrdp [options]"); - g_writeln(" -h, --help show help"); - g_writeln(" -n, --nodaemon don't fork into background"); - g_writeln(" -k, --kill shut down xrdp"); - g_writeln(" -p, --port tcp listen port"); - g_writeln(" -f, --fork fork on new connection"); - g_writeln("%s", ""); + print_help(); + g_deinit(); g_exit(0); } if (startup_params->version) { - g_writeln("%s", ""); - 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("%s", ""); + print_version(); g_deinit(); g_exit(0); } diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 5201dada..65e5c4f6 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -49,6 +49,10 @@ tbus g_get_sync_event(void); void g_process_waiting_function(void); +void +print_version(void); +void +print_help(void); /* xrdp_cache.c */ struct xrdp_cache*