Commit Graph

967 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult e536c2035c os: auth: move GenerateRandomData() and make it static
Only used in mitauth.c, so we can move it there and make it static.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:53 +02:00
Enrico Weigelt, metux IT consult e89006d015 os: auth: factor out auth proto names into defines
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:49 +02:00
Enrico Weigelt, metux IT consult 73abb7150d os: auth: consolidate GenerateAuthorization()
No need for having two implementations in os/ vs xwin.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:45 +02:00
Enrico Weigelt, metux IT consult 0da8fc466d os: auth: use strlen() for auth proto name length
No need to explicitly hard-code strings lengths when we can use
standard strlen(). Those code pathes are so cold that trying to
spare a few cycled for an (usually inlined) strlen() doesn't seem
to justify any extra care.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:41 +02:00
Enrico Weigelt, metux IT consult 58e661e1cc os: auth: improve readability and robustness of auth proto list
The code is easier to understand, but also more robust (eg. against struct
layout changes) if structs are initialized with explicit field names
instead of as lists.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:37 +02:00
Enrico Weigelt, metux IT consult 5f619d862d os: use calloc() instead of malloc()
Using calloc() instead of malloc() as preventive measure, so there
never can be any hidden bugs or leaks due uninitialized memory.

The extra cost of using this compiler intrinsic should be practically
impossible to measure - in many cases a good compiler can even deduce
if certain areas really don't need to be zero'd (because they're written
to right after allocation) and create more efficient machine code.

The code pathes in question are pretty cold anyways, so it's probably
not worth even thinking about potential extra runtime costs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:49:45 +02:00
Enrico Weigelt, metux IT consult fd3d162331 os: xdmcp: handle allocation failure
| ../os/xdmcp.c: In function ‘get_mcast_options’:
| ../os/xdmcp.c:1527:27: warning: dereference of possibly-NULL ‘mcastinfo’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|  1527 |             mcastinfo->ai = firstai;
|       |             ~~~~~~~~~~~~~~^~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:35:48 +02:00
Enrico Weigelt, metux IT consult c389f28af0 os: util: protect set_font_authorizations() from allocation failure
| ../os/utils.c: In function ‘set_font_authorizations’:
| ../os/utils.c:863:14: warning: dereference of possibly-NULL ‘result’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   863 |         *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
|       |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:35:45 +02:00
Enrico Weigelt, metux IT consult eb09c17a54 os: ospoll_create(): protect from allocation failure
| ../os/ospoll.c: In function ‘ospoll_create’:
| ../os/ospoll.c:229:22: warning: dereference of possibly-NULL ‘ospoll’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   229 |     ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|       |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:35:42 +02:00
Enrico Weigelt, metux IT consult ed289f734b os: don't ever try to mess with stderr / fd 2
1. We've got some ancient code here that's trying to open stderr (fd 2) itself,
   in case it cannot write there for strange reason. POSIX defines the three
   standard streams (and associated fd's) to be available on program startup
   (when main() is reached). One needs a sledgehammer for breaking a system
   so much that this doesn't work anymore - even calling a program directly
   from /etc/inittab does provide them.

2. The current implementation is not POSIX conformant - it should use freopen(),
   and it leaks FILE structure.

3. stderr is set to buffered mode, quite the opposite of POSIX - it states
   stderr shall NOT be buffered. Simple and obvious reason: not risking vital
   error information getting lost.

4. Placing The logfile in /usr/adm - an ancient, pre-FHS, directory that rarely
   exists on modern systems. That's even hardcoded, instead of derived from
   build-time given installation pathes.

Conculusio: obsolete and broken, thus removing it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:32:00 +02:00
Enrico Weigelt, metux IT consult 6a01f488c8 os: drop self-limiting resources
It's only rarely used and can be easily achieved by generic means,
eg. via ulimit or supervisor settings.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:31:57 +02:00
Alan Coopersmith f988558348 os: remove unused definition of BUGADDRESS
We stopped including this in error messages back in 2008

Clears warning from clang 19.1.7:

os/utils.c:1338:9: warning: macro is not used [-Wunused-macros]
 1338 | #define BUGADDRESS BUILDERADDR
      |         ^

Fixes: ef77e4c44 ("Remove useless commentary from environment and argument processing.")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1910>
2025-04-19 17:02:16 +00:00
Alan Coopersmith b490578242 os: connection.c should include header that defines GrabInProgress
Clears warning from clang 19.1.7:

os/connection.c:133:5: warning: no previous extern declaration for
 non-static variable 'GrabInProgress' [-Wmissing-variable-declarations]
  133 | int GrabInProgress = 0;
      |     ^

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1910>
2025-04-19 17:02:15 +00:00
Enrico Weigelt, metux IT consult 628e94b164 os: let vpnprintf() accept %X
Several pieces of the code, as well as drivers are using %X, which
we don't support, so leading to error messages like this:

[2025-02-27 14:28:44] BUG: 'if (f[f_idx])'
[2025-02-27 14:28:44] BUG: ../xserver/os/log.c:538 in vpnprintf()
[2025-02-27 14:28:44] Unsupported printf directive 'X'
[2025-02-27 14:28:44]
[2025-02-27 14:28:44] Backtrace:
[2025-02-27 14:28:44] unw_get_proc_name failed: no unwind info found [-10]
[2025-02-27 14:28:44] 0: /usr/lib/Xorg (?+0x0) [0x5f4d1261bc47]
[2025-02-27 14:28:44] 1: /usr/lib/Xorg (LogVHdrMessageVerb+0x10f) [0x5f4d1261ca3f]
[2025-02-27 14:28:44] 2: /usr/lib/Xorg (LogHdrMessageVerb+0x85) [0x5f4d1261cae5]
[2025-02-27 14:28:44] 3: /usr/lib/Xorg (xf86VDrvMsgVerb+0x54) [0x5f4d12636604]
[2025-02-27 14:28:44] 4: /usr/lib/Xorg (xf86DrvMsg+0x97) [0x5f4d126367d7]
[2025-02-27 14:28:44] 5: /usr/lib/Xorg (xf86PrintEDID+0x545) [0x5f4d12654315]
[2025-02-27 14:28:44] 6: /usr/lib/Xorg (xf86OutputSetEDID+0x1bd) [0x5f4d12657e0d]

In the longer run, we'll have to decide whether we actually want to
implement the upper-case directive or change all callers to lower-case.

But for now it's better to just accept %X and interpret it as lower-case,
in order to fix those error messages. Whether it's printed as upper or
lower case is more or less an aesthetic matter.

Reported-By: guido iodice <guido.iodice@gmail.com>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1846>
2025-02-28 12:51:44 +01:00
Enrico Weigelt, metux IT consult 1dc648b1b7 os: drop unused TimerCheck()
This isn't used anywhere, so can be dropped.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1789>
2025-02-23 17:46:13 +00:00
Enrico Weigelt, metux IT consult d973c43810 os: unexport SetCriticalOutputPending()
Not used by any drivers/modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1814>
2025-02-23 17:39:18 +00:00
Enrico Weigelt, metux IT consult 6c88eb0cc4 misc.h: unexport compare_version()
Not used by any external modules, so no need to keep it in public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1807>
2025-02-18 11:17:40 +00:00
Enrico Weigelt, metux IT consult 804b2c081b os: unexport CloseWellKnownConnections()
Not used by any modules, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult 0d95b53a20 os: unexport ResetWellKnownSockets()
Not used by any modules (and not supposed to be), so should not
be exported at all.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult dd05532b38 os: unexport CreateWellKnownSockets()
Not used by any modules (and not supposed to be), so should not
be exported at all.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult 59b39ee6ee os: unexport NotifyParentProcess()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult c9ee4245a2 os: unexport ResetOsBuffers()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult 583dbe832d os: unexport FlushIfCriticalOutputPending()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult be16616715 os: unexport FlushAllOutput()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult c6b223459c os: unexport ResetCurrentRequest()
Not used by any external modules, so no need to keep it in public API.

Since it's used by DRI, still needs the _X_EXPORT flag, as long as DRI
is a dynamically loaded module.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:45 +00:00
Enrico Weigelt, metux IT consult 189a70dfb2 os: unexport InsertFakeRequest()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult ba665948f6 os: unexport WriteFdToClient()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult effe8d66bd os: unexport ReadRequestFromClient()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult 9b0c3c62f2 os: unexport ListenOnOpenFD()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult d637e1d284 os: unexport AddClientOnOpenFD()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult a84ae08526 os: unexport ClientAuthorized()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult c6b8207342 os: unexport AuthorizationIDOfClient()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult 1f27d3d653 os: unexport ClientIsLocal()
Not used by any modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1790>
2025-02-18 10:53:44 +00:00
Enrico Weigelt, metux IT consult 346d5f5c35 os: move BUG_*() macros to own private header
These macros aren't used by any external modules, so no need
to keep them public. Moving them into private header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1804>
2025-02-17 19:32:48 +00:00
Enrico Weigelt, metux IT consult 6c24e53a89 os: drop `upstart` specific SIGSTOP signaling logic
Upstart is long dead, discontinued a decade ago, so there's no
need to keep around a special signaling logic just for it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1791>
2025-02-14 14:25:28 +01:00
Enrico Weigelt, metux IT consult 5b6f2292a3 os: drop win32-only System() function
Not used anymore, so it can be dropped.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1778>
2025-02-11 09:53:59 +01:00
Randy Palamar 5677de586f os/osinit: fix build when execinfo.h is missing
HAVE_BACKTRACE gets set on systems with libunwind however
execinfo.h may be missing (on *BSD or musl for example).
HAVE_EXECINFO_H has been defined by the build system for a long
time but previously not used.

Signed-off-by: Randy Palamar <randy@rnpnr.xyz>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1207>
2025-02-08 15:22:29 +00:00
Enrico Weigelt, metux IT consult 8e8bf63908 os: move AbortServer() to os/utils.c
This function doesn't much to do with logging, except for being
called once by FatalError(). It's better placed in utils.c

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1678>
2025-02-07 18:45:35 +01:00
Doug Johnson e0588d2110 os: backtrace: Fix -Wincompatible-pointer-types compiler error on 32-bit targets
```
../os/backtrace.c: In function ‘print_registers’:
../os/backtrace.c:94:52: error: passing argument 3 of ‘_ULarm_get_reg’ from incompatible pointer type [-Wincompatible-pointer-types]
   94 |         ret = unw_get_reg(&cursor, regs[i].regnum, &val);
      |                                                    ^~~~
      |                                                    |
      |                                                    uint64_t * {aka long long unsigned int *}
```
Switched to libunwind's un_word_t type and PRIxPTR fprintf fmt specification

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1763>
2025-02-07 16:58:02 +02:00
Enrico Weigelt, metux IT consult e3cbde9914 include: unexport no*Extension flags
Most of these flags aren't used by any drivers, so no need to keep them
exported. Only three exceptions: composite, Panoramix/Xinerama and Xv.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1519>
2025-02-07 12:00:58 +01:00
Enrico Weigelt, metux IT consult 356e18dcc6 os: move out extension disable flags to corresponing extensions
The OS abstraction isn't really the right place for those flags,
they are're probably better off in their corresponding extensions.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1519>
2025-02-07 12:00:53 +01:00
Enrico Weigelt, metux IT consult f4eb217f11 os: log: replace VErrorF() by LogVMessageVerb()
Since LogVMessageVerb() is now signal safe, we can use this one instead.
Leaving VErrorF() macro for backwards compat with drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:27 +00:00
Enrico Weigelt, metux IT consult 9652bc73e2 xwin: drop duplicate OsVendorVErrorF()
It really doesn't seem to be necessary to protect a LogVMessageVerb()
call by extra mutex on windows only, while obviously not needed on
any other platform.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:27 +00:00
Enrico Weigelt, metux IT consult da22bc9ae0 os: log: replace VErrorFSigSafe() by VErrorF()
Since VErrorF() is now signal safe, we can use this one instead.
Leaving VErrorFSigSafe() macro for backwards compat with drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:27 +00:00
Enrico Weigelt, metux IT consult 2d18c353b4 os: log: replace ErrorFSigSafe() by ErrorF()
Since ErrorF() is now signal safe, we can use this one instead.
Leaving ErrorFSigSafe() macro for backwards compat with drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:27 +00:00
Enrico Weigelt, metux IT consult dd37cc4855 os: log: replace LogMessageVerbSigSafe() by LogMessageVerb()
Since LogMessageVerb() is now signal safe, we can use this one instead.
Leaving LogMessageVerbSigSafe() macro for backwards compat with drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:27 +00:00
Enrico Weigelt, metux IT consult 5962211612 os: log: make LogVMessageVerb() signal safe
We already have our own signal safe vnsprintf() implementation, which is used
for formatting log messages while being in a signal handler, there's no need
to have two separate implementations of all the logging functions.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:27 +00:00
Enrico Weigelt, metux IT consult 71b8953597 os: log: consolidate log formatting functions
Simplify log formatting functions and remove redundancies, e.g.:

* common function for line termination
* copy prefix directly instead of *printf'ing it
* now just exactly one LogSWrite() call per message
  (good for other log targets like syslog)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:27 +00:00
Enrico Weigelt, metux IT consult f5fe8a6379 os: log: drop unused variables
Drop some unneeded variabes, whose values can be computed at compile-time.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1691>
2025-02-06 23:35:26 +00:00
Enrico Weigelt, metux IT consult 161c3c8398 os: drop obsolete LogHdrMessage()
This function isn't used anywhere, so no need to keep it around.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1677>
2025-02-06 19:57:52 +00:00