mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Make it clear that being able to restore root is a failure
This commit is contained in:
		
							parent
							
								
									cd0bae80b6
								
							
						
					
					
						commit
						9dae68eba5
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -197,17 +197,18 @@ static void log_kernel(void) {
 | 
			
		|||
static void drop_permissions(void) {
 | 
			
		||||
	if (getuid() != geteuid() || getgid() != getegid()) {
 | 
			
		||||
		if (setgid(getgid()) != 0) {
 | 
			
		||||
			wlr_log(WLR_ERROR, "Unable to drop root");
 | 
			
		||||
			wlr_log(WLR_ERROR, "Unable to drop root, refusing to start");
 | 
			
		||||
			exit(EXIT_FAILURE);
 | 
			
		||||
		}
 | 
			
		||||
		if (setuid(getuid()) != 0) {
 | 
			
		||||
			wlr_log(WLR_ERROR, "Unable to drop root");
 | 
			
		||||
			wlr_log(WLR_ERROR, "Unable to drop root, refusing to start");
 | 
			
		||||
			exit(EXIT_FAILURE);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (setuid(0) != -1) {
 | 
			
		||||
		wlr_log(WLR_ERROR, "Root privileges can be restored.");
 | 
			
		||||
		exit(EXIT_FAILURE);
 | 
			
		||||
		wlr_log(WLR_ERROR, "Unable to drop root (we shouldn't be able to "
 | 
			
		||||
			"restore it after setuid), refusing to start");
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue