diff options
author | ilsimo <ilsimo> | 2007-03-25 21:20:20 +0000 |
---|---|---|
committer | ilsimo <ilsimo> | 2007-03-25 21:20:20 +0000 |
commit | 6cbc09be53e8ee7c35cd3a281360412361ffc6ef (patch) | |
tree | 180953811c0d55e9e087660508485e989d59264d | |
parent | 5d29a7127bf08027d7c4b1f226505e2ee854fd3b (diff) | |
download | xrdp-proprietary-6cbc09be53e8ee7c35cd3a281360412361ffc6ef.tar.gz xrdp-proprietary-6cbc09be53e8ee7c35cd3a281360412361ffc6ef.zip |
added ListenAddress configuration option
-rw-r--r-- | docs/man/sesman.ini.5 | 7 | ||||
-rw-r--r-- | sesman/config.c | 14 | ||||
-rw-r--r-- | sesman/config.h | 8 | ||||
-rw-r--r-- | sesman/sesman.c | 2 | ||||
-rw-r--r-- | sesman/tcp.c | 23 | ||||
-rw-r--r-- | sesman/tcp.h | 20 |
6 files changed, 64 insertions, 10 deletions
diff --git a/docs/man/sesman.ini.5 b/docs/man/sesman.ini.5 index c15c3c61..e6fd0ada 100644 --- a/docs/man/sesman.ini.5 +++ b/docs/man/sesman.ini.5 @@ -37,6 +37,11 @@ The options to be specified in the \fB[globals]\fR section are the following: .br .TP +\fBListenAddress\fR=\fIip address\fR +Specifies sesman listening address. Default is 0.0.0.0 (all interfaces) +.br + +.TP \fBListenPort\fR=\fIport number\fR Specifies sesman listening port. Default is 3350 .br @@ -165,6 +170,8 @@ This is an example \fBsesman.ini\fR: [Globals] .br +ListenAddress=127.0.0.1 +.br ListenPort=3350 .br EnableUserWindowManager=1 diff --git a/sesman/config.c b/sesman/config.c index 4567e677..1b3bc4ab 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -22,7 +22,7 @@ * @file config.c * @brief User authentication code * @author Simone Fedele @< simo [at] esseemme [dot] org @> - * + * */ #include "arch.h" @@ -107,6 +107,7 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n, list_clear(param_n); /* resetting the struct */ + cf->listen_address[0] = '\0'; cf->listen_port[0] = '\0'; cf->enable_user_wm = 0; cf->user_wm[0] = '\0'; @@ -132,9 +133,17 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n, { g_strncpy(cf->listen_port, (char*)list_get_item(param_v, i), 15); } + else if (0 == g_strcasecmp(buf, SESMAN_CFG_ADDRESS)) + { + g_strncpy(cf->listen_address, (char*)list_get_item(param_v, i), 31); + } } /* checking for missing required parameters */ + if ('\0' == cf->listen_address[0]) + { + g_strncpy(cf->listen_address, "0.0.0.0", 8); + } if ('\0' == cf->listen_port[0]) { g_strncpy(cf->listen_port, "3350", 5); @@ -150,6 +159,7 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n, /* 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); @@ -302,7 +312,7 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n, se->max_idle_time=0; se->max_disc_time=0; se->kill_disconnected=0; - + file_read_section(file, SESMAN_CFG_SESSIONS, param_n, param_v); for (i = 0; i < param_n->count; i++) { diff --git a/sesman/config.h b/sesman/config.h index c1eb4527..3ecc345a 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -22,7 +22,7 @@ * @file config.h * @brief User authentication definitions * @author Simone Fedele @< simo [at] esseemme [dot] org @> - * + * */ #ifndef CONFIG_H @@ -44,6 +44,7 @@ #define SESMAN_CFG_GLOBALS "Globals" #define SESMAN_CFG_DEFWM "DefaultWindowManager" +#define SESMAN_CFG_ADDRESS "ListenAddress" #define SESMAN_CFG_PORT "ListenPort" #define SESMAN_CFG_ENABLE_USERWM "EnableUserWindowManager" #define SESMAN_CFG_USERWM "UserWindowManager" @@ -142,6 +143,11 @@ struct config_sessions struct config_sesman { /** + * @var listen_address + * @brief Listening address + */ + char listen_address[32]; + /** * @var listen_port * @brief Listening port */ diff --git a/sesman/sesman.c b/sesman/sesman.c index b3f83f9c..b760a727 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -50,7 +50,7 @@ sesman_main_loop(void) log_message(LOG_LEVEL_INFO, "listening..."); g_sck = g_tcp_socket(); g_tcp_set_non_blocking(g_sck); - error = g_tcp_bind(g_sck, g_cfg.listen_port); + error = tcp_bind(g_sck, g_cfg.listen_address, g_cfg.listen_port); if (error == 0) { error = g_tcp_listen(g_sck); diff --git a/sesman/tcp.c b/sesman/tcp.c index 36ea4670..e51fbdf9 100644 --- a/sesman/tcp.c +++ b/sesman/tcp.c @@ -21,12 +21,18 @@ * * @file tcp.c * @brief Tcp stream funcions - * @author Jay Sorg - * + * @author Jay Sorg, Simone Fedele + * */ #include "sesman.h" +#include <netinet/in.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <stdlib.h> +#include <string.h> + /*****************************************************************************/ int DEFAULT_CC tcp_force_recv(int sck, char* data, int len) @@ -124,3 +130,16 @@ tcp_force_send(int sck, char* data, int len) return 0; } + +/*****************************************************************************/ +int DEFAULT_CC +tcp_bind(int sck, char* addr, char* port) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons(atoi(port)); + s.sin_addr.s_addr = inet_addr(addr); + return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} diff --git a/sesman/tcp.h b/sesman/tcp.h index 57f9716d..e8fee60b 100644 --- a/sesman/tcp.h +++ b/sesman/tcp.h @@ -18,10 +18,10 @@ */ /** - * + * * @file tcp.h * @brief Tcp stream functions declarations - * @author Jay Sorg + * @author Jay Sorg, Simone Fedele * */ @@ -35,7 +35,7 @@ * @param data Data buffer * @param len Data buffer size * @return 0 on success, 1 on error - * + * */ int DEFAULT_CC tcp_force_recv(int sck, char* data, int len); @@ -47,9 +47,21 @@ tcp_force_recv(int sck, char* data, int len); * @param data Data buffer * @param len Data buffer size * @return 0 on success, 1 on error - * + * */ int DEFAULT_CC tcp_force_send(int sck, char* data, int len); +/** + * + * @brief Binds the listening socket + * @param sck Listening socket + * @param addr Listening address + * @param port Listening port + * @return 0 on success, -1 on error + * + */ +int DEFAULT_CC +tcp_bind(int sck, char* addr, char* port); + #endif |