diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-02 21:21:15 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-02 21:21:15 +0000 |
commit | 96900dbce3aaa1fcac74a07a71482c5c6fcd3cab (patch) | |
tree | bf3fc68d0dcc660fce0e21171373a2d4e2395707 /kded/khostname.cpp | |
parent | 5f99bff82d3413803bcc652999f4f631058179d6 (diff) | |
download | tdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.tar.gz tdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.zip |
* Large set of SuSE patches to fix bugs and add functionality
* kdemm is included but not used by knotify as it does not work out of the box
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171141 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kded/khostname.cpp')
-rw-r--r-- | kded/khostname.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/kded/khostname.cpp b/kded/khostname.cpp index e38c88f53..0fa837a2c 100644 --- a/kded/khostname.cpp +++ b/kded/khostname.cpp @@ -111,7 +111,8 @@ static QCStringList split(const TQCString &str) void KHostName::changeX() { - TQString cmd = "xauth list"; + const char* xauthlocalhostname = getenv("XAUTHLOCALHOSTNAME"); + TQString cmd = "xauth -n list"; FILE *xFile = popen(TQFile::encodeName(cmd), "r"); if (!xFile) { @@ -123,6 +124,7 @@ void KHostName::changeX() char buf[1024+1]; while (!feof(xFile)) { + buf[1024]='\0'; TQCString line = fgets(buf, 1024, xFile); if (line.length()) line.truncate(line.length()-1); // Strip LF. @@ -157,12 +159,17 @@ void KHostName::changeX() TQCString newNetId = newName+netId.mid(i); TQCString oldNetId = netId.left(i); - if(oldNetId != oldName) - continue; + if(oldNetId != oldName + && (!xauthlocalhostname || strcmp(xauthlocalhostname, oldNetId.data()) != 0)) + continue; - cmd = "xauth remove "+KProcess::quote(netId); - system(TQFile::encodeName(cmd)); - cmd = "xauth add "; + // don't nuke the xauth when XAUTHLOCALHOSTNAME points to it + if (!xauthlocalhostname || oldNetId != xauthlocalhostname) + { + cmd = "xauth -n remove "+KProcess::quote(netId); + system(TQFile::encodeName(cmd)); + } + cmd = "xauth -n add "; cmd += KProcess::quote(newNetId); cmd += " "; cmd += KProcess::quote(authName); @@ -276,7 +283,10 @@ void KHostName::changeDcop() } } - // Remove old entries + // Remove old entries, but only if XAUTHLOCALHOSTNAME doesn't point + // to it + char* xauthlocalhostname = getenv("XAUTHLOCALHOSTNAME"); + if (!xauthlocalhostname || !oldNetId.contains(xauthlocalhostname)) { TQString cmd = "iceauth remove "+KProcess::quote("netid="+oldNetId); system(TQFile::encodeName(cmd)); @@ -368,9 +378,7 @@ int main(int argc, char **argv) KHostName hn; - if(!getenv("XAUTHLOCALHOSTNAME")) - hn.changeX(); - + hn.changeX(); hn.changeDcop(); hn.changeStdDirs("socket"); hn.changeStdDirs("tmp"); |