Debian Codegraph @

src/sudoers/entry/verbose.rs

raw symbols SCIP
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
2
3 use craterust-analyzer cargo sudo-rs 0.2.14 crate/::sudoersrust-analyzer cargo sudo-rs 0.2.14 sudoers/::{
4 astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::{Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#, RunAsrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/RunAs#, Tagrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#},
5 tokensrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/::ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#,
6 };
7
8 use superrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/::Entryrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/Entry#;
9
10 pub struct Verboserust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/Verbose#<'a>(pub Entryrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/Entry#<'a>);
11
12 impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Verboserust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/Verbose#<'_> {
13 fn fmtrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/impl#[`Verbose<'_>`][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
14 let Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/impl#[`Verbose<'_>`][Display](Entryrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/Entry# {
15 run_asrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/Entry#run_as.,
16 cmd_specsrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/Entry#cmd_specs.,
17 cmd_aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/Entry#cmd_alias.,
18 }) = self;
19
20 let root_runas = superrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/::root_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/root_runas().();
21 let run_as = run_as.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(&root_runas);
22
23 let mut last_tag = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
24 for (tag, cmd_spec) in cmd_specs {
25 if last_tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(tag) {
26 let is_first_iteration = last_tag.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().();
27 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_first_iteration {
28 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("\n")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
29 }
30
31 write_entry_headerrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_entry_header().(run_as, f)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
32 write_tagrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_tag().(f, tag)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
33 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "\n {}", xlatrust-analyzer cargo sudo-rs 0.2.14 gettext/xlat!!("Commands:"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
34 }
35 last_tag = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(tag);
36
37 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("\n\t")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
38 superrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/::write_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/write_spec().(f, cmd_spec, cmd_alias.iterrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[`VecOrd<T>`]iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().(), true, "\n\t")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
39 }
40
41 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
42 }
43 }
44
45 fn write_entry_headerrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_entry_header().(run_as: &RunAsrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/RunAs#, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
46 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "\n{}", xlatrust-analyzer cargo sudo-rs 0.2.14 gettext/xlat!!("Sudoers entry:"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
47
48 write_usersrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_users().(run_as, f)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
49 write_groupsrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_groups().(run_as, f)
50 }
51
52 fn write_usersrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_users().(run_as: &RunAsrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/RunAs#, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
53 // TRANSLATORS: This is sudo-specific jargon.
54 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "\n {}: ", xlatrust-analyzer cargo sudo-rs 0.2.14 gettext/xlat!!("RunAsUsers"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
55 superrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/::write_usersrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/write_users().(run_as, f)
56 }
57
58 fn write_groupsrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_groups().(run_as: &RunAsrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/RunAs#, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
59 if run_as.groupsrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/RunAs#groups..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
60 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
61 }
62
63 // TRANSLATORS: This is sudo-specific jargon.
64 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "\n {}: ", xlatrust-analyzer cargo sudo-rs 0.2.14 gettext/xlat!!("RunAsGroups"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
65 superrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/::write_groupsrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/write_groups().(run_as, f)
66 }
67
68 fn write_tagrust-analyzer cargo sudo-rs 0.2.14 sudoers/entry/verbose/write_tag().(f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#, tag: &Tagrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
69 if tag.authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nonerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#None# {
70 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "\n {}: ", xlatrust-analyzer cargo sudo-rs 0.2.14 gettext/xlat!!("Options"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
71 if tag.authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Passwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Passwd# {
72 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("!")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
73 }
74 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("authenticate")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
75 }
76
77 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cwd) = &tag.cwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#cwd. {
78 // TRANSLATORS: This is sudo-specific jargon.
79 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "\n {}: ", xlatrust-analyzer cargo sudo-rs 0.2.14 gettext/xlat!!("Cwd"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
80 match cwd {
81 ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#::Pathrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#Path#(path) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
82 ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#::Anyrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#Any# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("*")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
83 }
84 }
85
86 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
87 }