diff --git a/goutmp.go b/goutmp.go index a963434..2d7721b 100644 --- a/goutmp.go +++ b/goutmp.go @@ -16,23 +16,15 @@ package goutmp //typedef char char_t; // // -//void pututmp(struct utmp* entry, char* name, char* host) { -// //TODO: if ttyname returns NULL, it's probably a network -// // connection and the pty should be passed in to this func. -// char* stdinName = ttyname(STDIN_FILENO); -// if( !stdinName ) { -// stdinName = "/dev/ptyN"; -// } -// +//void pututmp(struct utmp* entry, char* uname, char* ptsname, char* host) { // entry->ut_type = USER_PROCESS; // entry->ut_pid = getpid(); -// strcpy(entry->ut_line, stdinName + strlen("/dev/")); -// /* only correct for ptys named /dev/tty[pqr][0-9a-z] */ +// strcpy(entry->ut_line, ptsname + strlen("/dev/")); // -// strcpy(entry->ut_id, stdinName + strlen("/dev/tty")); +// strcpy(entry->ut_id, ptsname + strlen("/dev/pts/")); // // entry->ut_time = time(NULL); -// strcpy(entry->ut_user, name); +// strcpy(entry->ut_user, uname); // strcpy(entry->ut_host, host); // entry->ut_addr = 0; // setutent(); @@ -109,11 +101,11 @@ func GetHost(addr string) (h string) { } // Put a username and the originating host/IP to utmp -func Put_utmp(user string, host string) UtmpEntry { +func Put_utmp(user, ptsName, host string) UtmpEntry { var entry UtmpEntry //log.Println("Put_utmp:host ", host, " user ", user) - C.pututmp(&entry.entry, C.CString(user), C.CString(host)) + C.pututmp(&entry.entry, C.CString(user), C.CString(ptsName), C.CString(host)) return entry } @@ -123,7 +115,7 @@ func Unput_utmp(entry UtmpEntry) { } // Put the login app, username and originating host/IP to lastlog -func Put_lastlog_entry(app string, usr string, host string) { +func Put_lastlog_entry(app, usr, ptsname, host string) { u, e := user.Lookup(usr) if e != nil { return