Commit Graph

1156 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
e1dc65bdf0 os: drop ifdef NO_PART_NET code path
This symbol is never defined, so that code path isn't needed.
Disabling "partial network" (thus, not arborting when not all
requested interfaces can't be bound) can be done via command line.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-02-10 11:48:42 +01:00
Enrico Weigelt, metux IT consult
4642d6207f os: unexport SeatId and move it to dix settings
Not used by any external module/driver, so no need to keep it
public. Also move it to the new dix settings code and rename it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-02-03 11:34:14 +01:00
Enrico Weigelt, metux IT consult
885ba96ff6 os: xtrans: drop some unused defines
The TRANS_LOCAL_*_INDEX defines aren't used anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-01-07 10:56:57 +01:00
Alan Coopersmith
2a41522349 os: make FormatInt64() handle LONG_MIN correctly
When compiling with gcc 15.2.0 using -O3 -m64 on Solaris SPARC & x64,
we'd get a test failure of:

Assertion failed: strcmp(logmsg, expected) == 0,
 file ../test/signal-logging.c, line 339, function logging_format

because 'num *= -1' produced a value that was out of the range of the
int64_t it was being stored in.  (Compiling with -O2 worked fine with
the same compiler/configuration/platform though.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2117>
2026-01-01 13:23:22 +01:00
b-aaz
d334e01e31 os: osdep: Disabled a section on Cygwin that was redundant.
The section does some mappings between POSIX and windows APIs that are
already handled by Cygwin. This caused build errors on Cygwin due to
redefinition of things like the sigset_t struct.

Signed-off-by: b-aaz <b-aazbsd@proton.me>
2025-12-21 12:59:03 +01:00
b-aaz
7f7efe8195 Revert 9a82f5c, bring back Cygwin support.
Brought back the code removed in that commit so that we can bring back
Cygwin support.
Small changes are done in the process of resolving conflicts against the
current head.

Some checks have not been reverted, because they were not necessary
anymore.

Signed-off-by: b-aaz <b-aazbsd@proton.me>
2025-12-21 12:59:03 +01:00
Mikhail Dmitrichenko
252dda933a os: avoid closing null fd at Fopen
In `Fopen` function variable `iop` may store NULL as a result of `fopen`
call. In this case, if later privileges couldn't be restored (`seteuid`
call fails), further `fclose(iop)` call will cause runtime error.

This commit adds check `iop` for NULL before calling `fclose` to prevent
potential NULL pointer dereference.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2115>
2025-12-19 18:31:23 +01:00
b-aaz
a5f87f20b2 os: Cleaned up the log functions and handled return values.
The old function used int for write() return values, that could overflow.
And the return values of the write calls were discarded and not checked.

Now if the write() to the log file fails, a warning will be logged to
stderr and the log message will be appended after the warning.

If writes to stderr fail, a warning will be logged to stdout and the log
message will be appended after the warning.

If writes to stdout fail, we can't really do anything else and will
continue on silently.

Also used the length returned by strftime for the next write call to
eliminate an extra use of strlen.

The -1 was also removed from the buflen argument of strftime because it
was unnecessary.

Did some small formatting changes too.

Signed-off-by: b-aaz <b-aazbsd@proton.me>
2025-12-19 12:21:44 +01:00
Enrico Weigelt, metux IT consult
857e397c15 os: Xtranssock: fix (signed) char array subscript
>  In file included from /usr/include/ctype.h:100,
>                   from ../include/misc.h:154,
>                   from ../include/os.h:51,
>                   from ../os/Xtransint.h:256,
>                   from ../os/transport.c:57:
> ../os/Xtranssock.c: In function ‘is_numeric’:
> ../os/Xtranssock.c:217:19: error: array subscript has type ‘char’ [-Werror=char-subscripts]
>    217 |  if (!isdigit (str[i]))
>        |                   ^

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-14 11:27:49 +01:00
Enrico Weigelt, metux IT consult
9a54f4b908 os: enable UNIX sockets on Mingw32
Mingw32 also supports unix sockets, so no need to disable them here.

Since it's now always enabled, follow-up commits can now drop all the
extra #ifdef's on UNIXCONN and so reduce complexity.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-14 11:03:00 +01:00
Enrico Weigelt, metux IT consult
16d4d44551 os: drop symbol TCPCONN
It's been always enabled for aeons, so no practical need to
disable it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-13 15:59:07 +01:00
Enrico Weigelt, metux IT consult
7ba4f6a2b6 os: xtrans: define trans_mkdir() when UNIXCONN is enabled
trans_mkdir() is needed for unix sockets, so the correct switch is
UNIXCONN, instead of WIN32.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-13 15:46:11 +01:00
Alan Coopersmith
1e5c56eb9a os: Use EVP APIs when building with OpenSSL 3
Avoids deprecation warnings for old SHA1 APIs in OpenSSL 3.0 and later

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1845
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2066>
2025-12-12 14:28:18 +01:00
Enrico Weigelt, metux IT consult
3d742db3a9 os: xtrans: declare trans_mkdir() static function only if needed
Win32/mingw32 doesn't need it, so compiler warns on it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-12 13:47:24 +01:00
Enrico Weigelt, metux IT consult
7389686d6d os: xtrans: drop status pointer from *Accept() functions
Nobody's ever looking at this value, so no need to keep it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-12 13:47:15 +01:00
Enrico Weigelt, metux IT consult
c9d9da7cf0 os: xtrans: drop obsolete LOCALCONN code paths
the symbol LOCALCONN is never defined, so these code pathes are dead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-12 13:26:20 +01:00
Enrico Weigelt, metux IT consult
faa1b1e27a os: xtransutil: drop unused FAIL_HARD code pathes
The symbol is never defined anywhere, so these dead code pathes
can be removed entirely.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-12 13:18:50 +01:00
Enrico Weigelt, metux IT consult
eb082584b6 os: utils: ‘VerifyDisplayName: fix array subscript signedness
../os/utils.c: In function ‘VerifyDisplayName’:
../os/utils.c:624:23: warning: array subscript has type ‘char’ [-Wchar-subscripts]
  624 |         if (!isdigit(d[i])) {
      |                       ^

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-11 20:15:02 +01:00
Enrico Weigelt, metux IT consult
df0f1cc687 os: Xtranssock: fix printf format warning
> ../os/Xtranssock.c: In function '_XSERVTransSocketReopen':
> ../os/Xtranssock.c:449:49: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
>         prmsg (1, "SocketReopen: invalid portlen %d\n", portlen);
>                                                  ~^     ~~~~~~~
>                                                  %ld

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-10 15:11:27 +01:00
Enrico Weigelt, metux IT consult
19ee44b607 treewide: drop including <dix-config.h> from private includes
All .c sources must include <dix-config.h> at the very first.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 19:50:44 +01:00
Enrico Weigelt, metux IT consult
f5a70d968c include: fix warning on XNFvasprintf() prototype
> ../os/xprintf.c: In function ‘XNFvasprintf’:
> ../os/xprintf.c:84:5: warning: function ‘XNFvasprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
>    84 |     int size = vasprintf(ret, format, va);
>       |     ^~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 17:28:58 +01:00
Enrico Weigelt, metux IT consult
71b25119f7 os: ResetHosts(): fix warning on potentially unitialized memory
> In function ‘ConvertAddr’,
>    inlined from ‘ResetHosts’ at ../os/access.c:1014:26:
> ../os/access.c:1540:25: warning: ‘saddr’ may be used uninitialized [-Wmaybe-uninitialized]
>  1540 |         if (16777343 == *(long *) &((struct sockaddr_in *) saddr)->sin_addr)
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../os/access.c: In function ‘ResetHosts’:
> ../os/access.c:908:7: note: ‘saddr’ declared here
>   908 |     } saddr;
>       |       ^~~~~

The union isn't needed at all, we're just using one of the fields anyways.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 15:10:43 +01:00
Enrico Weigelt, metux IT consult
409e721e98 os: merge os/xstrans.c and os/transport.c
Since xtrans is now in-tree and already have been trimmed down
for only things needed by the Xserver, the split between xstrans.c
and transport.c isn't needed anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-03 13:15:58 +01:00
Enrico Weigelt, metux IT consult
e0ddc62bd0 os: add header for math related functions (possibly OS optimized)
Adding a new header for math related functions, beginning with new
MIN/MAX macros, which will be used by subsequent commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:58:33 +01:00
Enrico Weigelt, metux IT consult
2fe5e2519a os: move OsCommRec/Ptr and related functions into own header
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:36:00 +01:00
Enrico Weigelt, metux IT consult
fda3695872 os: move MILLI_PER_MIN and MILLI_PER_SECOND to osdep.h
Not needed in public SDK, so move them into a private header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 11:58:45 +01:00
Enrico Weigelt, metux IT consult
07d6ca4254 os: move ComputeLocalClient() prototype to auth.h
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 10:45:36 +01:00
Enrico Weigelt, metux IT consult
ce75ddb0bb os: move OsVendorFatalError() and OsVendorInit() to ddx_priv.h
These are implemented by DDX, thus should be declared in ddx_priv.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 10:44:58 +01:00
Enrico Weigelt, metux IT consult
5532917d76 os: move AllowByteSwappedClients setting into DIX
Adding new source and header that's going to host all DIX
settings (set via cmdline or xf86 config file) in the future.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 10:44:23 +01:00
Tautvis
e00b4b55c8 os: utils.c ignore '-reset' and '-noreset' command line arguments
Certain display managers (for example SDDM) starts X server with
-noreset flag and it is not user configurable. This patch add code to
ignore -noreset and -reset command line arguments to prevent X server
crash due to unknown arguments.

Signed-off-by: Tautvis <gtautvis@gmail.com>
2025-11-22 13:25:52 +01:00
Enrico Weigelt, metux IT consult
0b3aaa0369 os: drop ResetWellKnownSockets() and XdmcpReset()
Since internal server reset is gone, those aren't needed anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:22:44 +01:00
Enrico Weigelt, metux IT consult
416f69eb88 include: misc.h: unexport lowbit() macro
Not used by any drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:20:07 +01:00
Enrico Weigelt, metux IT consult
b0ac921156 dix: unexport GrabInProgress
Only internally within OS layer and screen saver logic,
so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 17:42:29 +01:00
Enrico Weigelt, metux IT consult
f161a014f1 os: xdmcp: drop server reset support
Not needed anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 16:36:04 +01:00
Enrico Weigelt, metux IT consult
064e5f2ddf os: drop OsCleanup()
Since we're always terminating now, everbody can call UnlockServer()
directly, so we don't need that extra function anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 11:19:02 +01:00
Enrico Weigelt, metux IT consult
f27e12c918 dix: drop DE_RESET and associated cmdline args
Drop the -reset flag, so Xserver now either simply continues (w/o going
through internal reset) when last client disconnected or terminates
when -terminate is given.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-18 18:22:25 +01:00
Chase
2fff53d35d Xtransutil.c: minor formatting fix 2025-11-17 13:16:45 +01:00
Enrico Weigelt, metux IT consult
7a8f12361d os: move OS_COMM_* defines into os/connection.c
They're only used inside os/connection.c, so no need to have them
in some header and expose them to other areas.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-10 11:07:58 +01:00
Enrico Weigelt, metux IT consult
b0b9a624d8 os: replace ETEST macro by ossock_wouldblock()
Move this to a little function (which also has a better name now)
inside the already platform specific ossock.c

Also removing the EMSGSIZE check: we're using TCP or local unix
socket, so EMSGSIZE is never returned.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-08 10:46:03 +01:00
Enrico Weigelt, metux IT consult
cd3b208bde os: osdep: drop unused OsFlushFunc
Not used anymore for over two decades now, so no need to keep it around.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-07 19:12:08 +01:00
Enrico Weigelt, metux IT consult
b3a5b5b61c os: drop unused Xscnprintf() and Xvscnprintf()
Not used anywhere (not even in drivers), so no need to keep them anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-07 09:31:48 +01:00
Enrico Weigelt, metux IT consult
7ef8400df5 xfree86: compat: re-add TimeCheck() for proprietary nvidia driver
Yet another very internal function that the proprietary Nvidia driver
is using for unknown reasons.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-28 16:26:44 +01:00
Enrico Weigelt, metux IT consult
b306691c2d win32: move definition of sigset_t to os/osdep.h
Not needed by drivers (there aren't any on win32), so no need to
have it in public SDK header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 19:13:49 +02:00
Enrico Weigelt, metux IT consult
4a75fb14b7 os: unexport ReplyCallback
It's only used by record extension, not used by any drivers at all
(neither FOSS nor proprietary), so it shouldn't be in the public SDK.

Since it's never been used by any driver, it's effectively no ABI change,
so we can safely do this within ABI-25.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 11:05:27 +02:00
Enrico Weigelt, metux IT consult
ca484055c7 dix: unexport screen saver parameters
Not used by any external drivers, so no need to keep them in public
SDK headers. Since they're never used by drivers, it's effectively
not an ABI change, so can safely be done within ABI-25.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 11:01:21 +02:00
Enrico Weigelt, metux IT consult
21fb27735a os: unexport XNFreallocarray()
Not used by any drivers, no no need to keep it in public SDK.
Since it's not used by drivers, it's effectively not an ABI change,
so can be done within ABI-25.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 10:53:15 +02:00
Enrico Weigelt, metux IT consult
f29fb6bb62 present: unexport symbols not used by drivers
these symbols aren't used by any external drivers (not even proprietary
Nvidia), so no need to keep them exported any longer:

 * present_check_flips
 * present_register_complete_notify
 * present_can_window_flip
 * uint32_t FakeScreenFps

Since it's not any *effective* ABI change, can go into current ABI-25 line.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 17:09:43 +02:00
Enrico Weigelt, metux IT consult
74e3f18204 os: unexport inSignalContext
Only used inside OS layer and xfree86 os-support, so no need to keep
it in public SDK.

Since never used by any drivers, it's not an actual ABI change, so
we can safely do it within ABI-25.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 15:58:04 +02:00
Enrico Weigelt, metux IT consult
995398ecde os: rename audit.h to audit_priv.h
Our convention is naming private (non-SDK) headers w/ _priv.h suffix.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 15:56:47 +02:00
Enrico Weigelt, metux IT consult
da42cb968c os: move LogPrintMarkers() declaration into private header
Not exported, not used by any external modules, so no need to have
that declaration in a public SDK header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 11:50:59 +02:00