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

Add options to relocate session config files #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion misc/config.ini.debian.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ module_xsession_displayOffset_number=100
module_xsession_uselauncher_bool=true
module_xsession_startwm_string=@OGON_CFG_PATH@/ogonXsession
module_xsession_launcherexecutable_string=@OGON_SBIN_PATH@/ogon-backend-launcher
#module_xsession_xauthoritypath_string=/tmp
module_xsession_startvc_string=@OGON_BIN_PATH@/ogon-start-vc.sh
#module_xsession_tmppath_string=/tmp
#module_xsession_paconfpath_string=/etc/ogon/pulse

# Weston configuration
module_weston_modulename_string=Weston
Expand Down
49 changes: 48 additions & 1 deletion session-manager/common/session/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

#include "Session.h"

#include <ogon/build-config.h>

#define STD_PATH "/usr/local/bin:/usr/bin:/bin"

namespace ogon { namespace sessionmanager { namespace session {
Expand Down Expand Up @@ -266,7 +268,10 @@ namespace ogon { namespace sessionmanager { namespace session {
bool Session::generateEnvBlockAndModify(const std::string &clientName, const std::string &clientAddress) {

struct passwd* pwnam;
char envstr[256];
char envstr[MAX_PATH +1] = {0};
std::string defaultmodule;
std::string tmppath;
std::string pulseconfigpath;

if (mUsername.length() == 0) {
WLog_Print(logger_Session, WLOG_ERROR, "s %" PRIu32 ": no username!", mSessionID);
Expand Down Expand Up @@ -304,6 +309,32 @@ namespace ogon { namespace sessionmanager { namespace session {
return false;
}

configNS::PropertyManager *propertyManager = APP_CONTEXT.getPropertyManager();

std::string queryStringDefaultModule = std::string("module");

if (!propertyManager->getPropertyString(mSessionID, queryStringDefaultModule, defaultmodule)) {
defaultmodule = "xsession";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not to use module_string=xsession in the [global] part of the config file?
The name 'xsession' is just an arbitrary name chosen in the default config. That could be anything so having it hardcoded here requires that a backend with the name xsession is defined.

Copy link
Author

Choose a reason for hiding this comment

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

It's been some time since I tested this, but as far as I recall, I didn't succeed in adding a new backend by copying existing settings and replacing xsession with something else.
Just didn't work (and I didn't investigate any further).
The above hack "worked for me" and surely needs some cleanups from someone who knows more about how ogon works ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

wohoo. That was a quick reply. Just to make sure this was a workaround to get the name of the config uses that you can query the settings?

Copy link
Author

Choose a reason for hiding this comment

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

Glad to see some activity on this project again!
Yes, I needed to get some settings and I did so by using a hard-coded session string (not knowing how to get to it any other way).

WLog_Print(logger_Session, WLOG_DEBUG, "s %" PRIu32 ": defaultmodule = %s", mSessionID, defaultmodule.c_str());

std::string configBaseName = std::string("module.") + defaultmodule;
std::string queryStringTmpPath = configBaseName + std::string(".tmppath");

WLog_Print(logger_Session, WLOG_DEBUG, "s %" PRIu32 ": moduleconfigname = %s", mSessionID, mModuleConfigName.c_str());

if (!propertyManager->getPropertyString(mSessionID, queryStringTmpPath, tmppath)) {
tmppath="/tmp";
}
WLog_Print(logger_Session, WLOG_DEBUG, "s %" PRIu32 ": tmppath = %s", mSessionID, tmppath.c_str());

std::string queryStringPAPath = configBaseName + std::string(".paconfpath");

if (!propertyManager->getPropertyString(mSessionID, queryStringPAPath, pulseconfigpath)) {
pulseconfigpath = std::string(OGON_CFG_PATH) + std::string("/pulse");
}
WLog_Print(logger_Session, WLOG_DEBUG, "s %" PRIu32 ": pulseaudio config path = %s", mSessionID, pulseconfigpath.c_str());

sprintf_s(envstr, sizeof(envstr), "%" PRIu32 "", mSessionID);
if (!SetEnvironmentVariableEBA(&mpEnvBlock, "OGON_SID", envstr)) {
WLog_Print(logger_Session, WLOG_ERROR, "s %" PRIu32 ": failed to set OGON_SID in the environment block", mSessionID);
Expand All @@ -324,6 +355,22 @@ namespace ogon { namespace sessionmanager { namespace session {
}
}

if (!SetEnvironmentVariableEBA(&mpEnvBlock, "PULSE_CONFIG_PATH", pulseconfigpath.c_str())) {
WLog_Print(logger_Session, WLOG_ERROR, "s %" PRIu32 ": failed to set PULSE_CONFIG_PATH in the environment block", mSessionID);
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Same here: code "worked for me" - cleanups by someone more familiar with ogon are welcome.
However I think, there may have been a difference between the session environment and the environment used for virtual channels scripts ... but I'm not sure about this (last tests were half a year ago).


sprintf_s(envstr, sizeof(envstr), "%s/.rdpsnd-%" PRIu32 "", tmppath.c_str(), mSessionID);
if (!SetEnvironmentVariableEBA(&mpEnvBlock, "PULSE_RUNTIME_PATH", envstr)) {
WLog_Print(logger_Session, WLOG_ERROR, "s %" PRIu32 ": failed to set PULSE_RUNTIME_PATH in the environment block", mSessionID);
return false;
}

if (!SetEnvironmentVariableEBA(&mpEnvBlock, "PULSE_STATE_PATH", envstr)) {
WLog_Print(logger_Session, WLOG_ERROR, "s %" PRIu32 ": failed to set PULSE_STATE_PATH in the environment block", mSessionID);
return false;
}

mUserUID = pwnam->pw_uid;
mGroupUID = pwnam->pw_gid;

Expand Down
2 changes: 1 addition & 1 deletion session-manager/module/X11/x11_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static char *x11_rds_module_start(RDS_MODULE_COMMON *module) {
}

if (getPropertyStringWrapper(module->baseConfigPath, &gConfig,
module->sessionId, "xauthoritypath", buf, sizeof(buf))) {
module->sessionId, "tmppath", buf, sizeof(buf))) {
WLog_Print(gModuleLog, WLOG_DEBUG, "config: xAuthorityPath = %s", buf);
sprintf_s(xauthFileName, sizeof(xauthFileName), "%s/.Xauthority.ogon", buf);
} else {
Expand Down