mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Refuse to start when SUID is detected
This ensures that those surprised by the deprecation of SUID operation receive an error rather than accidentally having run as root. swaywm/sway@e572805
This commit is contained in:
		
							parent
							
								
									1c80dbd6ef
								
							
						
					
					
						commit
						573a521cf1
					
				
					 2 changed files with 15 additions and 32 deletions
				
			
		
							
								
								
									
										15
									
								
								src/main.c
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								src/main.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -47,6 +47,19 @@ usage(void)
 | 
			
		|||
	exit(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
die_on_detecting_suid(void)
 | 
			
		||||
{
 | 
			
		||||
	if (geteuid() != 0 && getegid() != 0) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if (getuid() == geteuid() && getgid() == getegid()) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	wlr_log(WLR_ERROR, "SUID detected - aborting");
 | 
			
		||||
	exit(EXIT_FAILURE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
send_signal_to_labwc_pid(int signal)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +131,8 @@ main(int argc, char *argv[])
 | 
			
		|||
 | 
			
		||||
	wlr_log_init(verbosity, NULL);
 | 
			
		||||
 | 
			
		||||
	die_on_detecting_suid();
 | 
			
		||||
 | 
			
		||||
	if (!rc.config_dir) {
 | 
			
		||||
		rc.config_dir = config_dir();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue