UTMP IP address implimentation

David Lee t.d.lee at durham.ac.uk
Wed Apr 23 16:25:19 GMT 2003


On Wed, 23 Apr 2003, Andrew Bartlett wrote:

> On Wed, 2003-04-23 at 15:52, Philip Anderson wrote:
> > I just made a simple attempt at implimenting ut->addr in utmp.c so that
> > 'last -i' wouldp produce the client's IP address.  I tried it, and all
> > appears to work on my RedHat 9 machine.  Is this a valid solution?
> >
> > I added the following lines to the end of sys_utmp_fill in utmp.c:
> >
> > #if defined(HAVE_UT_UT_ADDR)
> >         inet_pton(AF_INET,hostname,&(u->ut_addr));
> > #endif
>
> That doesn't look quite right - you should ask the code further up to
> give you the raw IP address, still in it's struct, and use that
> directly.
>
> With the right options, we will actually fill 'hostname' with the
> reverse DNS name.

Although 'twas I who originally wrote the utmp stuff, that was so long ago
that I have forgotten all the detail.  Furthermore, it has since had some
significant reworking by Andrew B. and others.

But this does remind me of another problem in this area, which may be
related.  On our system (Solaris 8, samba 2.2.8a) the output from "who"
shows IP number rather than hostname for the SMB connections (the telnet
connections etc. show hostnames).  And I also recall a mention of this
some time ago on samba-technical: a quick search reveals a thread "utmp
stores IP not hostname" around March 9th 2002, recognising this problem in
the 2_2 tree.

A quick look through the 2.2.8a source code indicates that hostname is an
argument passed into the utmp module ("sys_utmp_claim()" et seq.).
Relating this to Philip Anderson's original question, that would suggest
that the IP number might similarly be expected to be passed into the
module (as distinct from being determined by it).

Andrew:  Are you able to take a quick look at this, at least to determine
your preferred principle (pass-into v. determine-within).  Then, among us,
we can decide how to address these two (possibly related) issues.


-- 

:  David Lee                                I.T. Service          :
:  Systems Programmer                       Computer Centre       :
:                                           University of Durham  :
:  http://www.dur.ac.uk/t.d.lee/            South Road            :
:                                           Durham                :
:  Phone: +44 191 334 2752                  U.K.                  :


More information about the samba-technical mailing list