Commit Graph

768 Commits

Author SHA1 Message Date
Boris-Barboris 16571b8926 Don't hardcode fps for fake screen
Currently, when main hardware screen is powered-off,
X server initializes fake screen's timer with
1 second update interval.

Streaming software like Nomachine or Vnc, as well as
desktop input automation suffers from it, since it
will forever be stuck on 1 fps until the display is
turned back on.

This commit adds command line option -fakescreenfps <int>
that allows the user to change the default fake screen
timer.

Signed-off-by: Baranin Alexander <ismailsiege@gmail.com>
2021-07-29 08:09:00 +00:00
Povilas Kanapickas b67e514dbb meson: Fix warnings when reading back and checking feature flags
Meson does not like comparing things of different types which is a
problem when reading back values of feature flags as they may contain
either false (bool) or 1 (string).

Since there is a strong reason why we use false when the feature does
not exist, we work around this issue by always converting the returned
value to int via to_int().

Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1190
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-07-05 12:46:14 +00:00
Olivier Certner d4b38e1119 os: Properly report failure to link lock file
Stop assuming that a failure to link always means that the file indeed
exists. In case of other failure (e.g., permissions), the user would get an
inconsistent "Can't read lock file" message.

Signed-off-by: Olivier Certner <olce.freedesktop@certner.fr>
2021-06-25 10:18:18 +00:00
Olivier Fourdan 6b47321bc6 dix: Add optional terminate delay
When the command line option "-terminate" is used, it could be
interesting to give it an optional grace period to let the Xserver
running for a little longer in case a new connection occurs.

This adds an optional parameter to the "-terminate" command line option
for this purpose.

v2: Use a delay in seconds instead of milliseconds
    (Martin Peres <martin.peres@mupuf.org>)
v3: Clarify man page entry, ensure terminateDelay is always >= 0,
    simplify TimerFree(). (Peter Hutterer <peter.hutterer@who-t.net>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-06-07 17:28:05 +02:00
Claes Nästén 236d177550 os: include unistd.h when HAVE_PSTACK is defined
On Solaris when HAVE_PSTACK is defined unistd.h needs to be included to
avoid implicit declarations of pipe, read, execle etc.
2021-05-27 21:33:12 +00:00
Povilas Kanapickas 68c2cfadd6 meson: Make sure defines are either set to 1 or not defined
This will make the behavior of meson consistent with autotools. The
configuration macros are exposed to public headers so any inconsistency
is likely to break code for anyone who's not careful to use #ifdef
instead of #if.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-04-09 11:18:54 +00:00
Povilas Kanapickas b25795462f meson: Add missing pthread dependency for libxserver_os library
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-04-09 11:18:54 +00:00
Povilas Kanapickas 9582ef4efc meson: Fix typo in libxserver_os dependencies for openbsd
This has not been tested, but os_deps is not used anywhere in the file,
so it's likely this was a typo.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-04-09 11:18:54 +00:00
Jeremie Courreges-Anglas ab8f8c9841 xserver/os: safer IPv6 "kame hack" fix, only override sin6_scope_id if zero
This helps on KAME-based systems which want to get rid of this hack.
The assumption is that if sin6_scope_id is set, then the interface index
is no longer embedded in the address.

Signed-off-by: Jeremie Courreges-Anglas <jca@wxcvbn.org>
2021-04-04 21:06:35 +00:00
Jeremy Huddleston Sequoia 20b86c4060 os: Remove support for Tiger and earlier versions of macOS
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Olivier Fourdan 3cdac5ba07 mi: List extensions in usage message
Not all extensions can be enabled or disabled at runtime, list the
extensions which can from the help message rather than on error only.

v2:
 * Print the header message in the ListStaticExtensions() (Peter
   Hutterer)
 * Do not export ListStaticExtensions() as Xserver API

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-01-29 12:52:09 +00:00
Adam Jackson 365cbbfc4b os, shm: fcntl()'s third argument is integer, not pointer
All of these uses were attempting to set FD_CLOEXEC, which happens to be
(1<<0). Since flags is going to be aligned in memory, its address is
never going to have the low bit set, so we were never actually setting
what we meant to.

Fixes: xorg/xserver#1114
2020-12-18 09:36:30 -05:00
Bernhard Übelacker c15dd0ba48 os: Fix instruction pointer written in xorg_backtrace
The address retrieved in "pip.start_ip" is not necessarily the same
address as unw_get_proc_name finds as nearest symbol and returns in "off".
Therefore using "pip.start_ip + off" is not reliable, at least
visible in the binaries from the Debian repository.

Bug-Debian: https://bugs.debian.org/971088

Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
2020-09-28 10:42:56 +02:00
Alan Coopersmith 23e83724df Fix spelling/wording issues
Most (but not all) of these were found by using
  codespell --builtin clear,rare,usage,informal,code,names
but not everything reported by that was fixed.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-07-05 13:07:33 -07:00
Jan Beich f2cf236da8 os: unbreak xsha1 on FreeBSD
../os/xsha1.c:36:10: fatal error: 'sha1.h' file not found
 #include <sha1.h>
          ^~~~~~~~
../os/xsha1.c:45:5: error: implicit declaration of function 'SHA1Init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    SHA1Init(ctx);
    ^
../os/xsha1.c:54:5: error: implicit declaration of function 'SHA1Update' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    SHA1Update(sha1_ctx, data, size);
    ^
../os/xsha1.c:63:5: error: implicit declaration of function 'SHA1Final' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    SHA1Final(result, sha1_ctx);
    ^
2020-05-27 07:15:07 +00:00
Daniel Llewellyn 578371616e
os: Ignore dying client in ResetCurrentRequest
You might as well, it's harmless. Better, some cleanup code (like DRI2
swap wait) needs to run both normally and at client exit, so it
simplifies the callers to not need to check first. See 4308f5d3 for a
similar example.

Props: @ajax (Adam Jackson)

Fixes: xorg/xserver#211

Signed-off-by: Daniel Llewellyn <diddledan@ubuntu.com>
2020-01-29 21:39:53 +00:00
Aaron Plattner 4308f5d3d1 os: Don't crash in AttendClient if the client is gone
If a client is in the process of being closed down, then its client->osPrivate
pointer will be set to NULL by CloseDownConnection. This can cause a crash if
freeing the client's resources results in a call to AttendClient. For example,
if the client has a pending sync fence:

 Thread 1 "X" received signal SIGSEGV, Segmentation fault.
 AttendClient (client=0x5571c4aed9a0) at ../os/connection.c:942
 (gdb) bt
 #0  AttendClient (client=0x5571c4aed9a0) at ../os/connection.c:942
 #1  0x00005571c3dbb865 in SyncAwaitTriggerFired (pTrigger=<optimized out>) at ../Xext/sync.c:694
 #2  0x00005571c3dd5749 in miSyncDestroyFence (pFence=0x5571c5063980) at ../miext/sync/misync.c:120
 #3  0x00005571c3dbbc69 in FreeFence (obj=<optimized out>, id=<optimized out>) at ../Xext/sync.c:1909
 #4  0x00005571c3d7a01d in doFreeResource (res=0x5571c506e3d0, skip=skip@entry=0) at ../dix/resource.c:880
 #5  0x00005571c3d7b1dc in FreeClientResources (client=0x5571c4aed9a0) at ../dix/resource.c:1146
 #6  FreeClientResources (client=0x5571c4aed9a0) at ../dix/resource.c:1109
 #7  0x00005571c3d5525f in CloseDownClient (client=0x5571c4aed9a0) at ../dix/dispatch.c:3473
 #8  0x00005571c3d55eeb in Dispatch () at ../dix/dispatch.c:492
 #9  0x00005571c3d59e96 in dix_main (argc=3, argv=0x7ffe7854bc28, envp=<optimized out>) at ../dix/main.c:276
 #10 0x00007fea4837cb6b in __libc_start_main (main=0x5571c3d1d060 <main>, argc=3, argv=0x7ffe7854bc28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe7854bc18) at ../csu/libc-start.c:308
 #11 0x00005571c3d1d09a in _start () at ../Xext/sync.c:2378
 (gdb) print client->osPrivate
 $1 = (void *) 0x0

Since the client is about to be freed, its ignore count doesn't matter and
AttendClient can simply be a no-op. Check for client->clientGone in AttendClient
and remove similar checks from two callers that had them.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2019-11-19 10:15:05 -08:00
Adam Jackson 89a9927b1e include: Remove now-empty site.h 2019-10-30 16:17:04 +00:00
Adam Jackson 2d1ed64d2a dix: Remove -to option to set the default connection timeout
One minute is admittedly arbitrary, but again, pretty sure this never
gets set on the command line in practice.
2019-10-30 16:17:04 +00:00
Adam Jackson 46a275522f xdmcp: Remove unconfigurable COMPILEDDISPLAYCLASS 2019-10-30 16:17:04 +00:00
Adam Jackson 66eb933ec9 os: Remove unconfigurable DEFAULT_ACCESS_CONTROL macro 2019-10-30 16:17:04 +00:00
Adam Jackson 56ea4c769c dix: Remove -fn and -fc options to set default text/cursor fonts
I strongly suspect these never get used in the wild, and it's not an
especially useful thing to do in any case.
2019-10-30 16:17:04 +00:00
Adam Jackson 4ebce1ed8b os: Move log verbosity defaults into os/log.c
There's not any configuration knobs for this so there's no real reason
to leave them in a configgy header.
2019-10-30 16:17:04 +00:00
Alan Coopersmith 0e8c0d2f23 ospoll: Fix Solaris ports implementation to build on Solaris 11.4
Wrong version got committed, but wasn't noticed since it only builds
with meson, not autoconf.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-09-23 15:12:01 -07:00
Adam Jackson 7d0e660e0e meson: Add dtrace support 2019-08-27 17:38:59 -04:00
Adam Jackson 7968d10fad dtrace: Move Xserver.d from dix/ to include/
dix/ is typically not in the include path, and this properly belongs in
include anyway since it's needed from os/ too.
2019-08-27 17:38:54 -04:00
Jon Turney a026972776 Clarify authorization failure reason strings sent back to the client 2019-07-23 19:50:25 +00:00
Jon Turney 7b4b030df8 configure: Check for sigprocmask
MinGW defines SIG_BLOCK, but doesn't have signal masks, so rather than
checking for SIG_BLOCK, add a configure check for sigprocmask.

v2:
Also add check to meson.build
2019-05-18 14:59:38 +00:00
Jon Turney 6c5d048095 os: Fix build of xserver_poll.c on MinGW
Include winsock.h for definition of fd_set type and select()

Future work: Maybe this also needs some error checking for fd > FD_SETSIZE?
2019-05-18 14:59:38 +00:00
Topi Miettinen bb46e78540 os: add support for systemd notification
It can take some time for Xorg to start. If Xorg runs as a systemd
service and other services are based on it, they have no way to
determine when Xorg is really ready to accept requests. Let's use
sd_notify() provided by libsystemd to signal systemd for readiness.
If Xorg has not been started as a systemd service, this won't do
anything.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2019-05-07 09:01:47 +03:00
Jon Turney 655b1eb32e meson: Convert xquartz from autotools
Differences from autotools:

* Autotools defined NO_ALLOCA for OSX builds.  I don't think we need
this anymore as Xalloc.h is no longer used anywhere in the xserver.

* X11.bin is linked with -u,miDCInitialize, and then libserver_mi
provided to satisfy (just) that.  It's been that way since the commit
which added it.  We can't write the equivalent in meson due to linker
argument ordering issues, but do we really need to?

* An explicit -Dsecure-rpc=false is required for OSX, since in meson we
don't do the checks that XTRANS_SECURE_RPC_FLAGS did for the existence
of the specific RPC functions required.
2019-05-02 15:42:58 +00:00
Jon Turney d3a528c91e Remove unneeded include of dix.h from strcasestr.c
In the meson build, functions to make up for the shortcomings of libc
are compiled into a separate library. We don't bother making the pixman
headers available (reasonably enough) to this compilation, but they are
required indirectly by dix.h.  Just remove this unneeded include.
2019-04-30 20:07:51 +00:00
Alan Coopersmith 4ad21c3247 Add ddxInputThread call from os layer into ddx layer
Allows ddx's to run additional code as necessary to set up the
input thread.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-25 15:48:03 +00:00
Peter Harris 937a5b78a2 os: Fix GetTimeInMicros resolution
GetTimeInMillis is called first, which sets clockid to
CLOCK_MONOTONIC_COARSE, which is typically much lower resolution than
the callers of GetTimeInMicros want.

Prior to a779fda224, GetTimeInMillis and
GetTimeInMicros did not share a clockid.

Restore the clockid split to fix the granularity of GetTimeInMicros.

Signed-off-by: Peter Harris <pharris@opentext.com>
2019-01-30 14:56:46 -05:00
Alan Coopersmith 7fb6338c68 os: Report errors opening authorization file (#469)
Fixes: xorg/xserver#469

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-01-01 16:50:24 -08:00
Adam Jackson 23752b3ef8 os: Establish new connections synchronously not on the work queue
This contortion made a bit more sense before we got SetNotifyFd and
friends, but now there's no need for it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-13 10:36:40 -05:00
Matthieu Herrb 248d164eae LogFilePrep: add a comment to the unsafe format string.
CVE-2018-14665 also made it possible to exploit this to access
memory. With -logfile forbidden when running with elevated privileges
this is no longer an issue.

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-10-25 09:17:11 -04:00
Andreas Fett 08ff37d05a os/xdmcp: Fix binding of ipv6 source address
Choose the socket fd of the correct address family based
on the address family of the argument to the -from option.

Fixes: xorg/xserver#4
2018-10-24 19:29:29 +00:00
Adam Jackson 53d32c94f3 dix: Remove the magic WhenMapped backing store hack
Automatic compositing exists, if that's what you want then use it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-10-23 18:37:46 +00:00
Alexander Volkov 32677ce03d os/xdmcp: Don't create a new socket in XdmcpReset()
xdmcpSocket survives during the reset, there is no
need to create a new one.

This commit restores logic that was broken by
49c0f2413d in Xorg 1.19.

Signed-off-by: Alexander Volkov <a.volkov@rusbitech.ru>
2018-10-03 17:46:15 +00:00
Adam Jackson a23eba2a91 dix: Merge AbortDDX into ddxGiveUp
These are so close to identical that most DDXes implement one in terms
of the other. All the relevant cases can be distinguished by the error
code, so merge the functions together to make things simpler.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-09-28 16:25:12 -04:00
Adam Jackson 3a4d7c79e7 dix: Remove MaxClients
This variable was no longer being read anywhere. MAXCLIENTS the macro is
the compile-time maximum limit, LIMITCLIENTS the macro is the default
limit, LimitClients the variable is the limit for the current server.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-09-12 19:31:07 +00:00
Eric Anholt 4ba7866770 meson: Get close to parity with autotools for CLIENTIDS tracking.
The client ID is only needed for XRes, and autotools build ignores the
--clientids= arg if xres is disabled.  We haven't made a meson option
for disabling tracking client ids (is it actually worth a build
option?), so just make this depend on xres.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-09 13:42:54 -04:00
Lyude Paul d95a1310ef meson: ensure the libc has RPC functions when secure-rpc is enabled
Currently our meson.build just makes the assumption that the libc is
going to provide RPC functions. This doesn't actually seem to be the
case on Fedora, which causes compilation to fail unexpectedly:

../../Projects/xserver/os/rpcauth.c:47:10: fatal error: rpc/rpc.h: No such file or directory
 #include <rpc/rpc.h>
          ^~~~~~~~~~~
compilation terminated.

So, in the event that we can't use libtirpc ensure that we actually
check whether or not the libc provides rpc/rpc.h. If it doesn't, raise
an error.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
2018-07-03 17:13:38 -04:00
Damien Leone f33cb42643 os: Recompute whether any clients are ready after check_timers()
If a driver calls AttendClient() from within a timer callback we
need to re-compute the local 'are_ready' to prevent the attended
client from waiting until WaitForSomething() times out.

This is a fix similar to commit 9ed5b263.

Signed-off-by: Damien Leone <dleone@nvidia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2018-06-26 17:03:32 -07:00
Chris Wilson 1e9d5533e3 os/WaitFor: Use the simpler xorg_list_for_each_entry()
As we are not freeing elements while iterating the list of timers, we
can forgo using the safe variant, and reduce the number of pointer
dances required for the insertion sort.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-05-21 13:52:13 -04:00
Chris Wilson 6115d8b40c os/WaitFor: Use xorg_list_append()
Currently, we use xorg_list_add(new, head->prev) which is functionaly
equivalent to xorg_list_append(), but with more pointer chasing, so
reduce the strain on the reader and compiler by using the simpler
append().

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-05-21 13:52:09 -04:00
Chris Wilson ac7a4bf44c os/WaitFor: Check timers on every iteration
Currently we only check timer expiry if there are no client fd (or
other input) waiting to be serviced. This makes it very easy to starve
the timers with long request queues, and so miss critical timestamps.

The timer subsystem is just another input waiting to be serviced, so
evaluate it on every loop like all the others, at the cost of calling
GetTimeInMillis() slightly more frequently. (A more invasive and likely
OS specific alternative would be to move the timer wheel to the local
equivalent of timerfd, and treat it as an input fd to the event loop
exactly equivalent to all the others, and so also serviced on every
pass. The trade-off being that the kernel timer wheel is likely more
efficiently integrated with epoll, but individual updates to each timer
would then require syscalls.)

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-04-17 16:30:36 -04:00
Thierry Reding f3b0a2aee2 meson: Remove usage of pkg-config --variable=includedir
Querying a pkg-config variable using the --variable option produces the
value of the given variable as stored in the pkg-config file and should
not be used to add directories to the include search path.

The reason for this is that it breaks cross-compilation, because header
files are installed relative to the host sysroot. pkg-config supports a
PKG_CONFIG_SYSROOT_DIR environment variable that points to this sysroot
and will prepend that to the path of directories in -I or -L options in
pkg-config's Cflags, Libs or Libs.private keywords. However, because no
context can be inferred from variable names, as opposed to the keywords
with fixed meaning, the sysroot path will not be prepended to them. The
build system is responsible for doing so if necessary since it is aware
of the context in which the variable is used.

Adding the include directory returned by pkg-config to the include path
leaks build system information into the cross-build and break with very
confusing errors such as this:

	In file included from include/misc.h:82:0,
			 from dix/atom.c:55:
	/usr/include/pthread.h:682:6: warning: '__regparm__' attribute directive ignored [-Wattributes]
	      __cleanup_fct_attribute;
	      ^~~~~~~~~~~~~~~~~~~~~~~

or this:

	In file included from include/misc.h:139:0,
			 from dix/atom.c:55:
	/usr/include/stdlib.h:133:8: error: '_Float128' is not supported on this target
	 extern _Float128 strtof128 (const char *__restrict __nptr,
		^~~~~~~~~

Fix this by replacing the include directory with the appropriate xproto
dependency required to add the correct include directory to the compile
command for subdirectories that are missing the dependency. As detailed
above, this gives pkg-config the opportunity to prepend the sysroot for
all paths in -I compiler options.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2018-04-02 13:42:02 -04:00
Antoine Martin c95361465e os: Fix -logfile when used with -displayfd
Trivial way to reproduce the bug:

$ Xorg -logfile /tmp/mylog -config /etc/xpra/xorg.conf -displayfd 2

The server then moans:

Failed to rename log file "/tmp/mylog" to "/tmp/mylog": No such file or directory

And the log file is created but immediately renamed to "/tmp/mylog.old".
This is caused by the changes to the log file handling introduced by
this commit:

https://cgit.freedesktop.org/xorg/xserver/commit/?id=edcb6426f20c3be5dd5f50b76a686754aef2f64e

To fix this, only rename the logfile if the log filename contains the
magic substitution string "%s".

Signed-off-by: Antoine Martin <antoine@nagafix.co.uk>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-03-28 15:16:02 -04:00