Version bump, fix EOF error, move PrintIPv4FromInt
This commit is contained in:
parent
501b371936
commit
0579cfea1d
15
libbsm.go
15
libbsm.go
@ -282,6 +282,11 @@ type Text struct {
|
||||
|
||||
|
||||
/* Utilities */
|
||||
func PrintIpv4FromInt(ipv4int uint32) string {
|
||||
return fmt.Sprintf("%d.%d.%d.%d", ipv4int & 0xFF000000 >> 24, ipv4int & 0x00FF0000 >> 16,
|
||||
ipv4int & 0x0000FF00 >> 8, ipv4int & 0x000000FF)
|
||||
}
|
||||
|
||||
func PrintIpv6FromInt(ipv6int [4]uint32) string {
|
||||
//return fmt.Sprintf("%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
|
||||
return fmt.Sprintf("%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
@ -602,11 +607,6 @@ func (s *Subject32) LoadFromBinary(file *os.File) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func PrintIpv4FromInt(ipv4int uint32) string {
|
||||
return fmt.Sprintf("%d.%d.%d.%d", ipv4int & 0xFF000000 >> 24, ipv4int & 0x00FF0000 >> 16,
|
||||
ipv4int & 0x0000FF00 >> 8, ipv4int & 0x000000FF)
|
||||
}
|
||||
|
||||
func (s *Subject32) Print(file *os.File, delimiter string, flags int) {
|
||||
fmt.Fprintf(file, "subject%s%v%s%v%s%v%s%v%s%v%s%v%s%v%s%v%s%s", delimiter, s.Auid, delimiter, s.Euid, delimiter, s.Egid,
|
||||
delimiter, s.Ruid, delimiter, s.Rgid, delimiter, s.Sid, delimiter, s.Tid.Port, delimiter, s.Tid.IpVers,
|
||||
@ -1324,7 +1324,10 @@ func readRecordToStruct(file *os.File) (Record, error) {
|
||||
hdr := make([]byte, 1)
|
||||
n, err := file.Read(hdr)
|
||||
if err != nil || n < 1 {
|
||||
return rec, fmt.Errorf("Unable to read header ID in file: %v", err)
|
||||
if err != io.EOF {
|
||||
return rec, fmt.Errorf("Unable to read header ID in file: %v", err)
|
||||
}
|
||||
return rec, err
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
|
9
main.go
9
main.go
@ -16,6 +16,7 @@ import "C"
|
||||
import "unsafe"
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"fmt"
|
||||
// "encoding/hex"
|
||||
@ -23,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version = "0.001"
|
||||
version = "0.01"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -139,8 +140,10 @@ func main() {
|
||||
//for i := 0 ; i < 20 ; i++ {
|
||||
for {
|
||||
rec, err := readRecordToStruct(f)
|
||||
if err != nil {
|
||||
fmt.Printf("Erreur : %v\n", err)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
fmt.Printf("Erreur : %v\n", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
rec.Print(os.Stdout, ",", 0)
|
||||
|
Loading…
Reference in New Issue
Block a user