mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	
		
			
	
	
		
			37 lines
		
	
	
	
		
			975 B
		
	
	
	
		
			C++
		
	
	
	
	
	
		
		
			
		
	
	
			37 lines
		
	
	
	
		
			975 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * SPDX-License-Identifier: BSD-2-Clause
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include <LibSystem/Wrappers.h>
							 | 
						||
| 
								 | 
							
								#include <LibSystem/syscall.h>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace System {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								ErrorOr<void> pledge(StringView promises, StringView execpromises)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    Syscall::SC_pledge_params params {
							 | 
						||
| 
								 | 
							
								        { promises.characters_without_null_termination(), promises.length() },
							 | 
						||
| 
								 | 
							
								        { execpromises.characters_without_null_termination(), execpromises.length() },
							 | 
						||
| 
								 | 
							
								    };
							 | 
						||
| 
								 | 
							
								    int rc = syscall(SC_pledge, ¶ms);
							 | 
						||
| 
								 | 
							
								    if (rc < 0)
							 | 
						||
| 
								 | 
							
								        return Error::from_errno(-rc);
							 | 
						||
| 
								 | 
							
								    return {};
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								ErrorOr<void> unveil(StringView path, StringView permissions)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    Syscall::SC_unveil_params params {
							 | 
						||
| 
								 | 
							
								        { path.characters_without_null_termination(), path.length() },
							 | 
						||
| 
								 | 
							
								        { permissions.characters_without_null_termination(), permissions.length() },
							 | 
						||
| 
								 | 
							
								    };
							 | 
						||
| 
								 | 
							
								    int rc = syscall(SC_unveil, ¶ms);
							 | 
						||
| 
								 | 
							
								    if (rc < 0)
							 | 
						||
| 
								 | 
							
								        return Error::from_errno(-rc);
							 | 
						||
| 
								 | 
							
								    return {};
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |