From b48cb6b0ec1320ad25fd2c0a1b5118dbe2536060 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 17 Oct 2021 21:18:24 +0200 Subject: 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). --- sway/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sway/main.c') diff --git a/sway/main.c b/sway/main.c index e960c4e2..264fa847 100644 --- a/sway/main.c +++ b/sway/main.c @@ -63,7 +63,7 @@ void detect_proprietary(int allow_unsupported_gpu) { sway_log(SWAY_ERROR, "Proprietary Nvidia drivers are NOT supported. " "Use Nouveau. To launch sway anyway, launch with " - "--my-next-gpu-wont-be-nvidia and DO NOT report issues."); + "--unsupported-gpu and DO NOT report issues."); exit(EXIT_FAILURE); } break; @@ -220,7 +220,6 @@ int main(int argc, char **argv) { {"verbose", no_argument, NULL, 'V'}, {"get-socketpath", no_argument, NULL, 'p'}, {"unsupported-gpu", no_argument, NULL, 'u'}, - {"my-next-gpu-wont-be-nvidia", no_argument, NULL, 'u'}, {0, 0, 0, 0} }; -- cgit v1.2.3 From 38020d157ddb58e756c654e9a2ff203c1562b25b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 21 Oct 2021 21:52:17 +0200 Subject: 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 --- sway/main.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'sway/main.c') diff --git a/sway/main.c b/sway/main.c index 264fa847..2c760524 100644 --- a/sway/main.c +++ b/sway/main.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ static bool terminate_request = false; static int exit_value = 0; +static struct rlimit original_nofile_rlimit = {0}; struct sway_server server = {0}; struct sway_debug debug = {0}; @@ -169,6 +171,33 @@ static bool drop_permissions(void) { return true; } +static void increase_nofile_limit(void) { + if (getrlimit(RLIMIT_NOFILE, &original_nofile_rlimit) != 0) { + sway_log_errno(SWAY_ERROR, "Failed to bump max open files limit: " + "getrlimit(NOFILE) failed"); + return; + } + + struct rlimit new_rlimit = original_nofile_rlimit; + new_rlimit.rlim_cur = new_rlimit.rlim_max; + if (setrlimit(RLIMIT_NOFILE, &new_rlimit) != 0) { + sway_log_errno(SWAY_ERROR, "Failed to bump max open files limit: " + "setrlimit(NOFILE) failed"); + sway_log(SWAY_INFO, "Running with %d max open files", + (int)original_nofile_rlimit.rlim_cur); + } +} + +void restore_nofile_limit(void) { + if (original_nofile_rlimit.rlim_cur == 0) { + return; + } + if (setrlimit(RLIMIT_NOFILE, &original_nofile_rlimit) != 0) { + sway_log_errno(SWAY_ERROR, "Failed to restore max open files limit: " + "setrlimit(NOFILE) failed"); + } +} + void enable_debug_flag(const char *flag) { if (strcmp(flag, "damage=highlight") == 0) { debug.damage = DAMAGE_HIGHLIGHT; @@ -349,6 +378,8 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } + increase_nofile_limit(); + // handle SIGTERM signals signal(SIGTERM, sig_handler); signal(SIGINT, sig_handler); -- cgit v1.2.3 From bb7bb3676deead149c66fbf74b55d3bb4f9d69b5 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Sat, 13 Nov 2021 15:25:58 +0000 Subject: 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. --- sway/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sway/main.c') diff --git a/sway/main.c b/sway/main.c index 2c760524..6c71048b 100644 --- a/sway/main.c +++ b/sway/main.c @@ -342,7 +342,6 @@ int main(int argc, char **argv) { log_kernel(); log_distro(); log_env(); - detect_proprietary(allow_unsupported_gpu); if (optind < argc) { // Behave as IPC client if (optind != 1) { @@ -369,6 +368,8 @@ int main(int argc, char **argv) { return 0; } + detect_proprietary(allow_unsupported_gpu); + if (!server_privileged_prepare(&server)) { return 1; } -- cgit v1.2.3 From 67d3d952b6cd328ffd053ad4f52dc1687e28a56b Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Tue, 11 Jan 2022 11:08:44 +0100 Subject: 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) --- sway/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sway/main.c') diff --git a/sway/main.c b/sway/main.c index 6c71048b..b6f8a8bf 100644 --- a/sway/main.c +++ b/sway/main.c @@ -153,6 +153,9 @@ static void log_kernel(void) { static bool drop_permissions(void) { if (getuid() != geteuid() || getgid() != getegid()) { + sway_log(SWAY_ERROR, "!!! DEPRECATION WARNING: " + "SUID privilege drop will be removed in a future release, please migrate to seatd-launch"); + // Set the gid and uid in the correct order. if (setgid(getgid()) != 0) { sway_log(SWAY_ERROR, "Unable to drop root group, refusing to start"); -- cgit v1.2.3