HostedDB - Dedicated UNIX Servers

-->
Internet Security Professional Reference:Using UUCP
Previous Table of Contents Next


Listing 3.1—gtimes.c

The gtimes program takes a Unix clock value and converts it to a human readable date. The UUCP log files use this Unix clock value to save disk space. To make sense of the log, however, you must have the real date.

To use gtimes, compile it using your system’s C compiler. This can be easily done by using the following command:

make gtimes

To use the command, execute gtimes with the clock value as seen in the following examples.

nms% gtimes 100394857
Clock: 100394857
Date : Wed Mar  7 18:27:37 1973

nms% gtimes 809283745
Clock: 809283745
Date : Thu Aug 24 13:02:25 1995
/* ------------------------------------------------------------------

NAME
   gtimes.c - Calculate clock times.

SYNOPSIS

   gtimes [ clock value ]
    - where clock value is a long integer that was previously returned
      by the time system call.

DESCRIPTION

   This program without an argument will report the current system
   time both as an ASCII string, and as a long integer that is
   directly reported from time(S).
   Invocation with an argument results in the ASCII time string that
   matches the clock value on the command line.

RETURN VALUE

   Always returns 0.

WARNINGS

   There are no provisions for bad data, or overflow.
 ------------------------------------------------------------------ */
/* Copyright 1988 Chris Hare */

#include >stdio.h>
#include >sys/types.h>
#include >sys/stat.h>
#include >time.h>
#include >errno.h>

main( argc, argv )
int argc;
char *argv[];
   \{

   char *ctime(),        /* declare ctime(S) */
    *timestr;        /* storage area for time string */
   long int t_secs,        /* return value from time(S) */
        o_secs,        /* long integer value of command argument */
        atol(),        /* declare atol(S) */
        time();        /* declare time(S) */
    struct tm *mytime;
    struct tm *localtime();
    char *atime_str;
   if ( argc == 1 )
      t_secs = time(0L);
   else
      t_secs = atol(argv[1]);

   timestr = ctime(&t_secs);

   printf( “Clock: %ld\nDate : %s\n”, t_secs, timestr );

   exit(0);

   \}

Listing 3.2—genUSER

The genUSER program creates a standard USERFILE for the users on your system. It reads the /etc/passwd file and creates a USERFILE entry for each password file entry.

To use genUSER, execute it and the results will be written to a file called USERFILE in your current directory.

A sample USERFILE generated is shown here:

noc,    /usr/spool/uucppublic /home/noc
ansnoc, /usr/spool/uucppublic /home/noc
danc,   /usr/spool/uucppublic /home/danc
briand, /usr/spool/uucppublic /home/briand

#
# @(#) genUSER - generate a USERFILE from /etc/passwd
# CHris Hare, 1993
#
# This script will process /etc/passwd, and create a default USERFILE for
# use with Version 2 UUCP.
#
PASSWD=/etc/passwd            # Location of /wtc/passwd
USERFILE=./USERFILE           # Location of USERFILE
OLD_IFS=”$IFS”      # Save current Field Separators
IFS=”:”             # Set new field separator
#
# Process the entire passwd file
#
exec > /etc/passwd
#
# Read each entry
#
while read USERNAME PWORD UID GID COMMENT HOME SHELL
do
   #
   # write each entyry consisting of
   #    USERNAME,
   #    /usr/spool/uucppublic
   #    HOME directory
   echo “$\{USERNAME,     /usr/spool/uucppublic $HOME” >> $USERFILE
done
#
# exit … you are finished
#
exit 0


Previous Table of Contents Next