summaryrefslogtreecommitdiff
path: root/os
AgeCommit message (Collapse)AuthorFilesLines
2018-04-02meson: Remove usage of pkg-config --variable=includedirThierry Reding1-0/+3
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-03-28os: Fix -logfile when used with -displayfdAntoine Martin1-1/+1
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-21os: use PrivsElevated instead of a manual checkNicolai Hähnle1-1/+1
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Ben Crocker <bcrocker@redhat.com> Reviewed-by: Antoine Martin <antoine@nagafix.co.uk> Tested-by: Ben Crocker <bcrocker@redhat.com>
2018-03-21os: move xf86PrivsElevated hereNicolai Hähnle1-0/+63
Having different types of code all trying to check for elevated privileges is a bad idea. This implementation is the most thorough one. Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Ben Crocker <bcrocker@redhat.com> Reviewed-by: Antoine Martin <antoine@nagafix.co.uk> Tested-by: Ben Crocker <bcrocker@redhat.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-08os: Define {ReadFdFrom,WriteFdTo}Client unconditionallyAdam Jackson1-2/+7
Otherwise this is broken on cygwin: rrlease.c: In function ‘ProcRRCreateLease’: rrlease.c:305:9: error: implicit declaration of function ‘WriteFdToClient’ [-Werror=implicit-function-declaration] if (WriteFdToClient(client, fd, TRUE) < 0) { Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-02-19os: avoid uninitialized offsets in backtraceJeffrey Smith1-0/+1
When xorg_backtrace calls unw_get_proc_name and an error occurs, offset might not be set for the current frame. Initialize offset for each frame so that the offset from another frame cannot be used inadvertently. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-01-31os: Always return microseconds from GetTimeInMicros()Jeff Smith1-1/+1
When a monotonic clock is not available, GetTimeInMicros() returns the time in nanoseconds. Instead, return the time in microseconds, as the name indicates. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-01-24os/inputthread: Force unlock when stopping thread.Michal Srb1-0/+1
The inputthread is kept locked all the time while X server's VT is not active. If the X server is terminated while not active, it will be stuck forever in InputThreadFini waiting for the thread to join, but it wouldn't because it is locked. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=103782 Signed-off-by: Michal Srb <msrb@suse.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-01-22meson: Use and prefer tirpc for Secure RPC authenticationJon Turney1-0/+5
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-01-16meson: Enable SUN-DES-1 auth codeAdam Jackson1-0/+4
Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2018-01-08os: Fix a type error in the IPv6 XDMCP codeAdam Jackson1-1/+1
Building with strict-aliasing rightly chirps here: ../os/xdmcp.c: In function ‘XdmcpRegisterConnection’: ../os/xdmcp.c:489:31: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] &((struct sockaddr_in6 *) &address)->sin6_addr.s6_addr[12]; ^~~~~~~~~~~~ We have "const char *address", so &address here is a char ** (i.e., it points to the slot on the stack containing the pointer to the character array passed in as an argument). Casting that to a struct sockaddr_in6 * is wrong, because it means that area of the stack will be reinterpreted as a struct sockaddr_in6. Instead, cast address, not &address. Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-12-13os: Add epoll-like port implementation for SolarisPeter Harris1-7/+121
x11perf -noop with 200 xlogos connected is slightly faster with ports: before after Operation ---------- ----------------- -------------------- 18400000.0 19200000.0 (1.04) X protocol NoOperation Acked-by: Keith Packard <keithp@keithp.com> Signed-off-by: Peter Harris <pharris@opentext.com>
2017-12-13os: Add epoll-like pollset implementation for AIXPeter Harris1-1/+145
AIX's poll only allows FD_SETSIZE entries in the fd list, which is insufficient for expanded MaxClients. As a bonus, x11perf -noop with ~250 xlogos connected is slightly faster with pollset: before after Operation --------- ---------------- -------------------- 5750000.0 5990000.0 (1.04) X protocol NoOperation Signed-off-by: Peter Harris <pharris@opentext.com> Acked-by: Keith Packard <keithp@keithp.com>
2017-12-13os: Make OsSignalHandler ask for core dumps for signo != SIGQUITAdam Jackson1-2/+4
SIGQUIT is a normal termination request, but any other signal we handle here wants a core. This has the effect of making FatalError's call to AbortServer trigger the if (CoreDump) OsAbort(); path. This will allow us to remove some DDX code that has the same net effect. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
2017-12-13os: Fix strtok/free crash in ComputeLocalClientTomasz Śniatowski1-3/+3
Don't reuse cmd for strtok output to ensure the proper pointer is freed afterwards. The code incorrectly assumed the pointer returned by strtok(cmd, ":") would always point to cmd. However, strtok(str, sep) != str if str begins with sep. This caused an invalid-free crash when running a program under X with a name beginning with a colon. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=104123 Signed-off-by: Tomasz Śniatowski <kailoran@gmail.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-11-29os/xdmcp: Honour -once when session is deadDaniel Martin1-1/+1
Terminate a dead session when -once was passed. Don't restart it. Signed-off-by: Daniel Martin <consume.noise@gmail.com> Reviewed-by: Walter Harms <wharms@bfs.de>
2017-11-06os: Remove mffs()Adam Jackson2-25/+0
This was always wide enough to work on an fd_mask ("mask" ffs presumably). We don't operate on fd_masks anymore, so this can go. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2017-10-30Use ARRAY_SIZE all over the treeDaniel Martin2-5/+3
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with the ARRAY_SIZE macro from dix.h when possible. A semantic patch for coccinelle has been used first. Additionally, a few macros have been inlined as they had only one or two users. Signed-off-by: Daniel Martin <consume.noise@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-09os: Make sure big requests have sufficient length.Michal Srb1-0/+5
A client can send a big request where the 32B "length" field has value 0. When the big request header is removed and the length corrected, the value will underflow to 0xFFFFFFFF. Functions processing the request later will think that the client sent much more data and may touch memory beyond the receive buffer. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-30os: Fix warning in LockServerAdam Jackson1-1/+1
The meson build gives me: ../os/utils.c: In function ‘LockServer’: ../os/utils.c:310:40: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long) getpid()); ^~~~~~~~~ ../os/utils.c:310:5: note: ‘snprintf’ output between 12 and 13 bytes into a destination of size 12 snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long) getpid()); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Which seems to be due to the %d part meaning that a negative number's - sign would be one wider than we're expecting. Fine, just coerce it to unsigned. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2017-08-22os: make MitGenerateCookie() independent of XCSECURITYEmil Velikov1-4/+0
Analogous to previous commit. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-08-22os: make GenerateRandomData() independent of XCSECURITYEmil Velikov1-2/+2
The function itself does not depend on the macro. Move it outside of the ifdef guard and remove the identical copy in XWIN. This is step 1 towards removing the duplication in winauth.c and moving the OS specifics to os/ Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-08-14meson: Fix epoll detectionPeter Harris1-1/+1
The epoll code depends on epoll_create1, not epoll_create. Signed-off-by: Peter Harris <pharris@opentext.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
2017-06-13os: Set oc->fd to -1 when connection is closedKeith Packard1-0/+1
This ensures that we don't use the now-closed file descriptor in the future. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2017-06-13os: Check oc->trans_conn before using oc->fd in YieldControlNoInputKeith Packard1-10/+9
oc->trans_conn is set to NULL when the connection is closed. At this point, oc->fd is no longer valid and shouldn't be used. Move dereference of oc->fd up into YieldControlNoInput where the state of oc->trans_conn can be checked in a single place. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2017-06-13os: Don't call ospoll_listen/ospoll_mute after connection is closedKeith Packard1-4/+6
In set_poll_client, check oc->trans_conn to make sure the connection is still running before changing the ospoll configuration of the file descriptor in case some other bit of the server is now using this file descriptor. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2017-06-13os: Use CloseDownFileDescriptor from AbortClient, including ospoll_removeKeith Packard3-11/+12
AbortClient performs most of the same operations as CloseDownFileDescriptor except that it doesn't call ospoll_remove, leaving that unaware that the file descriptor has been closed. If the file descriptor is re-used before the server comes back around to clean up, and that new file descriptor is passed to SetNotifyFd, then that function will mistakenly re-interpret the stale ClientPtr returned by ospoll_data as a struct notify * instead and mangle data badly. To fix this, the patch does: 1) Change CloseDownFileDescriptor so that it can be called multiple times on the same OsCommPtr. The calls related to the file descriptor are moved inside the check for trans_conn and oc->trans_conn is set to NULL after cleaning up. 2) Move the XdmcpCloseDisplay call into CloseDownFileDescriptor. I don't think the actually matters as we just need to know at some point that the session client has exited. Moving it avoids the possibility of having this accidentally trigger from another client with the same fd which closes down at around the same time. 3) Change AbortClient to call CloseDownFileDescriptor. This makes sure that all of the fd-related clean up happens in the same way everywhere, in particular ensures that ospoll is notified about the closed file descriptor at the time it is closed and not some time later. Debian-bug: https://bugs.debian.org/862824 Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2017-06-13os: Eliminate ConnectionTranslationKeith Packard2-140/+1
This infrastructure is no longer read, only written; the mapping from fd to client is now handled by ospoll. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2017-05-12os, xfree86: Stop being so weird about <limits.h>Adam Jackson2-19/+0
Whatever problem this is trying to fix, we don't care. Just include the thing and stop worrying about whether _POSIX_SOURCE is defined. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-05-10meson: Only detect each function oncePeter Harris1-9/+9
Use conf_data outside of include/ to avoid re-running detection of the same functions. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Peter Harris <pharris@opentext.com>
2017-05-10timingsafe_memcmp: Fix meson buildAdam Jackson1-1/+1
Include dix-config.h first to pick up _GNU_SOURCE so we get the definition for sigset_t. Reported-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-05-04meson: Test to build xserver_poll.c was invertedJon TURNEY1-2/+2
Test to build xserver_poll.c was inverted compared to autoconf. Build xserver_poll.c if poll is missing. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-04-29os: Mark client as ready to read when closing due to write failure [100863]Keith Packard1-1/+5
This makes sure the server will go look at the client again, notice that the FD is no longer valid and close the client down. Bugzilla: https://bugs.freedesktop.org/100863 Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2017-04-29os: un-duplicate code to close client on write failureKeith Packard1-13/+21
There are three copies of the same short sequence of operations to close down a client when a write error occurs. Create a new function, AbortClient, which performs these operations and then call it from the three places. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2017-04-27meson: Factor out the AC_REPLACE_FUNCS stuff to its own libraryAdam Jackson1-7/+17
This is all just stuff we wish we had in libc, and some of this gets used in eg. the dmx utilities build, so split it to its own library to avoid pulling in xserver stuff. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-04-26Add a Meson build system alongside autotools.Eric Anholt1-0/+65
This is a work in progress that builds Xvfb, Xephyr, Xwayland, Xnest, and Xdmx so far. The outline of Xquartz/Xwin support is in tree, but hasn't been built yet. The unit tests are also not done. The intent is to build this as a complete replacement for the autotools system, then eventually replace autotools. meson is faster to generate the build, faster to run the bulid, shorter to write the build files in, and less error-prone than autotools. v2: Fix indentation nits, move version declaration to project(), use existing meson_options for version-config.h's vendor name/web. Signed-off-by: Eric Anholt <eric@anholt.net> Acked-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-26Use #ifdef instead of #if for features to make Meson easier.Eric Anholt1-8/+8
We mostly use #ifdef throughout the tree, and this lets the generated config.h files just be #define TOKEN instead of #define TOKEN 1. Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net>
2017-04-26os: Handle SIGABRTMichel Dänzer2-0/+7
Without this, assertion failures can make life hard for users and those trying to help them. v2: * Change commit log wording slightly to "can make life hard", since apparently e.g. logind can alleviate that somewhat. * Set default handler for SIGABRT in hw/xfree86/common/xf86Init.c:InstallSignalHandlers() and hw/xquartz/quartz.c:QuartzInitOutput() (Eric Anholt) Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2017-04-25Rewrite the byte swapping macros.Eric Anholt1-2/+2
The clever pointer tricks were actually not working, and we were doing the byte-by-byte moves in general. By just doing the memcpy and obvious byte swap code, we end up generating actual byte swap instructions, thanks to optimizing compilers. text data bss dec hex filename before: 2240807 51552 132016 2424375 24fe37 hw/xfree86/Xorg after: 2215167 51552 132016 2398735 249a0f hw/xfree86/Xorg Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2017-03-27dpms: Consolidate a bunch of stuff into Xext/dpms.cAdam Jackson1-0/+1
Most of this is a legacy of the old "extmod" design where you could load _some_ extensions dynamically but only if the server had been built with support for them in the first place. Note that since we now only initialize the DPMS extension if at least one screen supports it, we no longer need DPMSCapableFlag: if it would be false, we would never read its value. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-02os: Squash missing declaration warning for timingsafe_memcmpAdam Jackson1-0/+3
timingsafe_memcmp.c:21:1: warning: no previous prototype for ‘timingsafe_memcmp’ [-Wmissing-prototypes] timingsafe_memcmp(const void *b1, const void *b2, size_t len) Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-03-01Brown bag commit to fix 957e8d (arc4random_buf() support)Matthieu Herrb1-1/+1
- typo in #ifdef check - also need to add AC_CHECK_FUNCS([arc4random_buf]) Reported-by Eric Engestrom. Thanks Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2017-02-28auth: remove AuthToIDFunc and associated functions. Not used anymore.Matthieu Herrb5-56/+3
And the current code for MitToId has a use-after-free() issue. [Also remove the actual implementations - ajax] Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2017-02-28Use arc4random_buf(3) if available to generate cookies.Matthieu Herrb1-0/+7
Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2017-02-28Use timingsafe_memcmp() to compare MIT-MAGIC-COOKIES CVE-2017-2624Matthieu Herrb2-1/+46
Provide the function definition for systems that don't have it. Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2017-02-27os: log a bug whenever WriteToClient is called from the input threadPeter Hutterer2-0/+11
The input thread should generate events, not send them. Make it easier to find the instances where it's doing so. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2017-02-23os: Fix iteration over busfaultsChris Wilson1-6/+7
Fixes a regression from commit 41da295eb50fa08eaacd0ecde99f43a716fcb41a Author: Keith Packard <keithp@keithp.com> Date: Sun Nov 3 13:12:40 2013 -0800 Trap SIGBUS to handle truncated shared memory segments that causes the SIGBUS handler to fail to chain up correctly and corrupts nearby memory instead. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-23inputthread: Initialise inputThreadInfo->changed before useChris Wilson1-0/+2
==8734== Thread 2 InputThread: ==8734== Conditional jump or move depends on uninitialised value(s) ==8734== at 0x2FDB05: InputThreadDoWork (inputthread.c:333) ==8734== by 0x6924423: start_thread (pthread_create.c:333) ==8734== by 0x6C229BE: clone (clone.S:105) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-20os: remove unused define MAX_TIMES_PEROlivier Fourdan1-1/+0
Remove leftover from commit e10ba9e, MAX_TIMES_PER is not used anymore. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-14DetermineClientCmd: try using /proc/pid/cmdline on Solaris tooAlan Coopersmith1-39/+47
Solaris 11.3.5 introduced support for /proc/pid/cmdline, so try it first, and if we can't open it, then fallback to /proc/pid/psinfo as we did before. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>