dcopclient: Use default path for XDG_RUNTIME_DIR if the variable is not set.

This resolves issue TDE/tdebase#241.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/146/head
Slávek Banko 3 years ago
parent 2b3ea27bdf
commit 81d495430d
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -590,17 +590,22 @@ int runDCOP( QCStringList args, UserList users, Session session,
} }
} }
if( users.count() > 1 || ( users.count() == 1 && if ((users.count() > 1) || ((users.count() == 1) &&
( getenv( "ICEAUTHORITY" ) == 0 || getenv( "DISPLAY" ) == 0 ) ) ) ((getenv("ICEAUTHORITY") == 0) || (getenv("DISPLAY") == 0))))
{ {
// Check for ICE authority file and if the file can be read by us // Check for ICE authority file and if the file can be read by us
TQString iceFileBase = "ICEauthority"; TQString iceFileBase = "ICEauthority";
TQString iceFile; TQString iceFile;
TQFileInfo fi; TQFileInfo fi;
if (getenv("XDG_RUNTIME_DIR") != 0 ) TQString xdgRuntimeDir = TQString::fromLocal8Bit(getenv("XDG_RUNTIME_DIR"));
if (xdgRuntimeDir.isEmpty())
{
xdgRuntimeDir = "/run/user/<uid>";
}
if (!xdgRuntimeDir.isEmpty())
{ {
TQFileInfo xdgRuntime(getenv("XDG_RUNTIME_DIR")); TQFileInfo xdgRuntime(xdgRuntimeDir);
passwd* pstruct = getpwnam(it.key().local8Bit()); passwd* pstruct = getpwnam(it.key().local8Bit());
if (pstruct) if (pstruct)
{ {
@ -628,7 +633,7 @@ int runDCOP( QCStringList args, UserList users, Session session,
{ {
if (fi.isReadable()) if (fi.isReadable())
{ {
char *envStr = strdup( ( "ICEAUTHORITY=" + iceFile ).ascii() ); char *envStr = strdup(("ICEAUTHORITY=" + iceFile).local8Bit());
putenv(envStr); putenv(envStr);
//cerr_ << "ice: " << envStr << endl; //cerr_ << "ice: " << envStr << endl;
} }
@ -643,7 +648,9 @@ int runDCOP( QCStringList args, UserList users, Session session,
else else
{ {
if (users.count() > 1) if (users.count() > 1)
{
continue; continue;
}
else else
{ {
cerr_ << "WARNING: Cannot find ICE authority file " cerr_ << "WARNING: Cannot find ICE authority file "

Loading…
Cancel
Save