Debian Codegraph @

src/explain.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#;
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#};
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#;
5
6 use nixrust-analyzer cargo nix 0.31.3 crate/::unistdrust-analyzer cargo nix 0.31.3 unistd/::getuidrust-analyzer cargo nix 0.31.3 unistd/getuid().;
7
8
9 pub trait Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable#: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# {
10 fn explainrust-analyzer cargo libmount 0.1.15 explain/Explainable#explain().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
11 }
12
13 pub fn existsrust-analyzer cargo libmount 0.1.15 explain/exists().(path: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> &'static str {
14 if path.existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().() {
15 "exists"
16 } else {
17 "missing"
18 }
19 }
20
21 pub fn userrust-analyzer cargo libmount 0.1.15 explain/user().() -> &'static str {
22 let uid = getuidrust-analyzer cargo nix 0.31.3 unistd/getuid().();
23 if u32::fromrust-analyzer cargo nix 0.31.3 unistd/impl#[u32][`From<Uid>`]from().(uid) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().0 {
24 let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(100);
25 match Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().("/proc/self/uid_map")
26 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|mut f| f.read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Read]read_to_string().(&mut buf))
27 {
28 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_) => {
29 if buf rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()." 0 0 4294967295\n" {
30 "superuser"
31 } else {
32 "mapped-root"
33 }
34 }
35 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
36 "privileged"
37 }
38 }
39 } else {
40 "regular-user"
41 }
42 }