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 03:20:04 +0100
commit81d495430ddcab805997c3945c195d2844bc1eaa (patch)
treecaba4887eb4bf61835b0397fcd6d8c5f75790d77
parent2b3ea27bdf4879933d46aba24c457382398c998f (diff)
downloadtdelibs-81d495430ddcab805997c3945c195d2844bc1eaa.tar.gz
tdelibs-81d495430ddcab805997c3945c195d2844bc1eaa.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>
-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