Version bump, fix EOF error, move PrintIPv4FromInt
This commit is contained in:
parent
501b371936
commit
0579cfea1d
13
libbsm.go
13
libbsm.go
@ -282,6 +282,11 @@ type Text struct {
|
|||||||
|
|
||||||
|
|
||||||
/* Utilities */
|
/* 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 {
|
func PrintIpv6FromInt(ipv6int [4]uint32) string {
|
||||||
//return fmt.Sprintf("%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
|
//return fmt.Sprintf("%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
|
||||||
return fmt.Sprintf("%x:%x:%x:%x:%x:%x:%x:%x",
|
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
|
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) {
|
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,
|
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,
|
delimiter, s.Ruid, delimiter, s.Rgid, delimiter, s.Sid, delimiter, s.Tid.Port, delimiter, s.Tid.IpVers,
|
||||||
@ -1324,8 +1324,11 @@ func readRecordToStruct(file *os.File) (Record, error) {
|
|||||||
hdr := make([]byte, 1)
|
hdr := make([]byte, 1)
|
||||||
n, err := file.Read(hdr)
|
n, err := file.Read(hdr)
|
||||||
if err != nil || n < 1 {
|
if err != nil || n < 1 {
|
||||||
|
if err != io.EOF {
|
||||||
return rec, fmt.Errorf("Unable to read header ID in file: %v", err)
|
return rec, fmt.Errorf("Unable to read header ID in file: %v", err)
|
||||||
}
|
}
|
||||||
|
return rec, err
|
||||||
|
}
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
/* startOf, _ := file.Seek(0, io.SeekCurrent)
|
/* startOf, _ := file.Seek(0, io.SeekCurrent)
|
||||||
|
5
main.go
5
main.go
@ -16,6 +16,7 @@ import "C"
|
|||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
"fmt"
|
||||||
// "encoding/hex"
|
// "encoding/hex"
|
||||||
@ -23,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "0.001"
|
version = "0.01"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -140,7 +141,9 @@ func main() {
|
|||||||
for {
|
for {
|
||||||
rec, err := readRecordToStruct(f)
|
rec, err := readRecordToStruct(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err != io.EOF {
|
||||||
fmt.Printf("Erreur : %v\n", err)
|
fmt.Printf("Erreur : %v\n", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rec.Print(os.Stdout, ",", 0)
|
rec.Print(os.Stdout, ",", 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user