UTMP IP address implimentation

Andrew Bartlett abartlet at samba.org
Thu Apr 24 09:56:35 GMT 2003

On Thu, 2003-04-24 at 02:25, David Lee wrote:
> 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.

If you set 'lookup hostnames = yes' in HEAD, you restore the behaviour
as 'expected'.  The problem is, if we do reverse DNS lookups, most
installations get long timeouts, as most people can't configure DNS...

> 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.

Storing the IP address, and passing it into the right places is easy,
and I've committed the fix to Samba 3.0.

Andrew Bartlett

Andrew Bartlett                                 abartlet at pcug.org.au
Manager, Authentication Subsystems, Samba Team  abartlet at samba.org
Student Network Administrator, Hawker College   abartlet at hawkerc.net
http://samba.org     http://build.samba.org     http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20030424/eddd4b63/attachment.bin

More information about the samba-technical mailing list