Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept full path for DefaultWindowManager #1147

Merged
merged 6 commits into from Jun 19, 2018

Conversation

metalefty
Copy link
Member

Also,

  • make path of reconnectwm.sh configurable
  • improve documents

Solves #1143. Inspired by Fedora's patch[1].
[1] https://src.fedoraproject.org/cgit/rpms/xrdp.git/commit/xrdp-0.9.6-scripts-libexec.patch?id=02f845c1b8cea781313cf3e9efcd6d7d50341824

Copy link
Member

@speidy speidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine

sesman/config.c Outdated
@@ -530,6 +570,9 @@ config_dump(struct config_sesman *config)
void
config_free(struct config_sesman *cs)
{
g_free(cs->default_wm);
g_free(cs->reconnect_sh);
g_free(cs->auth_file_path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not supposed to be a part of this patch

sesman/config.c Outdated
{
g_strncpy(cf->default_wm, "startwm.sh", 11);
buf = (char *)g_malloc(1024, 0);
g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, g_cfg->default_wm);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is prone to buffer overflow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will alloc g_strlen(XRDP_CFG_PATH) + g_strlen(g_cfg->default_wm) + 2.

sesman/config.c Outdated
if (cf->reconnect_sh[0] != '/')
{
buf = (char *)g_malloc(1024, 0);
g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, g_cfg->reconnect_sh);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@@ -575,8 +575,7 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
}
/* if we're here something happened to g_execlp3
so we try running the default window manager */
g_sprintf(text, "%s/%s", XRDP_CFG_PATH, g_cfg->default_wm);
g_execlp3(text, g_cfg->default_wm, 0);
g_execlp3(g_cfg->default_wm, g_cfg->default_wm, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should change the log message properly

                log_message(LOG_LEVEL_DEBUG, "        argv[0] = %s",
                            text);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

sesman/config.c Outdated
/* if default_wm doesn't begin with '/', it's a relative path to XRDP_CFG_PATH */
if (cf->default_wm[0] != '/')
{
length = g_strlen(XRDP_CFG_PATH) + g_strlen(g_cfg->default_wm) + 2; /* '/' + '\0' */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using strlen on XRDP_CFG_PATH is redundant, you better use sizeof(XRDP_CFG_PATH)-1 since its already known at compile time.

\fBReconnectScript\fR=\fIfilename\fR
Full path or relative path if the script which executed when users reconnects
to the existing session. If the path is not a full path, it will be resolved as
relative path to \fI@xrdpconfdir@\fR.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it worth to note the default setting if empty / not specified

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

Copy link
Member

@speidy speidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix and merge.

sesman/config.c Outdated
{
g_strncpy(cf->default_wm, "startwm.sh", 11);
length = sizeof(XRDP_CFG_PATH) + g_strlen(g_cfg->reconnect_sh) + 1; /* '/' */
Copy link
Member

@speidy speidy Jun 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its better to mention the addition of the null terminator explicitly.

BTW, if we were using strlendirectly gcc would optimize it since it smart enough to detect its applied on a constant value. (but we are using our g_strlen wrapper :)

@metalefty metalefty merged commit dbee05d into neutrinolabs:devel Jun 19, 2018
@metalefty metalefty deleted the defaultwm-fullpath branch June 19, 2018 04:06
metalefty added a commit to metalefty/xrdp that referenced this pull request Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants