mkalias.c revision a506a34ceb0e9dcc6c61bf0560202f8538928650
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* mkmap - program to convert the mail.aliases map into an
* inverse map of <user@host> back to <preferred-alias>
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <ndbm.h>
#include <stdio.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/systeminfo.h>
#include "ypdefs.h"
#define MKAL_INCLUDE ":include:"
int HostCheck(char *h, char *a);
void AddYPEntries(void);
int Verbose = 0; /* to get the gory details */
int UucpOK = 0; /* pass all UUCP names right through */
int DomainOK = 0; /* pass all Domain names (with dots) */
int ErrorCheck = 0; /* check carefully for errors */
int NoOutput = 0; /* no output, just do the check */
int Simple = 0; /* Do not do the user name preference step */
int NameMode = 0; /* Try to capitalize as names */
int
IsMailingList(char *s)
{
/*
* returns true if the given string is a mailing list
*/
char *p;
if (strchr(s, ','))
return (1);
if (strchr(s, '|'))
return (1);
p = strchr(s, ':');
return (1);
return (0);
}
int
IsQualified(char *s, char *p, char *h)
{
/*
* returns true if the given string is qualified with a host name
*/
register char *middle;
if (middle) {
continue;
*p = '\0';
return (1);
}
if (middle) {
*middle = '\0';
*middle = '!';
return (1);
}
return (0);
}
int
IsMaint(char *s)
{
/*
* returns true if the given string is one of the maintenence
* strings used in sendmail or NIS.
*/
if (*s == '@')
return (1);
return (1);
return (0);
}
void
{
/*
* copy a string, but ignore white space
*/
src++;
else
}
*dst = '\0';
}
int
{
/*
* compare strings, but ignore white space
*/
s1++;
s2++;
}
void
ProcessMap(void)
{
if (IsMailingList(address)) continue;
printf("Invalid host %s in %s:%s\n",
continue;
}
if (Simple)
else
if (NameMode)
if (!NoOutput)
} else {
if (NameMode)
if (!NoOutput)
if (Verbose)
}
}
}
/*
* Returns true if this is an invalid host
*/
int
HostCheck(char *h, char *a)
{
return (0);
return (0);
hp = gethostbyname(h);
}
/*
* Apply some Heurisitcs to upper case-ify the name
* If it has a dot in it.
*/
void
{
return;
while (*cp) {
cp++;
if (*cp)
cp++; /* skip past punctuation */
}
}
/*
* upper cases one name - stops at a .
*/
void
{
return; /* handle ff */
}
void
AddYPEntries(void)
{
char last_modified[PBLKSIZ];
/*
* Add the special NIS entries.
*/
}
int
{
case 'v':
Verbose = 1;
break;
case 'u':
UucpOK = 1;
break;
case 'd':
DomainOK = 1;
break;
case 'e':
ErrorCheck = 1;
break;
case 's':
Simple = 1;
break;
case 'n':
NameMode = 1;
break;
default:
break;
}
}
if (argc < 2) {
printf("Usage: mkalias [-e] [-v] [-u] [-d] [-s] [-n] <input> <output>\n");
exit(1);
}
exit(1);
}
exit(1);
}
NoOutput = 1;
else {
exit(1);
}
}
ProcessMap();
if (!NoOutput) {
AddYPEntries();
}
return (0);
}