mirror of
https://gogs.blitter.com/RLabs/goutmp
synced 2024-08-14 19:26:41 +00:00
Merge branch 'utmp' of Russtopia/goutmp into master
This commit is contained in:
commit
448de8b524
2 changed files with 17 additions and 18 deletions
20
goutmp.go
20
goutmp.go
|
@ -5,20 +5,18 @@ package goutmp
|
|||
//#include <stdlib.h>
|
||||
//#include <sys/file.h>
|
||||
//#include <string.h>
|
||||
//#include <bsd/string.h>
|
||||
//#include <unistd.h>
|
||||
//#include <stdint.h>
|
||||
//#include <time.h>
|
||||
//#include <pwd.h>
|
||||
//
|
||||
//#include <utmp.h>
|
||||
//#include <utmpx.h>
|
||||
//#include <lastlog.h>
|
||||
//
|
||||
//typedef char char_t;
|
||||
//
|
||||
//
|
||||
//void pututmp(struct utmpx* entry, char* name, char* host) {
|
||||
//void pututmp(struct utmp* entry, char* name, char* host) {
|
||||
// //int32_t stat = system("echo ---- pre ----;who");
|
||||
//
|
||||
// entry->ut_type = USER_PROCESS;
|
||||
|
@ -31,23 +29,23 @@ package goutmp
|
|||
// strcpy(entry->ut_user, name);
|
||||
// strcpy(entry->ut_host, host);
|
||||
// entry->ut_addr = 0;
|
||||
// setutxent();
|
||||
// pututxline(entry);
|
||||
// setutent();
|
||||
// pututline(entry);
|
||||
//
|
||||
// //stat = system("echo ---- post ----;who");
|
||||
//}
|
||||
//
|
||||
//void unpututmp(struct utmpx* entry) {
|
||||
//void unpututmp(struct utmp* entry) {
|
||||
// entry->ut_type = DEAD_PROCESS;
|
||||
// memset(entry->ut_line, 0, UT_LINESIZE);
|
||||
// entry->ut_time = 0;
|
||||
// memset(entry->ut_user, 0, UT_NAMESIZE);
|
||||
// setutxent();
|
||||
// pututxline(entry);
|
||||
// setutent();
|
||||
// pututline(entry);
|
||||
//
|
||||
// //int32_t stat = system("echo ---- cleanup ----;who; lastlog");
|
||||
//
|
||||
// endutxent();
|
||||
// endutent();
|
||||
//}
|
||||
//
|
||||
//int putlastlogentry(int64_t t, int uid, char* line, char* host) {
|
||||
|
@ -86,9 +84,9 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// UtmpEntry wraps the C struct utmpx
|
||||
// UtmpEntry wraps the C struct utmp
|
||||
type UtmpEntry struct {
|
||||
entry C.struct_utmpx
|
||||
entry C.struct_utmp
|
||||
}
|
||||
|
||||
// return remote client hostname or IP if host lookup fails
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"blitter.com/go/goutmp"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -9,6 +10,6 @@ func main() {
|
|||
host := "test.example.com"
|
||||
utmp := goutmp.Put_utmp(user, host)
|
||||
goutmp.Put_lastlog_entry("hkexsh", user, host)
|
||||
time.Sleep(10 * time.Second)
|
||||
goutmp.Unput_utmp(utmp)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue