-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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); | ||
|
@@ -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"; | ||
} | ||
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); | ||
|
@@ -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; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could easily be set via There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
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; | ||
|
||
|
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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 ;-)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).