aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-08-28 16:34:38 +0200
committerLinnea Gräf <nea@nea.moe>2024-08-28 16:34:38 +0200
commitaa5c8ee5a49000d8e0f10ce1c5c1d5a57ae88e25 (patch)
tree9525ded08e2ea48b2c50127208f99327cc9883ea /src
parente4b9a9b40838777d4d017001fef00e1c57efbb0c (diff)
downloadfagit-aa5c8ee5a49000d8e0f10ce1c5c1d5a57ae88e25.tar.gz
fagit-aa5c8ee5a49000d8e0f10ce1c5c1d5a57ae88e25.tar.bz2
fagit-aa5c8ee5a49000d8e0f10ce1c5c1d5a57ae88e25.zip
Add initial stuff for the configHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/config.rs12
-rw-r--r--src/login.rs17
-rw-r--r--src/main.rs2
3 files changed, 30 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index 5e8cc5d..9335cca 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,5 +1,7 @@
use std::path::Path;
+use serde::Deserialize;
+
pub fn ssh_user() -> &'static str {
return "git";
}
@@ -9,3 +11,13 @@ pub fn binary_path() -> &'static str {
pub fn repo_store() -> &'static Path {
return Path::new("/opt/fagit/store/");
}
+
+#[derive(Deserialize, Default)]
+pub struct RepoConfig {
+ pub access: Vec<KeyPermission>,
+}
+
+#[derive(Deserialize)]
+pub struct KeyPermission {
+ key: String,
+}
diff --git a/src/login.rs b/src/login.rs
index ca12c50..8639d35 100644
--- a/src/login.rs
+++ b/src/login.rs
@@ -1,5 +1,6 @@
use std::path::{Path, PathBuf};
+use crate::config::RepoConfig;
use crate::Login;
use clap::Args;
@@ -72,6 +73,22 @@ impl RepoId {
fn repo_path(&self) -> PathBuf {
return Path::join(crate::config::repo_store(), self.0.clone());
}
+
+ fn get_config(&self) -> RepoConfig {
+ let config_process = std::process::Command::new("git")
+ .args([
+ "-C",
+ self.repo_path().to_str().unwrap(),
+ "show",
+ "HEAD:.fagit.toml",
+ ])
+ .output()
+ .unwrap();
+ if !config_process.status.success() {
+ return RepoConfig::default();
+ }
+ toml::de::from_str(&String::from_utf8(config_process.stdout).unwrap()).unwrap()
+ }
}
fn canonicalize_repo(path: &str, user: &UserToken) -> RepoId {
diff --git a/src/main.rs b/src/main.rs
index cb5a926..166f34c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -52,7 +52,7 @@ mod login;
fn find_auth_keys(auth: &Auth) {
if auth.user != config::ssh_user() {
- let authorized_keys_path = Path::new(&auth.home).join(".ssh/authorized_keys_path");
+ let authorized_keys_path = Path::new(&auth.home).join(".ssh/authorized_keys");
let mut data = std::fs::File::open(authorized_keys_path).unwrap();
let mut vec = vec![];
data.read_to_end(&mut vec).unwrap();