Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
node_modules/ | ||
succeed/target/ | ||
own/target/ | ||
bin/succeed | ||
bin/own |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "own" | ||
version = "0.1.0" | ||
authors = ["chee <chee@snoot.club>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
nix = "0.19" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
cargo build --release | ||
mv target/release/own ../bin | ||
sudo chmod 4750 ../bin/own | ||
sudo chown root:snootauth ../bin/own |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use nix::unistd::{chown, User, Group}; | ||
use std::env; | ||
use std::fs::File; | ||
use std::os::unix::fs::PermissionsExt; | ||
use std::path::PathBuf; | ||
|
||
fn main() -> std::io::Result<()> { | ||
let args: Vec<String> = env::args().collect(); | ||
let snoot = args.get(1).expect("own <snoot> <scope>"); | ||
let scope = args.get(2).expect("own <snoot> <scope>"); | ||
let scope_user = User::from_name(scope).expect("no scope").expect("hoohoo"); | ||
let auth_group = Group::from_name("snootauth").expect("there should be a unix group called snootauth").expect("hoohoo"); | ||
|
||
let path = PathBuf::from(format!("/snoots/auth/sessions/{}.{}", snoot, scope)); | ||
let file = File::open(&path)?; | ||
let metadata = file.metadata()?; | ||
let mut permissions = metadata.permissions(); | ||
permissions.set_mode(0o400); | ||
chown(&path, Some(scope_user.uid), Some(auth_group.gid)).expect("cloudnt set files permission"); | ||
|
||
Ok(()) | ||
} |