Commit graph

202 commits

Author SHA1 Message Date
Will McKinnon 7b530bf448 Revert "merge sway master"
This reverts commit 7460d9f565.
2022-08-15 00:54:07 -04:00
William McKinnon 7460d9f565 merge sway master 2022-04-27 17:33:23 -04:00
Kenny Levinsen 67d3d952b6 Print deprecation notice when running SUID
SUID privilege drop is needed for the "builtin"-backend of libseat,
which copied our old "direct" backend behavior for the sake of
compatibility and ease of transition.

libseat now has a better alternative in the form of seatd-launch. It
uses the normal seatd daemon and libseat backend and takes care of SUID
for us.

Add a soft deprecation warning to highlight our future intent of
removing this code. The deprecation cycle is needed to avoid surprises
when sway no longer drops privileges.

(cherry picked from commit e1db1f8218998c428e8b087dda6660449ef2891a)
2022-01-16 19:26:57 +01:00
Eric Engestrom bb7bb3676d sway: allow IPCs on proprietary drivers
Proprietary drivers require --unsupported-gpu to be allowed, and IPCs
require no option to be passed.

The only way to satisfy both is to run IPCs before checking for
proprietary drivers.
2021-11-14 10:43:09 +03:00
Simon Ser 38020d157d Bump RLIMIT_NOFILE
Wayland compositors handle many file descriptors: client
connections, DMA-BUFs, sync_files, wl_data_device pipes, and so
on. Bump the limit to the max.

Closes: https://github.com/swaywm/sway/issues/6285
2021-10-30 08:19:35 -06:00
Simon Ser b48cb6b0ec Remove --my-next-gpu-wont-be-nvidia
Nvidia has historically been a bad actor in the open-source graphics
ecosystem because they required a special EGLStreams code-path
instead of exposing the de-facto standard GBM API. However, with
their upcoming release they now support GBM as well.

This is a push in the right direction for Nvidia, so there's no
reason we should be more hostile to them than to any other proprietary
driver. Let's remove the --my-next-gpu-wont-be-nvidia flag, and advise
users to use --unsupported-gpu now.

Note, proprietary Nvidia drivers are still unsupported by the Sway
project (just like all other proprietary drivers).
2021-10-19 09:26:06 +02:00
Simon Ser 82d5f12914 Add -Dnoscanout debug option
This can help debugging direct scan-out issues, such as [1].

[1]: https://github.com/swaywm/wlroots/issues/3185
2021-09-20 14:22:35 +02:00
Bartłomiej Burdukiewicz 7c74f01f0a main: removed vc4 detection code.
Signed-off-by: Bartłomiej Burdukiewicz <bartlomiej.burdukiewicz@gmail.com>
2021-04-29 18:04:34 +02:00
Simon Ser 78fc9d0d2d Log wlroots version on startup
Can be useful to make sure a bugfix is included. In the future maybe
the wlroots version string could include a commit hash when built
from source, too.
2021-04-12 16:18:17 +02:00
Manuel Stoeckl 169b90f90b Make command line option lists const 2021-02-04 09:49:06 +01:00
SpizzyCoder 7cf25d3b98 Changed fprintf(stdout,...) to printf(...) for more readable code 2021-01-16 20:24:41 +01:00
Simon Ser a68c6a00ca Route wlroots logs into Sway logging infrastructure
Instead of letting wlroots print messages to stdout, route debugging
messages into Sway's logging functions. This allows a more consistent
output (e.g. if Sway or wlroots changes its output style, they don't get
out-of-sync).

I also added a [wlr] prefix to wlroots messages, not yet sure it's a
good thing.
2020-12-09 23:57:12 -05:00
Simon Ser 6991ac8c70 Handle SIGINT
Gracefully exit on SIGINT, like we do for SIGTERM.
2020-08-11 18:37:11 -04:00
Antonin Décimo a1c6052383 Log empty value if envvar is not defined
If the environment variable is not defined, getenv returns NULL.
Passing a NULL pointer to the "%s" format specifier is undefined
behavior. Even if some implementations output "(null)", an empty
string is nicer.
2020-07-30 22:02:42 -04:00
Simon Ser bf8d23a836 Log Sway version on startup 2020-06-11 08:44:09 -06:00
Brian Ashworth 33a984bbc5 config: fix validation exit code and log level
This makes it so invalid configs will return the exit code 1 when the
validation flag is given. This also reduces the log level to SWAY_ERROR,
which makes it so only the errors are shown. If someone wants more
verbose output, the can use the -V/--verbose or -d/--debug flags.
Additionally, this also makes it so swaybg will not be spawned when
validating the config.
2020-02-11 16:02:11 +01:00
Teddy Reed 31a83bd48d Fix ordering of setgid and setuid
It looks like the code to drop privileges may have been broken via
commit 37f0e1f. That commit reverted the correct order from #911, which
first drops the gid then the uid. If setuid is called first then the
target user may not have the ability to setgid.
2020-02-11 10:17:45 +01:00
thermitegod 29a5ce5f65 Fix compiling with -fno-common 2020-01-24 10:16:59 +01:00
lbonn a6307aed00 Fix various memory leaks
Found with clang-tidy
2019-11-01 12:18:09 -04:00
Simon Ser c41c24d684 Error out on unknown debug flag
Otehrwise it's pretty easy to misremember a flag and think damage=rerender is
enabled when it's not.
2019-09-22 15:17:59 -04:00
Brian Ashworth 9670ccee68 bindings: defer while initiailizing
This adds the logic to defer binding execution while sway is still
initializing. Without this, the binding command would be executed, but
the command handler would return CMD_DEFER, which was being treated as
a failure to run. To avoid partial executions, this will defer all
bindings while config->active is false.
2019-06-12 07:56:41 +03:00
Lane Surface 812651d53e Remove extra inclusion of stdio.h 2019-04-27 20:53:21 -06:00
Brian Ashworth 6961bf2e4c Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and
swaybg are already done
2019-04-14 12:41:59 +03:00
Ryan Dwyer e9a476244d Remove debug tree
This feature has served its purpose. It's better to use IPC now.
2019-03-18 11:29:19 -04:00
Brian Ashworth 20c4d242f6 detect_proprietary: use strncmp
Only the main nvidia module needs to be blocked. Others such as
nvidiafb are benign and do not need to be blocked
2019-03-10 22:16:09 -06:00
hugbubby 37f0e1f1a2 Minor fix of code duplication.
Removes 3~ lines of code that didn't need to be restated.
2019-03-02 00:49:02 +01:00
Rouven Czerwinski aa4ccd845c run_as_ipc_client: free response after running the IPC command
Fixes memory leaks in the form of:

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c799569f2 in ipc_recv_response ../common/ipc-client.c:94
    #2 0x563c79957062 in ipc_single_command ../common/ipc-client.c:138
    #3 0x563c798a56cc in run_as_ipc_client ../sway/main.c:127
    #4 0x563c798a6a3a in main ../sway/main.c:349
    #5 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:32:55 +01:00
Rouven Czerwinski a968a650e2 ipc-client: free payload after sending it over the socket
Fixes memory leaks in the form of:

Direct leak of 20 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c7995b36a in join_args ../common/stringop.c:268
    #2 0x563c798a6a1a in main ../sway/main.c:348
    #3 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:31:05 +01:00
Brian Ashworth 2540e8ea79 Abort early when XDG_RUNTIME_DIR is not set
This aborts sway and displays an error message about XDG_RUNTIME_DIR
not being set without initializing the wl_display or logging any other
information.
2019-02-11 10:11:41 +01:00
Brian Ashworth ee56428b64 Clarify error for options and positional args
When both options and positional arguments are given, sway would print
the error `Don't use options with the IPC client`. Over the past
several months, it seems like users are including this error message in
issues instead of a debug log due to not understanding that the error
message means there is an issue with their command.

This makes the error message more verbose and will hopefully make it so
more users understand that the message is not a bug in sway, but with
the command used.
2019-02-06 19:38:25 +01:00
Connor E e1b8190d2c Initialize server so input manager is available. 2019-02-05 15:39:22 +00:00
Connor E 886789c197 If validating the config, do it as early as possible. 2019-02-05 14:37:22 +00:00
Brian Ashworth f0fd6119cf Cleanup config reading failure error logs
This cleans up the log when sway fails to read a config file. The
following changes have been made:
- A missing error message has been added to the log when the config file
is a directory instead of a regular file
- In main, `goto` statements have been added after the `sway_terminate`
calls instead of wrapping every block in `if (!terminate_request)`
- Unnecessary NULL-checks around calls to free in `main` have been
removed
- Deferred command execution has been extracted to a separate function
and the `Running deferred commands` log message will not be shown when
there are no deferred commands.
2019-01-29 13:18:53 -05:00
emersion 7c72327ab5
Cleanup log_env
SWAY_CURSOR_* are not used anymore. LD_PRELOAD_PATH doesn't exist and has been
replaced with LD_PRELOAD.
2019-01-28 21:59:10 +01:00
M Stoeckl 1211a81aad Replace wlr_log with sway_log
This commit mostly duplicates the wlr_log functions, although
with a sway_* prefix. (This is very similar to PR #2009.)
However, the logging function no longer needs to be replaceable,
so sway_log_init's second argument is used to set the exit
callback for sway_abort.

wlr_log_init is still invoked in sway/main.c

This commit makes it easier to remove the wlroots dependency for
the helper programs swaymsg, swaybg, swaybar, and swaynag.
2019-01-21 12:59:42 +01:00
Brian Ashworth 686b853047 Do not send ipc_event_shutdown from ipc client
In `sway_terminate`, `ipc_event_shutdown` was being sent regardless
which mode sway was running in. When running as an ipc client,
`sway_terminate` should just exit
2019-01-15 22:41:54 +01:00
Drew DeVault 4879d40695
Merge pull request #3144 from emersion/cmd-xwayland
Add xwayland command
2019-01-13 20:42:39 -05:00
Ian Fan a82b8a3c14 Remove readline.c
All occurrences of read_line have been replaced by getline.
peek_line has been absorbed into detect_brace.
2019-01-01 09:01:25 +00:00
Ian Fan c8776fac42 Cleanup list code 2018-12-09 01:15:38 +00:00
Brian Ashworth 5c6f3d7266 Change execute_command to return a list of results
This matches i3's behavior of returning a list of results that contain
the result of each command that was executed. Additionally, the
`parse_error` attribute has been added to the IPC JSON reply.
2018-11-27 21:42:09 -05:00
emersion 3a310f92ab
Replace _XOPEN_SOURCE with _POSIX_C_SOURCE
And make sure we don't define both in the same source file.
2018-11-25 17:19:43 +01:00
emersion 311c7db7e3
Add xwayland command 2018-11-19 17:38:37 +01:00
emersion f90ff1210b
Teardown compositor when failing to drop permissions 2018-11-01 18:50:06 +01:00
emersion 9dae68eba5
Make it clear that being able to restore root is a failure 2018-11-01 18:49:42 +01:00
Ryan Dwyer ebeb759873 Abort if proprietary drivers are in use
The idea here is we don't want users to be blissfully unaware that they
are running unsupported drivers. So we abort on startup, and force the
user to add a specific argument to bypass the check.
2018-10-21 00:01:09 +10:00
Drew DeVault 71aaa7e130 Remove unnecessary comment 2018-10-13 20:51:29 -04:00
Arkadiusz Hiler eed0bc3ebd Add support for installing binaries with DT_RPATH
It's better to use DT_RPATH dynamic section of the elf binary to store
the paths of libraries to load instead of overwriting LD_LIBRARY_PATH
for the whole environment, causing surprises. This solution is much more
transparent and perfectly suitable for running contained installations
of wayland/wlroots/sway.

The code unsetting the LD_LIBRARY_PATH/LD_PRELOAD was also deleted as
it's a placebo security at best - we should trust the execution path
that leads us to running sway, and it's way too late to care about those
variables since we already started executing our compositor, thus we
would be compromised anyway.
2018-09-30 15:37:01 +03:00
Arkadiusz Hiler 1e70f7b19e Turn funcs() into funcs(void)
If they really do not take undefined number of arguments.
2018-09-30 14:09:05 +03:00
Arkadiusz Hiler 00dfb76832 Remove libcap/prctl artifacts
They seem like relics of the pasts, from when we were retaining the
ptrace cap.

Some translations still may need updates.
2018-09-30 13:39:26 +03:00
Ryan Dwyer cb66bbea42 Allow running commands on containers without focusing them
This adds a `con` argument to `execute_command` which allows you to
specify the container to execute the command on. In most cases it leaves
it as `NULL` which makes it use the focused node. We only set it when
executing `for_window` criteria such as when a view maps. This means we
don't send unnecessary IPC focus events, and fixes a crash when the
criteria command is `move scratchpad` (because we can't give focus to a
hidden scratchpad container).

Each of the shell map handlers now check to see if the view has a
workspace. It won't have a workspace if criteria has moved it to the
scratchpad.
2018-09-23 08:39:11 +10:00