summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qlocalserver_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qlocalserver_unix.cpp')
-rw-r--r--src/network/socket/qlocalserver_unix.cpp54
1 files changed, 23 insertions, 31 deletions
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index 149d89c000..a615dcc7b6 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -90,13 +90,14 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
// Check any of the flags
if (socketOptions & QLocalServer::WorldAccessOption) {
- tempDir.reset(new QTemporaryDir(fullServerName));
+ QFileInfo serverNameFileInfo(fullServerName);
+ tempDir.reset(new QTemporaryDir(serverNameFileInfo.absolutePath() + QLatin1Char('/')));
if (!tempDir->isValid()) {
setError(QLatin1String("QLocalServer::listen"));
return false;
}
tempPath = tempDir->path();
- tempPath += QLatin1Char('/') + requestedServerName;
+ tempPath += QLatin1String("/s");
}
// create the unix socket
@@ -124,13 +125,6 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
}
::memcpy(addr.sun_path, tempPath.toLatin1().data(),
tempPath.toLatin1().size() + 1);
-
- if (-1 == ::fchmod(listenSocket, 0)) {
- setError(QLatin1String("QLocalServer::listen"));
- closeServer();
- return false;
- }
-
} else {
::memcpy(addr.sun_path, fullServerName.toLatin1().data(),
fullServerName.toLatin1().size() + 1);
@@ -160,30 +154,28 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
}
if (socketOptions & QLocalServer::WorldAccessOption) {
- mode_t mode = 000;
+ mode_t mode = 000;
- if (socketOptions & QLocalServer::UserAccessOption) {
- mode |= S_IRWXU;
- }
- if (socketOptions & QLocalServer::GroupAccessOption) {
- mode |= S_IRWXG;
- }
- if (socketOptions & QLocalServer::OtherAccessOption) {
- mode |= S_IRWXO;
- }
+ if (socketOptions & QLocalServer::UserAccessOption)
+ mode |= S_IRWXU;
- if (mode) {
- if (-1 == ::chmod(tempPath.toLatin1(), mode)) {
- setError(QLatin1String("QLocalServer::listen"));
- closeServer();
- return false;
- }
- }
- if (-1 == ::rename(tempPath.toLatin1(), fullServerName.toLatin1())){
- setError(QLatin1String("QLocalServer::listen"));
- closeServer();
- return false;
- }
+ if (socketOptions & QLocalServer::GroupAccessOption)
+ mode |= S_IRWXG;
+
+ if (socketOptions & QLocalServer::OtherAccessOption)
+ mode |= S_IRWXO;
+
+ if (::chmod(tempPath.toLatin1(), mode) == -1) {
+ setError(QLatin1String("QLocalServer::listen"));
+ closeServer();
+ return false;
+ }
+
+ if (::rename(tempPath.toLatin1(), fullServerName.toLatin1()) == -1) {
+ setError(QLatin1String("QLocalServer::listen"));
+ closeServer();
+ return false;
+ }
}
Q_ASSERT(!socketNotifier);