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>
(cherry picked from commit 81d495430d)
r14.0.x
Slávek Banko 3 years ago
parent cfacbca50c
commit a2f2ff6679
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)
{ {
@ -617,19 +622,19 @@ int runDCOP( QCStringList args, UserList users, Session session,
iceFile = TQString("%1/.%2").arg(it.data()).arg(iceFileBase); iceFile = TQString("%1/.%2").arg(it.data()).arg(iceFileBase);
fi.setFile(iceFile); fi.setFile(iceFile);
} }
if( iceFile.isEmpty() ) if (iceFile.isEmpty())
{ {
cerr_ << "WARNING: Cannot determine home directory for user " cerr_ << "WARNING: Cannot determine home directory for user "
<< it.key() << "!" << endl << it.key() << "!" << endl
<< "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl << "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl
<< "calling dcop." << endl; << "calling dcop." << endl;
} }
else if( fi.exists() ) else if (fi.exists())
{ {
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;
} }
else else
@ -642,8 +647,10 @@ 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