Replies: 10 comments 12 replies
-
Excuse the brief reply, as I've got limited time this week. Yes you can do this, but it will only apply to the session creation. On a reconnect the environment variable will be out-of-date, so not useful - environment variables can't be changed for a whole session once set. For that reason we probably wouldn't put this in the main product. If you want to do it, the ip address is part of the HTH |
Beta Was this translation helpful? Give feedback.
-
Hi Matt, it would be great to get it env_names/env_values -> like g_setenv("REMOTE_CLIENT_IP", connection_description, 1); as we got it working in an older version ... sesman/env.c
Thank you. |
Beta Was this translation helpful? Give feedback.
-
I don't have access to any test facilities this week. Here's an unofficial patch which might do what you want. All I can say is it compiles. I built it on v0.9.19 but it should work on most v0.9.x releases. --- a/sesman/session.c
+++ b/sesman/session.c
@@ -587,6 +587,12 @@ session_start_fork(tbus data, tui8 type, struct SCP_SESSION *s)
}
else if (window_manager_pid == 0)
{
+ if (s->connection_description != NULL)
+ {
+ list_add_item(g_cfg->env_names, (tintptr) g_strdup("REMOTE_CLIENT_IP"));
+ list_add_item(g_cfg->env_names, (tintptr) g_strdup(s->connection_description));
+ }
+
wait_for_xserver(display);
env_set_user(s->username,
0, |
Beta Was this translation helpful? Give feedback.
-
Oops - obvious problem with the above patch. The second Here's an improved version that actually works, and just adds the client IP to the environment variable rather than all the other stuff in teh connection description. --- a/sesman/session.c
+++ b/sesman/session.c
@@ -587,6 +587,16 @@ session_start_fork(tbus data, tui8 type, struct SCP_SESSION *s)
}
else if (window_manager_pid == 0)
{
+ if (s->connection_description != NULL)
+ {
+ char ip[64];
+ g_get_ip_from_description(s->connection_description,
+ ip, sizeof(ip));
+ list_add_item(g_cfg->env_names,
+ (tintptr) g_strdup("REMOTE_CLIENT_IP"));
+ list_add_item(g_cfg->env_values, (tintptr) g_strdup(ip));
+ }
+
wait_for_xserver(display);
env_set_user(s->username,
0, I think the correct way to actually meet a requirement for getting the client IP is to add a facility for a session to inquire about the characteristics of the currently connected client. That way you can get the details of the currently client (if any), rather than simply the client which initiated the connection. This is also related to #392, which is currently unimplemented. It shouldn't be too hard to get that done against devel, actually. I'll have a quick look. |
Beta Was this translation helpful? Give feedback.
-
Hi, great I got an fail - do I miss something?
|
Beta Was this translation helpful? Give feedback.
-
You are right I applied the changes as patch an made a fresh install -> build was ok now ... but sesman triggers an error ...
thank you !!! |
Beta Was this translation helpful? Give feedback.
-
Suggest you get things working without the parch first, then apply the patch. Preferably, use the one in this post. I can't see anything in the patch itself which should break your window manager. If you're doing a clean build from source, make sure xrdp isn't installed from a package. Check you're not logged in at the console, etc. |
Beta Was this translation helpful? Give feedback.
-
Hi, I've ran into simillar issue. I have Windows 10 clients which connect through RDP to Ubuntu XRDP server. Problem is that these clients need to use barcode scanner. We have out own program that registers this scanner through COM port (rs232) and passes it to information system. This much worked on older settup (Thinlinc client). The issue is, that now through XRDP I need to know IP of the client, so I can register the scanner and thats a challenge with xrdp. The error I've been thrown: To be clear, Iam running 0.9.19 and my clients are never reconnecting, when they disconned, system kills all of their processes, terminating the session. When they connect again, it creates a new session for them. Do you have any idea how to resolve this? |
Beta Was this translation helpful? Give feedback.
-
Hi @HottuDoku I'm a bit confused by your post. The commit which breaks the above patch is 79bec81. This isn't part of v0.9.19 - it's still in the development stream. Are you asking for a patch which works with the development stream, or am I misunderstanding exactly what you are asking? Thanks. |
Beta Was this translation helpful? Give feedback.
-
Here's an updated patch against 682ca95:- diff --git a/sesman/session.c b/sesman/session.c
index 1ad30baf..20effc19 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -607,6 +607,13 @@ session_start(long data,
}
else if (window_manager_pid == 0)
{
+ if (s->ip_addr[0] != '\0')
+ {
+ list_add_item(g_cfg->env_names,
+ (tintptr) g_strdup("REMOTE_CLIENT_IP"));
+ list_add_item(g_cfg->env_values, (tintptr) s->ip_addr);
+ }
+
wait_for_xserver(display);
env_set_user(s->username,
0, I haven't tested it yet. Please let me know if it does what you want @HottuDoku |
Beta Was this translation helpful? Give feedback.
-
Just wondering if its possible to get the connection ip address into env_set_user
I tried it like this but no success ...
env_set_user(const char *username, char **passwd_file, int display, char *connection_description,
const struct list *env_names, const struct list *env_values)
thx
Beta Was this translation helpful? Give feedback.
All reactions