summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2021-11-05 16:41:06 +0100
committerSlávek Banko <slavek.banko@axis.cz>2021-11-08 09:33:26 +0100
commita2f2ff667964cda492112448560c4684f062a932 (patch)
tree4bbc6b4587f414ee05c3e2c280e28585eb8d8bb0
parentcfacbca50cec3064cdaaa9af3226fba597ce40c1 (diff)
downloadtdelibs-a2f2ff667964cda492112448560c4684f062a932.tar.gz
tdelibs-a2f2ff667964cda492112448560c4684f062a932.zip
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 81d495430ddcab805997c3945c195d2844bc1eaa)
-rw-r--r--dcop/client/dcop.cpp107
1 files changed, 57 insertions, 50 deletions
diff --git a/dcop/client/dcop.cpp b/dcop/client/dcop.cpp
index 53acbd1c7..a07f6a41a 100644
--- a/dcop/client/dcop.cpp
+++ b/dcop/client/dcop.cpp
@@ -590,69 +590,76 @@ int runDCOP( QCStringList args, UserList users, Session session,
}
}
- if( users.count() > 1 || ( users.count() == 1 &&
- ( getenv( "ICEAUTHORITY" ) == 0 || getenv( "DISPLAY" ) == 0 ) ) )
+ if ((users.count() > 1) || ((users.count() == 1) &&
+ ((getenv("ICEAUTHORITY") == 0) || (getenv("DISPLAY") == 0))))
{
- // Check for ICE authority file and if the file can be read by us
- TQString iceFileBase = "ICEauthority";
- TQString iceFile;
- TQFileInfo fi;
+ // Check for ICE authority file and if the file can be read by us
+ TQString iceFileBase = "ICEauthority";
+ TQString iceFile;
+ TQFileInfo fi;
- if (getenv("XDG_RUNTIME_DIR") != 0 )
- {
- TQFileInfo xdgRuntime(getenv("XDG_RUNTIME_DIR"));
- passwd* pstruct = getpwnam(it.key().local8Bit());
- if (pstruct)
+ TQString xdgRuntimeDir = TQString::fromLocal8Bit(getenv("XDG_RUNTIME_DIR"));
+ if (xdgRuntimeDir.isEmpty())
{
- iceFile = TQString("%1/%2/%3").arg(xdgRuntime.dirPath()).arg(pstruct->pw_uid).arg(iceFileBase);
- fi.setFile(iceFile);
+ xdgRuntimeDir = "/run/user/<uid>";
}
- if (!pstruct || !fi.exists())
+ if (!xdgRuntimeDir.isEmpty())
{
- iceFile = TQString::null;
+ TQFileInfo xdgRuntime(xdgRuntimeDir);
+ passwd* pstruct = getpwnam(it.key().local8Bit());
+ if (pstruct)
+ {
+ iceFile = TQString("%1/%2/%3").arg(xdgRuntime.dirPath()).arg(pstruct->pw_uid).arg(iceFileBase);
+ fi.setFile(iceFile);
+ }
+ if (!pstruct || !fi.exists())
+ {
+ iceFile = TQString::null;
+ }
}
- }
- if (iceFile.isEmpty())
- {
- iceFile = TQString("%1/.%2").arg(it.data()).arg(iceFileBase);
- fi.setFile(iceFile);
- }
- if( iceFile.isEmpty() )
- {
- cerr_ << "WARNING: Cannot determine home directory for user "
- << it.key() << "!" << endl
- << "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl
- << "calling dcop." << endl;
- }
- else if( fi.exists() )
- {
- if( fi.isReadable() )
+ if (iceFile.isEmpty())
{
- char *envStr = strdup( ( "ICEAUTHORITY=" + iceFile ).ascii() );
- putenv( envStr );
- //cerr_ << "ice: " << envStr << endl;
+ iceFile = TQString("%1/.%2").arg(it.data()).arg(iceFileBase);
+ fi.setFile(iceFile);
}
- else
+ if (iceFile.isEmpty())
{
- cerr_ << "WARNING: ICE authority file " << iceFile
- << "is not readable by you!" << endl
- << "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl
- << "calling dcop." << endl;
+ cerr_ << "WARNING: Cannot determine home directory for user "
+ << it.key() << "!" << endl
+ << "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl
+ << "calling dcop." << endl;
+ }
+ else if (fi.exists())
+ {
+ if (fi.isReadable())
+ {
+ char *envStr = strdup(("ICEAUTHORITY=" + iceFile).local8Bit());
+ putenv(envStr);
+ //cerr_ << "ice: " << envStr << endl;
+ }
+ else
+ {
+ cerr_ << "WARNING: ICE authority file " << iceFile
+ << "is not readable by you!" << endl
+ << "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl
+ << "calling dcop." << endl;
+ }
}
- }
- else
- {
- if( users.count() > 1 )
- continue;
else
{
- cerr_ << "WARNING: Cannot find ICE authority file "
- << iceFile << "!" << endl
- << "Please check permissions or set the $ICEAUTHORITY"
- << " variable manually before" << endl
- << "calling dcop." << endl;
+ if (users.count() > 1)
+ {
+ continue;
+ }
+ else
+ {
+ cerr_ << "WARNING: Cannot find ICE authority file "
+ << iceFile << "!" << endl
+ << "Please check permissions or set the $ICEAUTHORITY"
+ << " variable manually before" << endl
+ << "calling dcop." << endl;
+ }
}
- }
}
// Main loop