mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/master' into atomic
This commit is contained in:
		
						commit
						b11c9199a6
					
				
					 4 changed files with 31 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -54,6 +54,8 @@ struct sway_server {
 | 
			
		|||
 | 
			
		||||
struct sway_server server;
 | 
			
		||||
 | 
			
		||||
/* Prepares an unprivileged server_init by performing all privileged operations in advance */
 | 
			
		||||
bool server_privileged_prepare(struct sway_server *server);
 | 
			
		||||
bool server_init(struct sway_server *server);
 | 
			
		||||
void server_fini(struct sway_server *server);
 | 
			
		||||
void server_run(struct sway_server *server);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@
 | 
			
		|||
#include <strings.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <wordexp.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "sway/commands.h"
 | 
			
		||||
#include "sway/config.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -71,21 +72,27 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
 | 
			
		|||
			if (conf) {
 | 
			
		||||
				char *conf_path = dirname(conf);
 | 
			
		||||
				src = malloc(strlen(conf_path) + strlen(src) + 2);
 | 
			
		||||
				if (src) {
 | 
			
		||||
					sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
 | 
			
		||||
				} else {
 | 
			
		||||
				if (!src) {
 | 
			
		||||
					free(conf);
 | 
			
		||||
					wordfree(&p);
 | 
			
		||||
					wlr_log(L_ERROR,
 | 
			
		||||
						"Unable to allocate background source");
 | 
			
		||||
						"Unable to allocate resource: Not enough memory");
 | 
			
		||||
					return cmd_results_new(CMD_FAILURE, "output",
 | 
			
		||||
						"Unable to allocate resources");
 | 
			
		||||
				}
 | 
			
		||||
				sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
 | 
			
		||||
				free(conf);
 | 
			
		||||
			} else {
 | 
			
		||||
				wlr_log(L_ERROR, "Unable to allocate background source");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (!src || access(src, F_OK) == -1) {
 | 
			
		||||
 | 
			
		||||
		if (access(src, F_OK) == -1) {
 | 
			
		||||
			struct cmd_results *cmd_res = cmd_results_new(CMD_FAILURE, "output",
 | 
			
		||||
				"Unable to access background file '%s': %s", src, strerror(errno));
 | 
			
		||||
			free(src);
 | 
			
		||||
			wordfree(&p);
 | 
			
		||||
			return cmd_results_new(CMD_INVALID, "output",
 | 
			
		||||
				"Background file unreadable (%s).", src);
 | 
			
		||||
			return cmd_res;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		output->background = strdup(src);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -360,6 +360,11 @@ int main(int argc, char **argv) {
 | 
			
		|||
 | 
			
		||||
	executable_sanity_check();
 | 
			
		||||
	bool suid = false;
 | 
			
		||||
 | 
			
		||||
	if (!server_privileged_prepare(&server)) {
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (getuid() != geteuid() || getgid() != getegid()) {
 | 
			
		||||
		// Retain capabilities after setuid()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@
 | 
			
		|||
#include <wlr/types/wlr_idle.h>
 | 
			
		||||
#include <wlr/types/wlr_layer_shell.h>
 | 
			
		||||
#include <wlr/types/wlr_linux_dmabuf.h>
 | 
			
		||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
 | 
			
		||||
#include <wlr/types/wlr_primary_selection.h>
 | 
			
		||||
#include <wlr/types/wlr_screenshooter.h>
 | 
			
		||||
#include <wlr/types/wlr_server_decoration.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -26,9 +27,8 @@
 | 
			
		|||
#include "sway/tree/layout.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool server_init(struct sway_server *server) {
 | 
			
		||||
	wlr_log(L_DEBUG, "Initializing Wayland server");
 | 
			
		||||
 | 
			
		||||
bool server_privileged_prepare(struct sway_server *server) {
 | 
			
		||||
	wlr_log(L_DEBUG, "Preparing Wayland server initialization");
 | 
			
		||||
	server->wl_display = wl_display_create();
 | 
			
		||||
	server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
 | 
			
		||||
	server->backend = wlr_backend_autocreate(server->wl_display, NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +37,12 @@ bool server_init(struct sway_server *server) {
 | 
			
		|||
		wlr_log(L_ERROR, "Unable to create backend");
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool server_init(struct sway_server *server) {
 | 
			
		||||
	wlr_log(L_DEBUG, "Initializing Wayland server");
 | 
			
		||||
 | 
			
		||||
	struct wlr_renderer *renderer = wlr_backend_get_renderer(server->backend);
 | 
			
		||||
	assert(renderer);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -98,6 +104,7 @@ bool server_init(struct sway_server *server) {
 | 
			
		|||
		deco_manager, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
 | 
			
		||||
 | 
			
		||||
	wlr_linux_dmabuf_create(server->wl_display, renderer);
 | 
			
		||||
	wlr_export_dmabuf_manager_v1_create(server->wl_display);
 | 
			
		||||
 | 
			
		||||
	server->socket = wl_display_add_socket_auto(server->wl_display);
 | 
			
		||||
	if (!server->socket) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue