[Samba] Re: utmp update for bsd systems (try 2)

Michael Shalayeff mickey at lucifier.net
Thu Apr 14 17:48:35 GMT 2005


Making, drinking tea and reading an opus magnum from Christopher R. Hertel:
> >From the FAQ:
> 
>   The Samba 2.2 branch is no longer maintained. It's EOL was October 1, 
>   2004.
> 
> It's GPL'd, though, so if you want to maintain patches for it you are more 
> than welcome to do so.

the same function is empty in 3.0 either
so i suppose it's the same patch anyway

cu

> On Thu, Apr 14, 2005 at 01:11:08PM -0400, Michael Shalayeff wrote:
> > re
> > i have posted this before but received no response...
> > is there anybod reading on this address?
> > cu
> > 
> > ----- Forwarded message (env-from mickey) -----
> > 
> > re
> > this is a patch against samba-2.2.12p0 and adds support
> > for updating utmp on bsds. code similarly ripped from
> > openbsd's ftpd (;
> > cu
> > -- 
> >     paranoic mickey       (my employers have changed but, the name has remained)
> > 
> > --- utmp.c	Thu Aug 12 14:24:20 2004
> > +++ /home/mickey/utmp.c	Wed Mar 30 15:51:40 2005
> > @@ -261,6 +261,7 @@
> >  }
> >  
> >  #ifndef HAVE_PUTUTLINE
> > +#include <ttyent.h>
> >  
> >  /****************************************************************************
> >   Update utmp file directly.  No subroutine interface: probably a BSD system.
> > @@ -268,8 +269,50 @@
> >  
> >  static void pututline_my(pstring uname, struct utmp *u, BOOL claim)
> >  {
> > -	DEBUG(1,("pututline_my: not yet implemented\n"));
> > -	/* BSD implementor: may want to consider (or not) adjusting "lastlog" */
> > +	int fd, topslot;
> > +	struct utmp ubuf;
> > +
> > +	if ((fd = open(uname, O_RDWR, 0)) < 0)
> > +		return;
> > +
> > +	if (!setttyent())
> > +		return;
> > +
> > +	for (topslot = 0; getttyent() != (struct ttyent *)NULL; )
> > +		topslot++;
> > +
> > +	if (!endttyent())
> > +		return;
> > +
> > +	(void) lseek(fd, (off_t)(topslot * sizeof(struct utmp)), SEEK_SET);
> > +
> > +	DEBUG(1,("pututline(%s, %s, %d); topslot=%d\n",
> > +	    u->ut_line, u->ut_name, claim, topslot));
> > +
> > +	while (1) {
> > +		if (read(fd, &ubuf, sizeof(ubuf)) == sizeof(ubuf)) {
> > +			if ((claim && !ubuf.ut_name[0]) ||
> > +			    (!claim && ubuf.ut_name[0] &&
> > +			     !strncmp(ubuf.ut_line, u->ut_line, UT_LINESIZE))) {
> > +				(void) lseek(fd, -(off_t)sizeof(struct utmp),
> > +				    SEEK_CUR);
> > +				break;
> > +			}
> > +			topslot++;
> > +		} else {
> > +			(void) lseek(fd, (off_t)(topslot *
> > +			    sizeof(struct utmp)), SEEK_SET);
> > +			break;
> > +		}
> > +	}
> > +
> > +	if (! claim) {
> > +		memset((char *)&u->ut_name, '\0', sizeof(u->ut_name));
> > +		memset((char *)&u->ut_host, '\0', sizeof(u->ut_host));
> > +	}
> > +	(void) write(fd, u, sizeof(struct utmp));
> > +
> > +	(void) close(fd);
> >  }
> >  #endif /* HAVE_PUTUTLINE */
> >  
> > 
> > ----- End of forwarded message (env-from mickey) -----
> > 
> > -- 
> >     paranoic mickey       (my employers have changed but, the name has remained)
> > 
> 
> -- 
> "Implementing CIFS - the Common Internet FileSystem" ISBN: 013047116X
> Samba Team -- http://www.samba.org/     -)-----   Christopher R. Hertel
> jCIFS Team -- http://jcifs.samba.org/   -)-----   ubiqx development, uninq.
> ubiqx Team -- http://www.ubiqx.org/     -)-----   crh at ubiqx.mn.org
> OnLineBook -- http://ubiqx.org/cifs/    -)-----   crh at ubiqx.org
> 


-- 
    paranoic mickey       (my employers have changed but, the name has remained)


More information about the samba mailing list