@@ -2,11 +2,11 @@ package main
22
33import (
44 "context"
5- "log"
65 "strings"
76
87 "github.com/MiLk/nsscache-go/cache"
98 "github.com/MiLk/nsscache-go/source"
9+ "github.com/hashicorp/go-hclog"
1010
1111 pb "github.com/netauth/protocol"
1212 "github.com/netauth/netauth/pkg/netauth"
@@ -52,6 +52,8 @@ type NetAuthCacheFiller struct {
5252 DefaultHome string
5353
5454 c * netauth.Client
55+
56+ l hclog.Logger
5557}
5658
5759// NewCacheFiller returns an interface that can be used to fill caches
@@ -70,13 +72,15 @@ func NewCacheFiller(minuid, mingid int32, defshell, defhome string, shells []str
7072 AllowedShells : shells ,
7173
7274 DefaultHome : defhome ,
75+
76+ l : hclog .L ().Named ("cachefiller" ),
7377 }
7478
7579 ctx := context .Background ()
7680
7781 c , err := netauth .New ()
7882 if err != nil {
79- log . Println ("Error during client initialization" )
83+ x . l . Error ("Error during client initialization" , "error" , err )
8084 return nil , err
8185 }
8286 c .SetServiceName ("nsscache" )
@@ -148,7 +152,10 @@ func (nc *NetAuthCacheFiller) findGroups(ctx context.Context) error {
148152 if grps [i ].GetNumber () < nc .MinGID {
149153 // Group number is too low, continue without
150154 // this one.
151- log .Printf ("Ignoring group %s, GID is below cutoff (%d < %d)" , grps [i ].GetName (), grps [i ].GetNumber (), nc .MinGID )
155+ nc .l .Warn ("Ignoring group, GID is below cutoff" ,
156+ "group" , grps [i ].GetName (),
157+ "limit" , nc .MinGID ,
158+ "gid" , grps [i ].GetNumber ())
152159 continue
153160 }
154161 nc .groups [grps [i ].GetName ()] = grps [i ]
@@ -173,13 +180,17 @@ func (nc *NetAuthCacheFiller) findEntities(ctx context.Context) error {
173180 if ents [i ].GetNumber () < nc .MinUID {
174181 // The uidNumber was too low, continue without
175182 // this one.
176- log .Printf ("Ignoring entity %s, UID is below cutoff (%d < %d)" , ents [i ].GetID (), ents [i ].GetNumber (), nc .MinUID )
183+ nc .l .Warn ("Ignoring entity, UID is below cutoff" ,
184+ "entity" , ents [i ].GetID (),
185+ "limit" , nc .MinUID ,
186+ "uid" , ents [i ].GetNumber ())
177187 continue
178188 }
179189 if _ , ok := nc .pgroups [ents [i ].GetMeta ().GetPrimaryGroup ()]; ! ok {
180190 // The primary group was invalid, continue
181191 // without this one.
182- log .Printf ("Ignoring entity %s, Primary Group is invalid" , ents [i ].GetID ())
192+ nc .l .Warn ("Ignoring entity, Primary Group is invalid" ,
193+ "entity" , ents [i ].GetID ())
183194 continue
184195 }
185196 if nc .hasBadShell (ents [i ].GetMeta ().GetShell ()) {
0 commit comments