mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-22 06:47:56 +01:00
Merge branch 'feature/version-improvements' into development
* feature/version-improvements: Slightly more logging during authentication Switch to shadow-rs --version talks about API version too Start on improving a few version thingies
This commit is contained in:
commit
d35477c806
94
Cargo.lock
generated
94
Cargo.lock
generated
@ -477,6 +477,9 @@ name = "cc"
|
|||||||
version = "1.0.73"
|
version = "1.0.73"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||||
|
dependencies = [
|
||||||
|
"jobserver",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
@ -543,6 +546,26 @@ dependencies = [
|
|||||||
"cache-padded",
|
"cache-padded",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const_format"
|
||||||
|
version = "0.2.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0936ffe6d0c8d6a51b3b0a73b2acbe925d786f346cf45bfddc8341d79fb7dc8a"
|
||||||
|
dependencies = [
|
||||||
|
"const_format_proc_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const_format_proc_macros"
|
||||||
|
version = "0.2.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "constant_time_eq"
|
name = "constant_time_eq"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
@ -820,6 +843,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_dhall",
|
"serde_dhall",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"shadow-rs",
|
||||||
"signal-hook",
|
"signal-hook",
|
||||||
"signal-hook-async-std",
|
"signal-hook-async-std",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
@ -1171,6 +1195,19 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "git2"
|
||||||
|
version = "0.14.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"libc",
|
||||||
|
"libgit2-sys",
|
||||||
|
"log",
|
||||||
|
"url",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glob"
|
name = "glob"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@ -1291,6 +1328,12 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is_debug"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06d198e9919d9822d5f7083ba8530e04de87841eaf21ead9af8f2304efd57c89"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@ -1321,6 +1364,15 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
|
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jobserver"
|
||||||
|
version = "0.1.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.56"
|
version = "0.3.56"
|
||||||
@ -1364,6 +1416,30 @@ version = "0.2.120"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ad5c14e80759d0939d013e6ca49930e59fc53dd8e5009132f76240c179380c09"
|
checksum = "ad5c14e80759d0939d013e6ca49930e59fc53dd8e5009132f76240c179380c09"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libgit2-sys"
|
||||||
|
version = "0.13.4+1.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"libz-sys",
|
||||||
|
"pkg-config",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libz-sys"
|
||||||
|
version = "1.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92e7e15d7610cce1d9752e137625f14e61a28cd45929b6e12e47b50fe154ee2e"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
"vcpkg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lightproc"
|
name = "lightproc"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@ -2283,6 +2359,18 @@ dependencies = [
|
|||||||
"opaque-debug 0.3.0",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shadow-rs"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f47e98e36909e951f4da3908f4475f969bec92a41734dd92e883aaa11c10294b"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"const_format",
|
||||||
|
"git2",
|
||||||
|
"is_debug",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sharded-slab"
|
name = "sharded-slab"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@ -2750,6 +2838,12 @@ dependencies = [
|
|||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vcpkg"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -103,6 +103,8 @@ async-compat = "0.2.1"
|
|||||||
url = "2.2.2"
|
url = "2.2.2"
|
||||||
rustls-native-certs = "0.6.1"
|
rustls-native-certs = "0.6.1"
|
||||||
|
|
||||||
|
shadow-rs = "0.11"
|
||||||
|
|
||||||
[dependencies.rsasl]
|
[dependencies.rsasl]
|
||||||
git = "https://github.com/dequbed/rsasl.git"
|
git = "https://github.com/dequbed/rsasl.git"
|
||||||
rev = "0b5012d0"
|
rev = "0b5012d0"
|
||||||
@ -113,5 +115,8 @@ features = ["unstable_custom_mechanism", "provider", "registry_static", "plain"]
|
|||||||
futures-test = "0.3.16"
|
futures-test = "0.3.16"
|
||||||
tempfile = "3.2"
|
tempfile = "3.2"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
shadow-rs = "0.11"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["modules/*", "api"]
|
members = ["modules/*", "api"]
|
||||||
|
@ -65,12 +65,16 @@ impl AuthenticationSystem for Authentication {
|
|||||||
Ok(Step::Done(data)) => {
|
Ok(Step::Done(data)) => {
|
||||||
self.state = State::Finished;
|
self.state = State::Finished;
|
||||||
|
|
||||||
let uid = pry!(session.get_property::<AuthId>().ok_or(capnp::Error::failed(
|
let uid = pry!(session.get_property::<AuthId>().ok_or_else(|| {
|
||||||
"Authentication didn't provide an authid as required".to_string()
|
tracing::warn!("Authentication didn't provide an authid as required.");
|
||||||
)));
|
capnp::Error::failed(
|
||||||
let session = pry!(manager.open(uid.as_ref()).ok_or(capnp::Error::failed(
|
"Authentication didn't provide an authid as required".to_string(),
|
||||||
"Failed to lookup the given user".to_string()
|
)
|
||||||
)));
|
}));
|
||||||
|
let session = pry!(manager.open(uid.as_ref()).ok_or_else(|| {
|
||||||
|
tracing::warn!(uid = uid.as_str(), "Failed to lookup the given user");
|
||||||
|
capnp::Error::failed("Failed to lookup the given user".to_string())
|
||||||
|
}));
|
||||||
|
|
||||||
let mut builder = builder.init_successful();
|
let mut builder = builder.init_successful();
|
||||||
if data.is_some() {
|
if data.is_some() {
|
||||||
|
@ -51,7 +51,7 @@ impl bootstrap::Server for BootCap {
|
|||||||
let _guard = span.enter();
|
let _guard = span.enter();
|
||||||
let mut builder = result.get();
|
let mut builder = result.get();
|
||||||
builder.set_name("bffhd");
|
builder.set_name("bffhd");
|
||||||
builder.set_release(crate::RELEASE_STRING);
|
builder.set_release(crate::env::VERSION);
|
||||||
Promise::ok(())
|
Promise::ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@ pub mod capnp;
|
|||||||
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
|
// Store build information in the `env` module.
|
||||||
|
shadow_rs::shadow!(env);
|
||||||
|
|
||||||
mod audit;
|
mod audit;
|
||||||
mod keylog;
|
mod keylog;
|
||||||
mod logging;
|
mod logging;
|
||||||
@ -60,9 +63,6 @@ use crate::users::Users;
|
|||||||
use executor::pool::Executor;
|
use executor::pool::Executor;
|
||||||
use signal_hook::consts::signal::*;
|
use signal_hook::consts::signal::*;
|
||||||
|
|
||||||
pub const VERSION_STRING: &'static str = env!("BFFHD_VERSION_STRING");
|
|
||||||
pub const RELEASE_STRING: &'static str = env!("BFFHD_RELEASE_STRING");
|
|
||||||
|
|
||||||
pub struct Diflouroborane {
|
pub struct Diflouroborane {
|
||||||
config: Config,
|
config: Config,
|
||||||
executor: Executor<'static>,
|
executor: Executor<'static>,
|
||||||
@ -77,7 +77,7 @@ pub static RESOURCES: OnceCell<ResourcesHandle> = OnceCell::new();
|
|||||||
impl Diflouroborane {
|
impl Diflouroborane {
|
||||||
pub fn new(config: Config) -> anyhow::Result<Self> {
|
pub fn new(config: Config) -> anyhow::Result<Self> {
|
||||||
logging::init(&config.logging);
|
logging::init(&config.logging);
|
||||||
tracing::info!(version = VERSION_STRING, "Starting BFFH");
|
tracing::info!(version = env::VERSION, "Starting BFFH");
|
||||||
|
|
||||||
let span = tracing::info_span!("setup");
|
let span = tracing::info_span!("setup");
|
||||||
let _guard = span.enter();
|
let _guard = span.enter();
|
||||||
|
@ -11,28 +11,33 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// values for the name, description and version are pulled from `Cargo.toml`.
|
// values for the name, description and version are pulled from `Cargo.toml`.
|
||||||
let matches = Command::new(clap::crate_name!())
|
let matches = Command::new(clap::crate_name!())
|
||||||
.version(clap::crate_version!())
|
.version(clap::crate_version!())
|
||||||
.long_version(diflouroborane::VERSION_STRING)
|
.long_version(&*format!("{version}\n\
|
||||||
|
FabAccess {apiver}\n\
|
||||||
|
\t[{build_kind} build built on {build_time}]\n\
|
||||||
|
\t {rustc_version}\n\t {cargo_version}",
|
||||||
|
version=diflouroborane::env::PKG_VERSION,
|
||||||
|
apiver="0.3",
|
||||||
|
rustc_version=diflouroborane::env::RUST_VERSION,
|
||||||
|
cargo_version=diflouroborane::env::CARGO_VERSION,
|
||||||
|
build_time=diflouroborane::env::BUILD_TIME_3339,
|
||||||
|
build_kind=diflouroborane::env::BUILD_RUST_CHANNEL))
|
||||||
.about(clap::crate_description!())
|
.about(clap::crate_description!())
|
||||||
.arg(
|
.arg(Arg::new("config")
|
||||||
Arg::new("config")
|
|
||||||
.help("Path to the config file to use")
|
.help("Path to the config file to use")
|
||||||
.long("config")
|
.long("config")
|
||||||
.short('c')
|
.short('c')
|
||||||
.takes_value(true),
|
.takes_value(true))
|
||||||
)
|
|
||||||
.arg(Arg::new("verbosity")
|
.arg(Arg::new("verbosity")
|
||||||
.help("Increase logging verbosity")
|
.help("Increase logging verbosity")
|
||||||
.long("verbose")
|
.long("verbose")
|
||||||
.short('v')
|
.short('v')
|
||||||
.multiple_occurrences(true)
|
.multiple_occurrences(true)
|
||||||
.max_occurrences(3)
|
.max_occurrences(3)
|
||||||
.conflicts_with("quiet")
|
.conflicts_with("quiet"))
|
||||||
)
|
|
||||||
.arg(Arg::new("quiet")
|
.arg(Arg::new("quiet")
|
||||||
.help("Decrease logging verbosity")
|
.help("Decrease logging verbosity")
|
||||||
.long("quiet")
|
.long("quiet")
|
||||||
.conflicts_with("verbosity")
|
.conflicts_with("verbosity"))
|
||||||
)
|
|
||||||
.arg(Arg::new("log format")
|
.arg(Arg::new("log format")
|
||||||
.help("Use an alternative log formatter. Available: Full, Compact, Pretty")
|
.help("Use an alternative log formatter. Available: Full, Compact, Pretty")
|
||||||
.long("log-format")
|
.long("log-format")
|
||||||
@ -46,26 +51,22 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::new("print default")
|
Arg::new("print default")
|
||||||
.help("Print a default config to stdout instead of running")
|
.help("Print a default config to stdout instead of running")
|
||||||
.long("print-default"),
|
.long("print-default"))
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("check config")
|
Arg::new("check config")
|
||||||
.help("Check config for validity")
|
.help("Check config for validity")
|
||||||
.long("check"),
|
.long("check"))
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("dump")
|
Arg::new("dump")
|
||||||
.help("Dump all internal databases")
|
.help("Dump all internal databases")
|
||||||
.long("dump")
|
.long("dump")
|
||||||
.conflicts_with("load"),
|
.conflicts_with("load"))
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("load")
|
Arg::new("load")
|
||||||
.help("Load values into the internal databases")
|
.help("Load values into the internal databases")
|
||||||
.long("load")
|
.long("load")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.conflicts_with("dump"),
|
.conflicts_with("dump"))
|
||||||
)
|
|
||||||
.arg(Arg::new("keylog")
|
.arg(Arg::new("keylog")
|
||||||
.help("log TLS keys into PATH. If no path is specified the value of the envvar SSLKEYLOGFILE is used.")
|
.help("log TLS keys into PATH. If no path is specified the value of the envvar SSLKEYLOGFILE is used.")
|
||||||
.long("tls-key-log")
|
.long("tls-key-log")
|
||||||
@ -73,8 +74,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.max_values(1)
|
.max_values(1)
|
||||||
.min_values(0)
|
.min_values(0)
|
||||||
.default_missing_value("")
|
.default_missing_value(""))
|
||||||
)
|
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let configpath = matches
|
let configpath = matches
|
||||||
|
60
build.rs
60
build.rs
@ -1,60 +1,4 @@
|
|||||||
use std::process::Command;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!(">>> Building version number...");
|
// Extract build-time information using the `shadow-rs` crate
|
||||||
|
shadow_rs::new();
|
||||||
let rustc = std::env::var("RUSTC").unwrap();
|
|
||||||
let out = Command::new(rustc)
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.expect("failed to run `rustc --version`");
|
|
||||||
let rustc_version =
|
|
||||||
String::from_utf8(out.stdout).expect("rustc --version returned invalid UTF-8");
|
|
||||||
let rustc_version = rustc_version.trim();
|
|
||||||
println!("cargo:rustc-env=CARGO_RUSTC_VERSION={}", rustc_version);
|
|
||||||
|
|
||||||
println!("cargo:rerun-if-env-changed=BFFHD_BUILD_TAGGED_RELEASE");
|
|
||||||
let tagged_release = option_env!("BFFHD_BUILD_TAGGED_RELEASE") == Some("1");
|
|
||||||
let version_string = if tagged_release {
|
|
||||||
format!(
|
|
||||||
"{version} [{rustc}]",
|
|
||||||
version = env!("CARGO_PKG_VERSION"),
|
|
||||||
rustc = rustc_version
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// Build version number using the current git commit id
|
|
||||||
let out = Command::new("git")
|
|
||||||
.arg("rev-list")
|
|
||||||
.args(["HEAD", "-1"])
|
|
||||||
.output()
|
|
||||||
.expect("failed to run `git rev-list HEAD -1`");
|
|
||||||
let owned_gitrev =
|
|
||||||
String::from_utf8(out.stdout).expect("git rev-list output was not valid UTF8");
|
|
||||||
let gitrev = owned_gitrev.trim();
|
|
||||||
let abbrev = match gitrev.len() {
|
|
||||||
0 => "unknown",
|
|
||||||
_ => &gitrev[0..9],
|
|
||||||
};
|
|
||||||
|
|
||||||
let out = Command::new("git")
|
|
||||||
.arg("log")
|
|
||||||
.args(["-1", "--format=%as"])
|
|
||||||
.output()
|
|
||||||
.expect("failed to run `git log -1 --format=\"format:%as\"`");
|
|
||||||
let commit_date = String::from_utf8(out.stdout).expect("git log output was not valid UTF8");
|
|
||||||
let commit_date = commit_date.trim();
|
|
||||||
|
|
||||||
format!(
|
|
||||||
"{version} ({gitrev} {date}) [{rustc}]",
|
|
||||||
version = env!("CARGO_PKG_VERSION"),
|
|
||||||
gitrev = abbrev,
|
|
||||||
date = commit_date,
|
|
||||||
rustc = rustc_version
|
|
||||||
)
|
|
||||||
};
|
|
||||||
println!("cargo:rustc-env=BFFHD_VERSION_STRING={}", version_string);
|
|
||||||
println!(
|
|
||||||
"cargo:rustc-env=BFFHD_RELEASE_STRING=\"BFFH {}\"",
|
|
||||||
version_string
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user