From: Kshitij Shah <zirconiu...@gmail.com> Date: Tue, May 5, 2009 at 5:02 PM Subject: Sound Redirection Patch To: xrdp-devel@lists.sourceforge.net, proj-u...@googlegroups.com
Hi Community, I have attached a patch for xrdp that will redirect sound with pulse audio by setting the client IP address as an environment variable. We have also got IP address to be displayed in the log. You will also need the script getIsLocal.sh (attached) to export the variable. The latest kiwi-ltsp-desc needs to be installed. I have tested it only on OpenSUSE 11.1. Developers can we merge these changes upstream ? We will be glad to make the necessary changes. Hope you find this useful. Bugs and Suggestions will be appreciated. Known bug: Sound breaks on session resume from another terminal. This patch has been made by the projURON team members. Regards, projURON
diff -ur xrdp-0.4.1/libxrdp/libxrdpinc.h xrdp_x/libxrdp/libxrdpinc.h --- xrdp-0.4.1/libxrdp/libxrdpinc.h 2009-03-24 11:39:42.000000000 +0530 +++ xrdp_x/libxrdp/libxrdpinc.h 2009-04-25 22:19:27.000000000 +0530 @@ -51,6 +51,7 @@ int keylayout; char username[256]; char password[256]; + char xrdp_client_ip[256]; char domain[256]; char program[256]; char directory[256]; diff -ur xrdp-0.4.1/libxrdp/xrdp_sec.c xrdp_x/libxrdp/xrdp_sec.c --- xrdp-0.4.1/libxrdp/xrdp_sec.c 2009-03-24 11:39:42.000000000 +0530 +++ xrdp_x/libxrdp/xrdp_sec.c 2009-04-25 22:21:07.000000000 +0530 @@ -367,7 +367,7 @@ { in_uint8s(s, 2); /* unknown */ in_uint16_le(s, len_ip); - unicode_in(s, len_ip - 2, tmpdata, 255); + unicode_in(s, len_ip - 2, self->rdp_layer->client_info.xrdp_client_ip, 255); in_uint16_le(s, len_dll); unicode_in(s, len_dll - 2, tmpdata, 255); in_uint32_le(s, tzone); /* len of timetone */ diff -ur xrdp-0.4.1/rdp/rdp.h xrdp_x/rdp/rdp.h --- xrdp-0.4.1/rdp/rdp.h 2009-03-24 11:39:42.000000000 +0530 +++ xrdp_x/rdp/rdp.h 2009-04-25 22:20:12.000000000 +0530 @@ -325,6 +325,7 @@ char port[256]; char username[256]; char password[256]; + char xrdp_client_ip[256]; char hostname[256]; char domain[256]; char program[256]; diff -ur xrdp-0.4.1/sesman/env.c xrdp_x/sesman/env.c --- xrdp-0.4.1/sesman/env.c 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/env.c 2009-04-25 22:30:25.000000000 +0530 @@ -60,7 +60,7 @@ /******************************************************************************/ int DEFAULT_CC -env_set_user(char* username, char* passwd_file, int display, char* auth_file) +env_set_user(char* username, char* passwd_file, int display, char* auth_file, char* clientip) { int error; int pw_uid; @@ -98,6 +98,7 @@ g_sprintf(text, ":%d.0", display); g_setenv("DISPLAY", text, 1); g_setenv("XAUTHORITY", auth_file, 1); + g_setenv("XRDP_CLIENT_IP", clientip, 1); if (passwd_file != 0) { if (0 == g_cfg->auth_file_path) diff -ur xrdp-0.4.1/sesman/env.h xrdp_x/sesman/env.h --- xrdp-0.4.1/sesman/env.h 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/env.h 2009-04-25 22:30:43.000000000 +0530 @@ -50,7 +50,7 @@ * */ int DEFAULT_CC -env_set_user(char* username, char* passwd_file, int display, char* auth_file); +env_set_user(char* username, char* passwd_file, int display, char* auth_file, char* clientip); #endif diff -ur xrdp-0.4.1/sesman/libscp/libscp_session.c xrdp_x/sesman/libscp/libscp_session.c --- xrdp-0.4.1/sesman/libscp/libscp_session.c 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/libscp/libscp_session.c 2009-04-25 22:28:30.000000000 +0530 @@ -207,6 +207,25 @@ return 0; } + +/*******************************************************************/ +int +scp_session_set_clientip(struct SCP_SESSION* s, char* str) +{ + if (0 == str) + { + log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_clientip: null clientip", __LINE__); + return 1; + } + s->xrdp_client_ip = g_strdup(str); + if (0 == s->xrdp_client_ip) + { + log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_clientip: strdup error", __LINE__); + return 1; + } + return 0; +} + /*******************************************************************/ int scp_session_set_wm(struct SCP_SESSION* s, char* str) diff -ur xrdp-0.4.1/sesman/libscp/libscp_session.h xrdp_x/sesman/libscp/libscp_session.h --- xrdp-0.4.1/sesman/libscp/libscp_session.h 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/libscp/libscp_session.h 2009-04-25 22:28:59.000000000 +0530 @@ -69,6 +69,9 @@ scp_session_set_password(struct SCP_SESSION* s, char* str); int +scp_session_set_clientip(struct SCP_SESSION* s, char* str); + +int scp_session_set_wm(struct SCP_SESSION* s, char* str); int diff -ur xrdp-0.4.1/sesman/libscp/libscp_types.h xrdp_x/sesman/libscp/libscp_types.h --- xrdp-0.4.1/sesman/libscp/libscp_types.h 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/libscp/libscp_types.h 2009-04-25 22:23:17.000000000 +0530 @@ -77,6 +77,7 @@ char locale[18]; char* username; char* password; + char* xrdp_client_ip; char* hostname; char* wm; tui8 addr_type; diff -ur xrdp-0.4.1/sesman/libscp/libscp_v0.c xrdp_x/sesman/libscp/libscp_v0.c --- xrdp-0.4.1/sesman/libscp/libscp_v0.c 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/libscp/libscp_v0.c 2009-04-25 22:22:45.000000000 +0530 @@ -251,6 +251,24 @@ return SCP_SERVER_STATE_INTERNAL_ERR; } + /* reading clientip */ + in_uint16_be(c->in_s, sz); + if (sz > sizeof (buf) || sz > size) + { + scp_session_destroy(session); + log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: size error", __LINE__); + return SCP_SERVER_STATE_SIZE_ERR; + } + size -= sz; + buf[sz]='\0'; + in_uint8a(c->in_s, buf, sz); + if (0 != scp_session_set_clientip(session, buf)) + { + scp_session_destroy(session); + log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting clientip", __LINE__); + return SCP_SERVER_STATE_INTERNAL_ERR; + } + /* reading wm */ in_uint16_be(c->in_s, sz); if (sz > sizeof (buf) || sz > size) diff -ur xrdp-0.4.1/sesman/scp_v0.c xrdp_x/sesman/scp_v0.c --- xrdp-0.4.1/sesman/scp_v0.c 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/scp_v0.c 2009-04-25 22:36:59.000000000 +0530 @@ -54,22 +54,23 @@ if (1 == access_login_allowed(s->username)) { log_message(&(g_cfg->log), LOG_LEVEL_INFO, "granted TS access to user %s", s->username); + log_message(&(g_cfg->log), LOG_LEVEL_INFO, "Client_Info #...@%s#", s->username, s->xrdp_client_ip); if (SCP_SESSION_TYPE_XVNC == s->type) { log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xvnc session..."); - display = session_start(s->width, s->height, s->bpp, s->layout, s->username, s->password, + display = session_start(s->width, s->height, s->bpp, s->layout, s->username, s->password, s->xrdp_client_ip, s->wm, data, SESMAN_SESSION_TYPE_XVNC); } else if (SCP_SESSION_TYPE_XRDP == s->type) { log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting X11rdp session..."); - display = session_start(s->width, s->height, s->bpp, s->layout, s->username, s->password, + display = session_start(s->width, s->height, s->bpp, s->layout, s->username, s->password, s->xrdp_client_ip, s->wm, data, SESMAN_SESSION_TYPE_XRDP); } else { log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xdmx session..."); - display = session_start(s->width, s->height, s->bpp, s->layout, s->username, s->password, + display = session_start(s->width, s->height, s->bpp, s->layout, s->username, s->password, s->xrdp_client_ip, s->wm, data, SESMAN_SESSION_TYPE_XDMX); } } diff -ur xrdp-0.4.1/sesman/scp_v1.c xrdp_x/sesman/scp_v1.c --- xrdp-0.4.1/sesman/scp_v1.c 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/scp_v1.c 2009-04-25 22:24:58.000000000 +0530 @@ -112,19 +112,19 @@ { log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xvnc session..."); display = session_start(s->width, s->height, s->bpp, s->layout, s->username, - s->password, s->wm, data, SESMAN_SESSION_TYPE_XVNC); + s->password, s->xrdp_client_ip, s->wm, data, SESMAN_SESSION_TYPE_XVNC); } else if (SCP_SESSION_TYPE_XRDP == s->type) { log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting X11rdp session..."); display = session_start(s->width, s->height, s->bpp, s->layout, s->username, - s->password, s->wm, data, SESMAN_SESSION_TYPE_XRDP); + s->password, s->xrdp_client_ip, s->wm, data, SESMAN_SESSION_TYPE_XRDP); } else { log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xdmx session..."); display = session_start(s->width, s->height, s->bpp, s->layout, s->username, - s->password, s->wm, data, SESMAN_SESSION_TYPE_XDMX); + s->password, s->xrdp_client_ip, s->wm, data, SESMAN_SESSION_TYPE_XDMX); } e = scp_v1s_connect_new_session(c, display); diff -ur xrdp-0.4.1/sesman/session.c xrdp_x/sesman/session.c --- xrdp-0.4.1/sesman/session.c 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/session.c 2009-04-25 22:29:27.000000000 +0530 @@ -474,7 +474,7 @@ /******************************************************************************/ int DEFAULT_CC session_start(int width, int height, int bpp, int layout, - char* username, char* password, + char* username, char* password, char* clientip, char* wm, long data, unsigned char type) { int display; @@ -621,7 +621,7 @@ } #endif - if (env_set_user(username, passwd_file, display, auth_file) != 0) + if (env_set_user(username, passwd_file, display, auth_file, clientip) != 0) { log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "error - set user failed"); g_exit(1); diff -ur xrdp-0.4.1/sesman/session.h xrdp_x/sesman/session.h --- xrdp-0.4.1/sesman/session.h 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/sesman/session.h 2009-04-25 22:26:04.000000000 +0530 @@ -107,7 +107,7 @@ */ int DEFAULT_CC session_start(int width, int height, int bpp, int layout, - char* username, char* password, + char* username, char* password, char* clientip, char* wm, long data, unsigned char type); /** diff -ur xrdp-0.4.1/xrdp/xrdp_mm.c xrdp_x/xrdp/xrdp_mm.c --- xrdp-0.4.1/xrdp/xrdp_mm.c 2009-03-24 11:39:58.000000000 +0530 +++ xrdp_x/xrdp/xrdp_mm.c 2009-04-25 22:18:30.000000000 +0530 @@ -256,6 +256,9 @@ index = g_strlen(password); out_uint16_be(s, index); out_uint8a(s, password, index); + index = g_strlen(self->wm->session->client_info->xrdp_client_ip); + out_uint16_be(s, index); + out_uint8a(s, self->wm->session->client_info->xrdp_client_ip, index); index = g_strlen(exec); out_uint16_be(s, index); out_uint8a(s, exec, index);
getIsLocal.sh
Description: Bourne shell script
------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________ xrdp-devel mailing list xrdp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xrdp-devel