summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-09-05 00:34:21 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-09-05 00:34:21 -0600
commit6b94a9b6588112328fa2738b1c149b48908f5029 (patch)
tree4e7e11ad85997855af38b219a1b8193e1e4dab88 /src
parent066fe52728294bf764ccb89750eecae634a4c1a6 (diff)
clean up logging
Diffstat (limited to 'src')
-rw-r--r--src/inotify/syscall.go9
-rw-r--r--src/nshd/hackers_git/hackers.go1
-rw-r--r--src/nshd/hackers_git/hackers_parse.go8
-rw-r--r--src/nshd/hackers_git/hackers_watch.go20
-rwxr-xr-xsrc/nslcd_proto/func_handlerequest.go.sh1
-rw-r--r--src/nslcd_proto/io.go4
6 files changed, 26 insertions, 17 deletions
diff --git a/src/inotify/syscall.go b/src/inotify/syscall.go
index 245bc41..1b5c426 100644
--- a/src/inotify/syscall.go
+++ b/src/inotify/syscall.go
@@ -8,6 +8,13 @@ import (
type Cint C.int
+func pathError(op string, path string, err error) error {
+ if err == nil {
+ return nil
+ }
+ return &os.PathError{Op: op, Path: path, Err: err}
+}
+
/* Create and initialize inotify instance. */
func inotify_init() (Cint, error) {
fd, errno := syscall.InotifyInit()
@@ -24,7 +31,7 @@ func inotify_init1(flags Cint) (Cint, error) {
events specified by MASK. */
func inotify_add_watch(fd Cint, name string, mask uint32) (Cint, error) {
wd, errno := syscall.InotifyAddWatch(int(fd), name, mask)
- return Cint(wd), os.NewSyscallError("inotify_add_watch", errno)
+ return Cint(wd), pathError("inotify_add_watch", name, errno)
}
/* Remove the watch specified by WD from the inotify instance FD. */
diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go
index 60e6dd9..0f2dd3d 100644
--- a/src/nshd/hackers_git/hackers.go
+++ b/src/nshd/hackers_git/hackers.go
@@ -43,6 +43,7 @@ func NewHackers(config Config) *Hackers {
}
err := o.Reload()
if err != nil {
+ logger.Err("Could not initialize hackers.git: %v", err)
return nil
}
o.workers.Add(1)
diff --git a/src/nshd/hackers_git/hackers_parse.go b/src/nshd/hackers_git/hackers_parse.go
index 14140da..f1f360f 100644
--- a/src/nshd/hackers_git/hackers_parse.go
+++ b/src/nshd/hackers_git/hackers_parse.go
@@ -111,12 +111,12 @@ func load_user_password(filename string) (hash string) {
hash = "!"
file, err := os.Open(filename)
if err != nil {
- logger.Info("Could not open: %q: %v", filename, err)
+ logger.Debug("hackers.git: %v", err)
return
}
contents, err := ioutil.ReadAll(file)
if err != nil {
- logger.Info("Error while reading: %q: %v", filename, err)
+ logger.Debug("hackers.git: Error while reading: %q: %v", filename, err)
return
}
lines := strings.Split(string(contents), "\n")
@@ -127,10 +127,10 @@ func load_user_password(filename string) (hash string) {
if lines[1] == "" {
hash = lines[0]
} else {
- logger.Info("Invalid password format in file: %q", filename)
+ logger.Debug("hackers.git: Invalid password format in file: %q", filename)
}
default:
- logger.Info("Invalid password format in file: %q", filename)
+ logger.Debug("hackers.git: Invalid password format in file: %q", filename)
}
return
}
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index f1c4018..da008f8 100644
--- a/src/nshd/hackers_git/hackers_watch.go
+++ b/src/nshd/hackers_git/hackers_watch.go
@@ -29,7 +29,7 @@ func (o *Hackers) watchHomedir(uid int32) {
o.in_wd2uid[wd] = uid
} else {
delete(o.in_uid2wd, uid)
- logger.Info("could not watch: %s", o.users[uid].passwd.HomeDir)
+ logger.Debug("hackers.git: %v", err)
}
user := o.users[uid]
user.passwd.PwHash = load_user_password(user.passwd.HomeDir + "/.password")
@@ -39,7 +39,7 @@ func (o *Hackers) watchHomedir(uid int32) {
func (o *Hackers) unwatchHomedir(wd inotify.Cint) {
err := o.in_fd.RmWatch(wd)
if err != nil {
- logger.Warning("could not remove watch: %v", wd)
+ logger.Warning("hackers.git: %v", err)
return
}
uid := o.in_wd2uid[wd]
@@ -72,14 +72,14 @@ func (o *Hackers) reload() (err error) {
o.in_uid2wd = make(map[int32]inotify.Cint, len(filenames))
o.in_wd2uid = make(map[inotify.Cint]int32, len(filenames))
for _, filename := range filenames {
- logger.Info("Loading yaml file: %s", filename)
+ logger.Debug("hackers.git: Loading yaml file: %s", filename)
user, err := load_user_yaml(filename)
if err == nil {
o.users[user.passwd.UID] = user
- logger.Info("... success")
+ logger.Debug("hackers.git: ... success")
o.watchHomedir(user.passwd.UID)
} else {
- logger.Info("... error: %v", err)
+ logger.Debug("hackers.git: ... error: %v", err)
}
}
@@ -122,7 +122,7 @@ func (o *Hackers) worker_handle_passwd(uid int32) {
}
func worker_error(format string, a ...interface{}) {
- logger.Err(format, a)
+ logger.Err("hackers.git: "+ format, a)
os.Exit(int(lsb.EXIT_FAILURE))
}
@@ -150,15 +150,15 @@ func (o *Hackers) worker() {
panic("recieved child event from inotify, but no child name")
}
filename := o.cfg.Yamldir + "/" + *event.Name
- logger.Info("Loading yaml file: %s", filename)
+ logger.Debug("hackers.git: Loading yaml file: %s", filename)
user, err := load_user_yaml(filename)
if err == nil {
// User added/updated
- logger.Info("... success")
+ logger.Debug("hackers.git: ... success")
o.worker_handle_user_add(user)
} else if user.passwd.UID >= 0 {
// User became invalid
- logger.Info("... error: %v", err)
+ logger.Debug("hackers.git: ... error: %v", err)
o.worker_handle_user_del(user.passwd.UID)
}
} else {
@@ -184,7 +184,7 @@ func (o *Hackers) worker() {
o.worker_handle_passwd(o.in_wd2uid[event.Wd])
}
} else {
- logger.Debug("event didn't match: %#v", event)
+ logger.Debug("hackers.git: event didn't match: %#v", event)
}
}
}
diff --git a/src/nslcd_proto/func_handlerequest.go.sh b/src/nslcd_proto/func_handlerequest.go.sh
index 185db73..62ef231 100755
--- a/src/nslcd_proto/func_handlerequest.go.sh
+++ b/src/nslcd_proto/func_handlerequest.go.sh
@@ -30,6 +30,7 @@ while read -r request; do
case NSLCD_ACTION_${request^^}:
var req Request_${request}
read(in, &req)
+ fmt.Printf("request: %#v\n", req)
res = backend.${request}(cred, req)
EOT
done < "$requests"
diff --git a/src/nslcd_proto/io.go b/src/nslcd_proto/io.go
index 321a87c..87783ac 100644
--- a/src/nslcd_proto/io.go
+++ b/src/nslcd_proto/io.go
@@ -70,7 +70,7 @@ func write(fd io.Writer, data interface{}) {
write(fd, v.Field(i).Interface())
}
default:
- panic("Invalid structure for NSLCD protocol data")
+ panic(fmt.Sprintf("Invalid structure to write NSLCD protocol data from: %T ( %#v )", data, data))
}
}
}
@@ -139,7 +139,7 @@ func read(fd io.Reader, data interface{}) {
read(fd, v.Field(i).Interface())
}
default:
- panic("Invalid structure for NSLCD protocol data")
+ panic(fmt.Sprintf("The argument to nslcd_proto.read() must be a pointer: %T ( %#v )", data, data))
}
}
}