Your message dated Fri, 1 Mar 2019 11:43:38 +0000 (UTC)
with message-id <[email protected]>
and subject line Re: sysvinit: Regarding ipAddr printed by utmpdump
has caused the Debian Bug report #612823,
regarding sysvinit: Regarding ipAddr printed by utmpdump
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
612823: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=612823
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: sysvinit
Version: 2.88
X-Debbugs-CC: "Navdeep Bhatia" <[email protected]>, "Fred
Xia" <[email protected]>, "Henrique de Moraes Holschuh"
<[email protected]>,
*Bug Description:*
The addr field of the output from utmpdump contains the ip address of the
connection. This is obtained by calling inet_ntoa on the ut.ut_addr field
(as depicted in the code below, utmpdump.c, Release 2.88). But in case the
ip address is an IPV6 address, the output contains the wrong ip address
(decimal value of first 4 octets only).
This code should be updated to call inet_ntop and should be checked whether
the ut_addr field contains IPV4 or IPV6 address. The check can be made
either by checking ut_addr_v6[1:3] for zero (this is based on the assumption
that login program zeroes out fields before filling utmp structure, though
it is not mentioned in man entry for utmp) or by introducing a flag in the
utmp structure that depicts whether the address field contains IPV4 or IPV6
address.
void
print_utline(struct utmp ut)
{
char *addr_string, *time_string;
struct in_addr in;
in.s_addr = ut.ut_addr;
*addr_string = inet_ntoa(in); //Code statement causes issue in
case of IPV6 addresses*
time_string = timetostr(ut.ut_time);
cleanse(ut.ut_id);
cleanse(ut.ut_user);
cleanse(ut.ut_line);
cleanse(ut.ut_host);
/* pid id user line host addr
time */
printf("[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s]
[%-28.28s]\n",
ut.ut_type, ut.ut_pid, ut.ut_id, 8, UT_NAMESIZE, ut.ut_user,
12, UT_LINESIZE, ut.ut_line, 20, UT_HOSTSIZE, ut.ut_host,
addr_string, time_string);
}
*Solution:*
a) One solution could be to look for ut_addr_v6[1:3] for zero. This is based
on the assumption that login program zeroes out the fields before filling
utmp structure. In this case the updated program would be:
void
print_utline(struct utmp ut)
{
char addr_string[INET6_ADDRSTRLEN], *time_string;
int addr_family = AF_INET6;
if( ut.ut_addr_v6[1] == 0 &&
ut.ut_addr_v6[2] == 0 &&
ut.ut_addr_v6[3] == 0 )
{
addr_family = AF_INET;
}
if( NULL == inet_ntop( addr_family, ut.ut_addr_v6, addr_string,
INET6_ADDRSTRLEN ) )
{
perror( "inet_ntop" );
exit(EXIT_FAILURE);
}
time_string = timetostr(ut.ut_time);
cleanse(ut.ut_id);
cleanse(ut.ut_user);
cleanse(ut.ut_line);
cleanse(ut.ut_host);
/* pid id user line host addr
time */
printf("[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-.45s]
[%-28.28s]\n",
ut.ut_type, ut.ut_pid, ut.ut_id, 8, UT_NAMESIZE, ut.ut_user,
12, UT_LINESIZE, ut.ut_line, 20, UT_HOSTSIZE, ut.ut_host,
addr_string, time_string);
}
b) The other solution could be to introduce a new flag in utmp structure
that fills whether the address is IPV4 or IPV6.
Thanks.
Regards,
Navdeep
--- End Message ---
--- Begin Message ---
tags 612823 fixed-upstream
fixed 612823 2.91-1
thanks
This was fixed upstream in sysvinit 2.89:
> sysvinit (2.89) world; urgency=low
>
> [ Werner Fink ]
> * Try to make utmpdump IPv6 valid, change based on suggestion from
> Navdeep Bhatia (see local bug #32429)
--
Pierre Ynard
--- End Message ---