wtmpfix.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1993-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* wtmpfix - adjust wtmpx file and remove date changes.
* wtmpfix <wtmpx1 >wtmpx2
*
* code are added to really fix wtmpx if it is corrupted ..
*/
#include <stdio.h>
#include "acctdef.h"
#include <utmpx.h>
#include <signal.h>
#include <time.h>
#include <ctype.h>
#include <locale.h>
#include <limits.h>
#include <stdlib.h>
static char time_buf[50];
struct dtab
{
};
int ch;
int n;
int multimode; /* multi user mode WHCC */
static int invalid(char *);
static void intr(int);
static void scanfile(void);
static int inrange(void);
static void wabort(int);
int
{
int fd;
perror("signal");
return (1);
}
perror("signal");
return (1);
}
if (argc < 2) {
argc++;
}
intr(0);
}
intr(0);
}
while (--argc > 0) {
argv++;
intr(0);
}
scanfile();
}
intr(0);
}
recno = 0;
}
return (0);
}
static int
{
return (0);
return (1);
else {
intr(0);
}
/* NOTREACHED */
}
static void
{
intr(0);
}
}
}
static void
{
intr(0);
}
intr(0);
}
}
static void
{
pp = p;
continue;
}
}
/*
* invalid() determines whether the name field adheres to
* the criteria set forth in acctcon1. If the name violates
* conventions, it returns a truth value meaning the name is
* invalid; if the name is okay, it returns false indicating
* the name is not invalid.
*/
static int
{
int i;
for (i = 0; i < NSZ; i++) {
if (name[i] == '\0')
return (VALID);
return (INVALID);
}
}
return (VALID);
}
static void
{
exit(1);
}
/*
* scanfile:
* 1) reads the file, to see if the record is within reasonable
* range; if not, then it will scan the file, delete foreign stuff.
* 2) enter setdtab if in multiuser mode
* 3) change bad login names to INVALID
*/
static void
scanfile()
{
if (n == 0) {
exit(0);
}
if (!inrange()) {
for (;;) {
perror("seek error\n");
exit(1);
}
perror("read\n");
exit(1);
}
exit(1);
}
if (inrange())
break;
}
}
/* Now we have a good utmpx record, do more processing */
multimode = 0;
multimode++;
}
"wtmpfix: logname \"%*.*s\" changed "
"to \"INVALID\"\n", OUTPUT_NSZ,
}
"offset %ld\n", recno);
intr(0);
}
"offset %ld", recno);
intr(0);
}
if (multimode) /* multiuser */
continue;
}
}
}
static int
inrange()
{
return (1);
return (1);
return (0);
}
static void
{
exit(1);
}