-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
44 lines (35 loc) · 848 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"os"
"github.com/hashicorp/go-hclog"
"github.com/netauth/pam-helper/internal/module"
"github.com/spf13/viper"
"github.com/netauth/netauth/pkg/netauth"
)
var (
appLogger hclog.Logger
)
func main() {
llevel := os.Getenv("NETAUTH_LOGLEVEL")
if llevel != "" {
appLogger = hclog.New(&hclog.LoggerOptions{
Name: "pam-helper",
Level: hclog.LevelFromString(llevel),
})
} else {
appLogger = hclog.NewNullLogger()
}
viper.SetConfigName("config")
viper.AddConfigPath("/etc/netauth/")
viper.AddConfigPath("$HOME/.netauth/")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
appLogger.Error("Error loading config", "error", err)
os.Exit(5)
}
nacl, err := netauth.NewWithLog(appLogger.Named("netauth"))
if err != nil {
os.Exit(2)
}
os.Exit(module.Exec(appLogger, nacl))
}