mirror of
https://github.com/iv-org/inv_sig_helper.git
synced 2025-01-15 16:12:21 +01:00
Add optional socket permissions argument (#50)
This commit is contained in:
parent
7809bedfbf
commit
63a8d8166f
2 changed files with 10 additions and 2 deletions
|
@ -2,6 +2,7 @@ use lazy_regex::{regex, Lazy};
|
|||
use regex::Regex;
|
||||
|
||||
pub static DEFAULT_SOCK_PATH: &str = "/tmp/inv_sig_helper.sock";
|
||||
pub static DEFAULT_SOCK_PERMS: u32 = 0o755;
|
||||
pub static DEFAULT_TCP_URL: &str = "127.0.0.1:12999";
|
||||
|
||||
pub static TEST_YOUTUBE_VIDEO: &str = "https://www.youtube.com/watch?v=jNQXAC9IVRw";
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -4,11 +4,11 @@ mod opcode;
|
|||
mod player;
|
||||
|
||||
use ::futures::StreamExt;
|
||||
use consts::{DEFAULT_SOCK_PATH, DEFAULT_TCP_URL};
|
||||
use consts::{DEFAULT_SOCK_PATH, DEFAULT_SOCK_PERMS, DEFAULT_TCP_URL};
|
||||
use jobs::{process_decrypt_n_signature, process_fetch_update, GlobalState, JobOpcode};
|
||||
use opcode::OpcodeDecoder;
|
||||
use player::fetch_update;
|
||||
use std::{env::args, sync::Arc};
|
||||
use std::{env::args, sync::Arc, fs::set_permissions, fs::Permissions, os::unix::fs::PermissionsExt};
|
||||
use env_logger::Env;
|
||||
use tokio::{
|
||||
fs::remove_file,
|
||||
|
@ -89,6 +89,13 @@ async fn main() {
|
|||
}
|
||||
}
|
||||
};
|
||||
let socket_perms: u32 = match args.get(2) {
|
||||
Some(stringref) => u32::from_str_radix(stringref, 8).expect(
|
||||
"Socket permissions must be an octal from 0 to 777!"),
|
||||
None => DEFAULT_SOCK_PERMS,
|
||||
};
|
||||
let perms = Permissions::from_mode(socket_perms);
|
||||
let _ = set_permissions(socket_url, perms);
|
||||
loop_main!(unix_socket, state);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue