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>2022-02-17 16:26:43 +0100
commita18e805939f7180ff5a6863082f079ad5681071a (patch)
tree4e5f711d0d98471b8f82c29fc49ac52a592ecc92
parent9b41b5ff4b2311d31c14cd007eb3ec58bf4b5bc6 (diff)
downloadtdelibs-a18e805939f7180ff5a6863082f079ad5681071a.tar.gz
tdelibs-a18e805939f7180ff5a6863082f079ad5681071a.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 5a76b8193..48cf02ec4 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