Commit Graph

38 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
980385e2ec xext: namespace: fix printf format string
../Xext/namespace/hook-init-rootwindow.c: In function ‘hookInitRootWindow’:
../Xext/namespace/hook-init-rootwindow.c:38:21: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘XID’ {aka ‘long unsigned int’} [-Wformat=]
   38 |             XNS_LOG("<%s> actual root 0x%0" PRIx32 "\n", walk->name, walk->rootWindow->drawable.id);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                                |
      |                                                                                                XID {aka long unsigned int}
../Xext/namespace/namespace.h:71:50: note: in definition of macro ‘XNS_LOG’
   71 | #define XNS_LOG(...) do { printf("XNS "); printf(__VA_ARGS__); } while (0)
      |                                                  ^~~~~~~~~~~
../Xext/namespace/hook-init-rootwindow.c:38:43: note: format string is defined here
   38 |             XNS_LOG("<%s> actual root 0x%0" PRIx32 "\n", walk->name, walk->rootWindow->drawable.id);
      |                                         ~~^
      |                                           |
      |                                           unsigned int
      |                                         %0lx
../Xext/namespace/hook-init-rootwindow.c:70:17: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘XID’ {aka ‘long unsigned int’} [-Wformat=]
   70 |         XNS_LOG("<%s> virtual root 0x%0" PRIx32 "\n", walk->name, walk->rootWindow->drawable.id);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                             |
      |                                                                                             XID {aka long unsigned int}
../Xext/namespace/namespace.h:71:50: note: in definition of macro ‘XNS_LOG’
   71 | #define XNS_LOG(...) do { printf("XNS "); printf(__VA_ARGS__); } while (0)
      |                                                  ^~~~~~~~~~~
../Xext/namespace/hook-init-rootwindow.c:70:40: note: format string is defined here
   70 |         XNS_LOG("<%s> virtual root 0x%0" PRIx32 "\n", walk->name, walk->rootWindow->drawable.id);
      |                                      ~~^
      |                                        |
      |                                        unsigned int
      |                                      %0lx

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-10 19:58:21 +01:00
Enrico Weigelt, metux IT consult
b08b8d6256 namespace: hook-resource: fix printf formats
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-10 11:09:48 +01:00
Enrico Weigelt, metux IT consult
81a8619bda dix: replace XACE_CLIENT_ACCESS by direct callback
Replace complicated xace hook by simple and cheap callback.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-07 10:52:54 +02:00
Enrico Weigelt, metux IT consult
8e68c8d514 dix: replace XACE_CLIENT_ACCESS by direct callback
Move the callbacks directly into DIX, since it's actually core infrastructure.
Also simplifying the whole machinery, by just using a simpel CallbackListPtr.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 11:24:13 +02:00
Enrico Weigelt, metux IT consult
f333cac5c2 Xext: namespace: fix NULL derefence on client close
Removing the namespace assignment of killed clients in ClientState-hook
is too early - we still need it later. Using the new ClientDestroyCallback
instead.

Closes: https://github.com/X11Libre/xserver/issues/486
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 16:28:17 +02:00
Enrico Weigelt, metux IT consult
6168868906 dix: replace XACE_SERVER_ACCESS by direct callback
Move the callbacks directly into DIX, since it's actually core infrastructure.
Also simplifying the whole machinery, by just using a simpel CallbackListPtr.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-25 14:27:41 +02:00
Enrico Weigelt, metux IT consult
96b5da5a0d dix: replace XACE_EXT_ACCESS and XACE_EXT_DISPATCH by direct callback
Move the callbacks directly into DIX, since it's actually core infrastructure.
Also simplifying the whole machinery, by just using a simpel CallbackListPtr.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-23 11:37:50 +02:00
Enrico Weigelt, metux IT consult
a324351f67 treewide: drop unnecessary includes of Xi/eglobals.h
Dropping include by sources that don't use anything from this header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-09 14:41:10 +02:00
Enrico Weigelt, metux IT consult
05d88310bd namespace: fix naming in examples, errors and comments
At some places, there's still the word 'contianer' instead of 'namespace'

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-13 11:50:13 +02:00
Enrico Weigelt, metux IT consult
e98a3a5ff4 namespace: allow "namespace" config directive instead of "container"
The namespace config still has the "container" directive, which should have
been named "namespace". It's a leftover from the original working draft that
was named "container extension".

For the time being, keep backwards compatibility by allowing both tokens
"container" as well as "namespace" for the same directive. But consider the
old token as deprecated, it shouldn't be used anymore and might go away
in the near future.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-12 18:51:16 +02:00
Enrico Weigelt, metux IT consult
ffc80b227a Xnamespace: fix wrong const char* authProto
The authProto field always is assigned to dynamically allocated buffer
(strdup()'ed) and needs to be freed sometimes, so cannot be const.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-05 14:14:26 +02:00
Enrico Weigelt, metux IT consult
2713d7e818 Xnamespace: fix possible memleak
In an OOM error path, we've forgotten an free() call.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-05 11:21:10 +02:00
Enrico Weigelt, metux IT consult
237e5f5e1e Xnamespace: fix printf patterns
For printing 32bit integers, we need to use PR*32 macros.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-31 15:23:05 +02:00
Enrico Weigelt, metux IT consult
ef420e43be Xext: use dixAddAtom()
Use the new helper for creating atoms on demand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-23 12:24:27 +02:00
Enrico Weigelt, metux IT consult
d338bf6e68 namespace: drop unused winIsRoot()
Not used in this file, so no need to keep it around anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-04 17:11:54 +02:00
dasha_uwu
7c64a06ba4 treewide: remove "lib" prefix in static_library names (meson)
this was producing static libraries named "liblibsomething.a"

Signed-off-by: dasha_uwu <dasha@linuxping.win>
2025-07-03 12:01:52 +02:00
Enrico Weigelt, metux IT consult
a353ffddd0 Xnamespace: add support for multiple auth tokens per namespace
Support having more than one auth token per namespace, so separate tokens
can be handed out to clients that are still landing in the same namespace.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
f790bae8dc Xnamespace: initial config loader
This loads the configuration (simple text file) passed via command line.
For now just supporting static configuration, that's loaded on server
startup.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
9c4b4e54d1 Xnamespace: property access hook
Filter property access. Right now just allowed inside same namespace,
or when caller is in root namespace.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
21e890e5fc Xnamespace: whitelist access to some server resources
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
8df9373199 Xnamespace: whitelist some XI operations
Whitelisting some XI operations in various hooks.

Note that some additional filtering needs to be done in send or
receive hook in order to prevent clients to receive possibly sensible
input data from the root window.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
0a90e70a01 Xnamespace: filter access on other clients
Restrict access to other clients within same namespace.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
e92d6ad8e4 Xnamespace: filter client-to-client message sending
Filter message sending by clients. Only sending within the same
namespace is allowed (except for clients in a NS with superpowers,
e.g. root)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
5a2903901a Xnamespace: filter server access
Whitelisting several server access calls that are safe, rejecting the rest.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
e293308ef7 Xnamespace: filter device access
Filter device access, whitelist several commonly used operations that
should be safe (eg. query keyboard layout).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
7afdba1952 Xnamespace: whitelist access to namespace virtual root window
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
fdba5d405d Xnamespace: whitelist certain operations on (real) root window
CreateWindow() needs access to root window, in order to create
top level windows. Whitelisting this operation.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
df56b26ed4 Xnamespace: whitelist resource access for serverClient
The server itself is allowed to access anything w/o restrictions.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
eaa08af7d1 Xnamespace: whitelist resource access within same namespace
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
86dd87d46c Xnamespace: filter transparency
Silently drop transparency flag if namespace isn't allowed to use it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
14008eb698 Xnamespace: filter extension access
Whitelist several extension calls that are safe. Also allow namespaces
to be configured for unrestricted access.

TBD: doesn't actually reject yet

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
81faed9c8c Xnamespace: filter raw mouse motion and keyboard access
Only namespaces with allowMouseOption flag enabled can receive
raw mouse motion events. Raw key press events are always blocked.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
cb1baec84a Xnamespace: isolate root window property access
Redirecting access to root window properties to the per-namespace
virtual root windows. This isolates a lot of communication via root
window, e.g. the cut buffers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
159183c8a0 Xnamespace: create per-namespace fake root windows
For each namespace creating a fake (invisible) root window, which can be
used for storing per-namespace properties (eg. cut buffers), etc.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
5901cb001d Xnamespace: add selection isolation
Selection names (as seen by the client) are internally prefixed with the
namespace ID, so each client can only access those within it's namespace.

If a client within namespace "foo" want's to operate on "PRIMARY",
it actually will be doing so on "<foo>PRIMARY", w/o ever noticing it.
Events will sent back to the client still pointing to "PRIMARY".

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
0698743fde Xnamespace: assign incoming clients to namespaces
The association is done by matching client's and namespace's
authentication token.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
9f8ef921ad Xnamespace: add basic namespace config structures
Adding data structure and initial data for namespace configuration.

Built-in namespaces are ROOT and ANONYMOUS.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
4379f7cc87 Xnamespace: namespace extension skeleton
Add tiny skeleton for the namespace extension. Disabled by default,
can be enabled via +extension arg, but doesn't actually do something yet.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00