summaryrefslogtreecommitdiff
path: root/source3/smbd/utmp.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-10-03 20:43:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:31:09 -0500
commit0d87820380416955a132d565a479b4234f78c113 (patch)
tree9e6debb4b26796a386c188e7933ab7032e77e838 /source3/smbd/utmp.c
parent334b288831c1730cb88fb431f684b9062e139efd (diff)
downloadsamba-0d87820380416955a132d565a479b4234f78c113.tar.gz
samba-0d87820380416955a132d565a479b4234f78c113.tar.bz2
samba-0d87820380416955a132d565a479b4234f78c113.zip
r25492: Start adding IPv6 compatible code to lib/util_sock.c and deal with
the ripple effects this causes. utmp has to change etc. Remove some global varables and store address/port in the unexpected db. Jeremy. (This used to be commit 18c6a2211d9e25233d01715b3f78977edcd6d869)
Diffstat (limited to 'source3/smbd/utmp.c')
-rw-r--r--source3/smbd/utmp.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c
index eb2152dac2..52174c4d83 100644
--- a/source3/smbd/utmp.c
+++ b/source3/smbd/utmp.c
@@ -112,14 +112,14 @@ Notes:
* Not WITH_UTMP? Simply supply dummy routines.
*/
-void sys_utmp_claim(const char *username, const char *hostname,
- struct in_addr *ipaddr,
- const char *id_str, int id_num)
+void sys_utmp_claim(const char *username, const char *hostname,
+ const char *ip_addr_str,
+ const char *id_str, int id_num)
{}
-void sys_utmp_yield(const char *username, const char *hostname,
- struct in_addr *ipaddr,
- const char *id_str, int id_num)
+void sys_utmp_yield(const char *username, const char *hostname,
+ const char *ip_addr_str,
+ const char *id_str, int id_num)
{}
#else /* WITH_UTMP */
@@ -448,7 +448,7 @@ static int ut_id_encode(int i, char *fourbyte)
{
int nbase;
const char *ut_id_encstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
+
fourbyte[0] = 'S';
fourbyte[1] = 'M';
@@ -470,13 +470,13 @@ static int ut_id_encode(int i, char *fourbyte)
/*
- fill a system utmp structure given all the info we can gather
+ fill a system utmp structure given all the info we can gather
*/
static BOOL sys_utmp_fill(struct utmp *u,
- const char *username, const char *hostname,
- struct in_addr *ipaddr,
- const char *id_str, int id_num)
-{
+ const char *username, const char *hostname,
+ const char *ip_addr_str,
+ const char *id_str, int id_num)
+{
struct timeval timeval;
/*
@@ -507,7 +507,7 @@ static BOOL sys_utmp_fill(struct utmp *u,
#endif
/*
- * ut_time, ut_tv:
+ * ut_time, ut_tv:
* Some have one, some the other. Many have both, but defined (aliased).
* It is easier and clearer simply to let the following take its course.
* But note that we do the more precise ut_tv as the final assignment.
@@ -525,9 +525,22 @@ static BOOL sys_utmp_fill(struct utmp *u,
#if defined(HAVE_UT_UT_HOST)
utmp_strcpy(u->ut_host, hostname, sizeof(u->ut_host));
#endif
-#if defined(HAVE_UT_UT_ADDR)
- if (ipaddr)
- u->ut_addr = ipaddr->s_addr;
+#if defined(AF_INET6) && defined(HAVE_UT_UT_ADDR_V6)
+ memset(&u->ut_addr_v6, '\0', sizeof(u->ut_addr_v6));
+ if (ip_addr_str) {
+ struct in6_addr addr;
+ if (inet_pton(AF_INET6, ip_addr_str, &addr) > 0) {
+ memcpy(&u->ut_addr_v6, &addr, sizeof(addr));
+ }
+ }
+#elif defined(HAVE_UT_UT_ADDR)
+ memset(&u->ut_addr, '\0', sizeof(u->ut_addr));
+ if (ip_addr_str) {
+ struct in_addr addr;
+ if (inet_pton(AF_INET, ip_addr_str, &addr) > 0) {
+ memcpy(&u->ut_addr, &addr, sizeof(addr));
+ }
+ }
/*
* "(unsigned long) ut_addr" apparently exists on at least HP-UX 10.20.
* Volunteer to implement, please ...
@@ -548,9 +561,9 @@ static BOOL sys_utmp_fill(struct utmp *u,
Close a connection.
****************************************************************************/
-void sys_utmp_yield(const char *username, const char *hostname,
- struct in_addr *ipaddr,
- const char *id_str, int id_num)
+void sys_utmp_yield(const char *username, const char *hostname,
+ const char *ip_addr_str,
+ const char *id_str, int id_num)
{
struct utmp u;
@@ -565,7 +578,8 @@ void sys_utmp_yield(const char *username, const char *hostname,
u.ut_type = DEAD_PROCESS;
#endif
- if (!sys_utmp_fill(&u, username, hostname, ipaddr, id_str, id_num)) return;
+ if (!sys_utmp_fill(&u, username, hostname, ip_addr_str, id_str, id_num))
+ return;
sys_utmp_update(&u, NULL, False);
}
@@ -574,9 +588,9 @@ void sys_utmp_yield(const char *username, const char *hostname,
Claim a entry in whatever utmp system the OS uses.
****************************************************************************/
-void sys_utmp_claim(const char *username, const char *hostname,
- struct in_addr *ipaddr,
- const char *id_str, int id_num)
+void sys_utmp_claim(const char *username, const char *hostname,
+ const char *ip_addr_str,
+ const char *id_str, int id_num)
{
struct utmp u;
@@ -586,7 +600,8 @@ void sys_utmp_claim(const char *username, const char *hostname,
u.ut_type = USER_PROCESS;
#endif
- if (!sys_utmp_fill(&u, username, hostname, ipaddr, id_str, id_num)) return;
+ if (!sys_utmp_fill(&u, username, hostname, ip_addr_str, id_str, id_num))
+ return;
sys_utmp_update(&u, hostname, True);
}