use CLIENTNAME for who.host
This commit is contained in:
parent
d229d838b1
commit
e04943ccb1
28
src/sigar.c
28
src/sigar.c
|
@ -806,18 +806,21 @@ static int sigar_who_net_sessions(sigar_t *sigar,
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static sigar_uint64_t get_logon_time(HKEY users,
|
static int get_logon_info(HKEY users,
|
||||||
char *username)
|
char *username,
|
||||||
|
sigar_who_t *who)
|
||||||
{
|
{
|
||||||
DWORD status;
|
DWORD status, size, type;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
char key_name[MAX_PATH];
|
char key_name[MAX_PATH];
|
||||||
|
char host[256];
|
||||||
FILETIME wtime;
|
FILETIME wtime;
|
||||||
sigar_uint64_t time=0;
|
|
||||||
|
who->time = 0;
|
||||||
|
|
||||||
sprintf(key_name, "%s\\Volatile Environment", username);
|
sprintf(key_name, "%s\\Volatile Environment", username);
|
||||||
if (RegOpenKey(users, key_name, &key) != ERROR_SUCCESS) {
|
if (RegOpenKey(users, key_name, &key) != ERROR_SUCCESS) {
|
||||||
return 0;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = RegQueryInfoKey(key,
|
status = RegQueryInfoKey(key,
|
||||||
|
@ -827,12 +830,21 @@ static sigar_uint64_t get_logon_time(HKEY users,
|
||||||
|
|
||||||
if (status == ERROR_SUCCESS) {
|
if (status == ERROR_SUCCESS) {
|
||||||
FileTimeToLocalFileTime(&wtime, &wtime);
|
FileTimeToLocalFileTime(&wtime, &wtime);
|
||||||
time = FileTimeToTime(&wtime) / 1000000;
|
who->time = FileTimeToTime(&wtime) / 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = sizeof(host);
|
||||||
|
status = RegQueryValueEx(key, "CLIENTNAME",
|
||||||
|
NULL, &type, host, &size);
|
||||||
|
if (status == ERROR_SUCCESS) {
|
||||||
|
if ((host[0] != '\0') && !strEQ(host, "Console")) {
|
||||||
|
SIGAR_SSTRCPY(who->host, host);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
|
|
||||||
return time;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*XXX dlload, not in NT */
|
/*XXX dlload, not in NT */
|
||||||
|
@ -883,10 +895,10 @@ static int sigar_who_registry(sigar_t *sigar,
|
||||||
SIGAR_WHO_LIST_GROW(wholist);
|
SIGAR_WHO_LIST_GROW(wholist);
|
||||||
who = &wholist->data[wholist->number++];
|
who = &wholist->data[wholist->number++];
|
||||||
|
|
||||||
who->time = get_logon_time(users, subkey);
|
|
||||||
SIGAR_SSTRCPY(who->user, username);
|
SIGAR_SSTRCPY(who->user, username);
|
||||||
SIGAR_SSTRCPY(who->host, domain);
|
SIGAR_SSTRCPY(who->host, domain);
|
||||||
SIGAR_SSTRCPY(who->device, "console");
|
SIGAR_SSTRCPY(who->device, "console");
|
||||||
|
get_logon_info(users, subkey, who);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFree(sid);
|
LocalFree(sid);
|
||||||
|
|
Loading…
Reference in New Issue