MCPcopy Index your code
hub / github.com/foxcpp/maddy / Configure

Method Configure

internal/auth/shadow/module.go:61–91  ·  view source on GitHub ↗
(inlineArgs []string, cfg *config.Map)

Source from the content-addressed store, hash-verified

59}
60
61func (a *Auth) Configure(inlineArgs []string, cfg *config.Map) error {
62 if len(inlineArgs) != 0 {
63 return errors.New("shadow: inline arguments are not used")
64 }
65
66 cfg.Bool("debug", true, false, &a.log.Debug)
67 cfg.Bool("use_helper", false, false, &a.useHelper)
68 if _, err := cfg.Process(); err != nil {
69 return err
70 }
71
72 if a.useHelper {
73 a.helperPath = filepath.Join(config.LibexecDirectory, "maddy-shadow-helper")
74 if _, err := os.Stat(a.helperPath); err != nil {
75 return fmt.Errorf("shadow: no helper binary (maddy-shadow-helper) found in %s", config.LibexecDirectory)
76 }
77 } else {
78 f, err := os.Open("/etc/shadow")
79 if err != nil {
80 if os.IsPermission(err) {
81 return fmt.Errorf("shadow: can't read /etc/shadow due to permission error, use helper binary or run maddy as a privileged user")
82 }
83 return fmt.Errorf("shadow: can't read /etc/shadow: %v", err)
84 }
85 if err := f.Close(); err != nil {
86 a.log.Error("can't close /etc/shadow file", err)
87 }
88 }
89
90 return nil
91}
92
93func (a *Auth) Lookup(username string) (string, bool, error) {
94 if a.useHelper {

Callers

nothing calls this directly

Calls 5

BoolMethod · 0.80
ProcessMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected