[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wuftpd-questions
Subject:    Re: Re: =?ISO-8859-1?Q?GOcit=E9?=
From:       Simon-Bernard Drolet <sxi () sympatico ! ca>
Date:       2002-03-27 15:07:44
[Download RAW message or body]

Hi,

I just rewrote logwtmp.c for Solaris 8.

I'm sure someone who knows a little bit better the wu-ftpd
source structure (ifdef...) can fix the file with this code.

I just remove everything with ifdef and hardcoded the 
Solaris 8 version. The main point here is to not use
open and write to access the wtmpx file directly but to
use the updwtmpx() system call.

Simon.


#include "config.h"

#include <sys/types.h>
#ifdef TIME_WITH_SYS_TIME
#include <time.h>
#include <sys/time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
#include <sys/stat.h>
#if defined(HAVE_FCNTL_H)
#include <fcntl.h>
#endif
#include <utmp.h>
#include <utmpx.h>
#ifdef SVR4
#ifndef NO_UTMPX
#include <utmpx.h>
#ifndef _SCO_DS
#include <sac.h>
#endif
#endif
#endif
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#ifdef HAVE_SYS_SYSLOG_H
#include <sys/syslog.h>
#endif
#if defined(HAVE_SYSLOG_H) || (!defined(AUTOCONF) && !defined(HAVE_SYS_SYSLOG_H)
)
#include <syslog.h>
#endif
#ifdef __FreeBSD__
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif

#include "pathnames.h"
#include "proto.h"

static int fd = -1;
#ifdef SVR4
static int fdx = -1;
#endif

void wu_logwtmp(char *line, char *name, char *host, int login)
{
    struct stat buf;
    struct utmp ut;
    struct utmpx utx;


        memset((void *) &utx, '\0', sizeof(utx));
        (void) strncpy(utx.ut_user, name, sizeof(utx.ut_user));
        (void) strncpy(utx.ut_host, host, sizeof(utx.ut_host));
        (void) strncpy(utx.ut_id, "ftp", sizeof(utx.ut_id));
        (void) strncpy(utx.ut_line, line, sizeof(utx.ut_line));
        utx.ut_syslen = strlen(utx.ut_host) + 1;
        utx.ut_pid = getpid();
        (void) time(&utx.ut_tv.tv_sec);
        if (login /* name && *name */ ) {
            utx.ut_type = USER_PROCESS;
        }
        else {
            utx.ut_type = DEAD_PROCESS;
        }
        utx.ut_exit.e_termination = 0;
        utx.ut_exit.e_exit = 0;

        updwtmpx("/var/adm/wtmpx", &utx);
}


Simon-Bernard Drolet, Specialiste X inc., 514-247-6741. mailto:SXi@Sympatico.ca
Certified Sun Technical Instructor (SA-118,SA-238,SA-288,SA-389,SA-400)
Sun Certified System and Network Administrator for Solaris 7/8

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic