Merge branch 'utmp' of Russtopia/goutmp into master

This commit is contained in:
Russtopia 2018-06-29 19:38:39 -07:00 committed by Gogs
commit 448de8b524
2 changed files with 17 additions and 18 deletions

View File

@ -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

View File

@ -1,14 +1,15 @@
package main
import (
"blitter.com/go/goutmp"
"blitter.com/go/goutmp"
"time"
)
func main() {
user := "bin"
host := "test.example.com"
utmp := goutmp.Put_utmp(user, host)
goutmp.Put_lastlog_entry("hkexsh", user, host)
goutmp.Unput_utmp(utmp)
user := "bin"
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)
}