summaryrefslogtreecommitdiff
path: root/src/secure.rs
diff options
context:
space:
mode:
authortylermurphy534 <tylermurphy534@gmail.com>2022-11-10 19:23:21 -0500
committertylermurphy534 <tylermurphy534@gmail.com>2022-11-10 19:23:21 -0500
commitf528a215f5effb748c04ee7f646f3ac0b34a8d29 (patch)
tree66ab58ec37e1264cb305d3d749b78fcde7dfc19b /src/secure.rs
parentfinalize adding groups (diff)
downloadcrab-f528a215f5effb748c04ee7f646f3ac0b34a8d29.tar.gz
crab-f528a215f5effb748c04ee7f646f3ac0b34a8d29.tar.bz2
crab-f528a215f5effb748c04ee7f646f3ac0b34a8d29.zip
add doc string for elevate_privlages
Diffstat (limited to 'src/secure.rs')
-rw-r--r--src/secure.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/secure.rs b/src/secure.rs
index 352e02b..13d67b0 100644
--- a/src/secure.rs
+++ b/src/secure.rs
@@ -40,6 +40,12 @@ pub fn read_file(dir: &str, file: &str) -> Option<String> {
}
+/// Ekevate tge oruvukages if the current process
+/// #### Arguments
+/// * `uid` - The uid to set the process to
+/// * `gid` - The gid to set the process to
+/// #### Returns
+/// If the process failes to elevate, it returns false
pub fn elevate_privilages(uid: u32, gid: u32) -> bool {
if unistd::setuid(Uid::from(uid)).is_err() {
return false;
@@ -92,4 +98,4 @@ fn check_file_permissions(uid: u32, gid: u32, mode: u32, path: &str) -> bool {
/// Get the path of a file given a directory and file name
fn path(dir: &str, file: &str) -> String {
return format!("{}/{}.persist", dir, file);
-} \ No newline at end of file
+}