summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2014-03-19 14:03:13 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2014-03-20 09:23:16 +1000
commit44fe1b8ea284df6bbaef67e246016d104665b2fe (patch)
tree18181e3f6d14b434b7f9c5f13ed53ab0a77f3f5b /os
parent62d584d63190c6c8cef5fd49d87b1cb29358a434 (diff)
os: Add a mechanism to prevent creating any listen sockets
A socket-activated server will receive its listening sockets from the parent process and should not create its own sockets. This patch introduces a NoListen flag that can be set by a DDX to prevent the server from creating the sockets. When NoListen is enabled, we also disable the server lock checking, since the parent process is responsible for checking the lock before picking the display name and creating the sockets. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'os')
-rw-r--r--os/connection.c9
-rw-r--r--os/utils.c4
2 files changed, 9 insertions, 4 deletions
diff --git a/os/connection.c b/os/connection.c
index 400c5425d..b50f9e914 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -138,6 +138,7 @@ fd_set OutputPending; /* clients with reply/event data ready to go */
int MaxClients = 0;
Bool NewOutputPending; /* not yet attempted to write some new output */
Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
+Bool NoListenAll; /* Don't establish any listening sockets */
static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or
@@ -406,7 +407,10 @@ CreateWellKnownSockets(void)
/* display is initialized to "0" by main(). It is then set to the display
* number if specified on the command line, or to NULL when the -displayfd
* option is used. */
- if (display) {
+ if (NoListenAll) {
+ ListenTransCount = 0;
+ }
+ else if (display) {
if (TryCreateSocket(atoi(display), &partial) &&
ListenTransCount >= 1)
if (!PartialNetwork && partial)
@@ -440,9 +444,10 @@ CreateWellKnownSockets(void)
DefineSelf (fd);
}
- if (!XFD_ANYSET(&WellKnownConnections))
+ if (!XFD_ANYSET(&WellKnownConnections) && !NoListenAll)
FatalError
("Cannot establish any listening sockets - Make sure an X server isn't already running");
+
#if !defined(WIN32)
OsSignal(SIGPIPE, SIG_IGN);
OsSignal(SIGHUP, AutoResetServer);
diff --git a/os/utils.c b/os/utils.c
index 497779b52..c513968ad 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -270,7 +270,7 @@ LockServer(void)
int len;
char port[20];
- if (nolock)
+ if (nolock || NoListenAll)
return;
/*
* Path names
@@ -390,7 +390,7 @@ LockServer(void)
void
UnlockServer(void)
{
- if (nolock)
+ if (nolock || NoListenAll)
return;
if (!StillLocking) {