diff options
author | wpaul <wpaul@FreeBSD.org> | 1996-04-28 04:08:22 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1996-04-28 04:08:22 +0000 |
commit | 5c33bf2a9e16412000ce3e1264a2bec611b60537 (patch) | |
tree | 3c02a77f31257fabe797337e6f3397ffd621d3db /gnu/usr.sbin | |
parent | 0f35f42efa9b930156fcb8c07b7090cc30788e39 (diff) | |
download | FreeBSD-src-5c33bf2a9e16412000ce3e1264a2bec611b60537.zip FreeBSD-src-5c33bf2a9e16412000ce3e1264a2bec611b60537.tar.gz |
Toss the GNU yp_mkdb into the attic.
Diffstat (limited to 'gnu/usr.sbin')
-rw-r--r-- | gnu/usr.sbin/yp_mkdb/Makefile | 7 | ||||
-rw-r--r-- | gnu/usr.sbin/yp_mkdb/yp_mkdb.8 | 128 | ||||
-rw-r--r-- | gnu/usr.sbin/yp_mkdb/yp_mkdb.c | 250 |
3 files changed, 0 insertions, 385 deletions
diff --git a/gnu/usr.sbin/yp_mkdb/Makefile b/gnu/usr.sbin/yp_mkdb/Makefile deleted file mode 100644 index 324bdf4..0000000 --- a/gnu/usr.sbin/yp_mkdb/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# From: @(#)Makefile 8.1 (Berkeley) 7/19/93 -# $Id$ - -PROG= yp_mkdb -MAN8= yp_mkdb.8 - -.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/yp_mkdb/yp_mkdb.8 b/gnu/usr.sbin/yp_mkdb/yp_mkdb.8 deleted file mode 100644 index cba203f..0000000 --- a/gnu/usr.sbin/yp_mkdb/yp_mkdb.8 +++ /dev/null @@ -1,128 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)yp_mkdb.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd February 3, 1995 -.Dt YP_MKDB 8 -.Os -.Sh NAME -.Nm yp_mkdb -.Nd "generate the NIS databases" -.Sh SYNOPSIS -.Nm yp_mkdb -.Fl u Ar dbname -.Nm yp_mkdb -.Op Fl i Ar inputfile -.Op Fl o Ar outputfile -.Op Fl m Ar mastername -.Ar inputfile -.Ar dbname -.Sh DESCRIPTION -.Nm yp_mkdb -creates -.Xr db 3 -style databases for use with FreeBSD's NIS server. -.Nm yp_mkdb -reads data from -.Nm inputfile , -and writes it to -.Nm dbname -in -.Xr db 3 -format (using the hash table method). -The input should be in 'key data' format, which is to say -two fields of ASCII data separated by white space. The first field -is assumed to be the key, and everything else is assumed to be -the data. -These databases are typically stored in -.Nm /var/yp/[domainname] -where -.Nm domainname -is the name of the NIS domain being served. -.Nm yp_mkdb -is usually invoked by -.Nm /var/yp/Makefile. -.Nm yp_mkdb -can also be used to dump an NIS database file so that its -contents can be examined. For security reasons, all databases that -.Nm yp_mkdb -creates are readable and writable by owner only (and usually the -owner is root). -.Pp -The options are as follows: -.Bl -tag -width flag -.It Fl u Ar dbname -.Pp -Dump (or 'unwind') an NIS database. This option can be used to -inspect the contents of an existing NIS database. -.It Op Fl i Ar inputfile -.Pp -When generating an NIS map, encode -.Nm inputfile -as a special entry in the database with called -.Nm YP_INPUT_FILE. -.Pp -.It Op Fl o Ar outputfile -.Pp -When generating an NIS map, encode -.Nm outputfile -as a special entry in the database with called -.Nm YP_OUTPUT_FILE . -.Pp -.It Op Fl m Ar mastername -.Pp -When generating an NIS map encode -.Nm mastername -as a special entry in the database with called -.Nm YP_MASTER_NAME . -This entry in the database is frequently used by various NIS utilities -to determine the name of an NIS master server for a domain. By default, -.Nm yp_mkdb -assumes that the local host is the NIS master; the -.Ar m -option is used to override this default. -.Sh FILES -.Bl -tag -width Pa -compact -.It Pa /var/yp/Makefile -The Makefile that calls -.Nm yp_mkdb -to build the NIS databases. -.Sh SEE ALSO -.Xr ypserv 8 , -.Xr db 3 -.Sh LICENSE -This program is covered by the GNU Public License version 2. -.Sh AUTHOR -Tobias Reber (original Linux version) -.br -Bill Paul <wpaul@ctr.columbia.edu> (port to FreeBSD and various -changes) diff --git a/gnu/usr.sbin/yp_mkdb/yp_mkdb.c b/gnu/usr.sbin/yp_mkdb/yp_mkdb.c deleted file mode 100644 index 29e5183..0000000 --- a/gnu/usr.sbin/yp_mkdb/yp_mkdb.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - YPS-0.2, NIS-Server for Linux - Copyright (C) 1994 Tobias Reber - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu) -*/ - -/* - * $Id: yp_mkdb.c,v 1.5 1995/10/23 16:03:41 wpaul Exp $ - */ - -#define BUFFERSIZE 4096 - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <fcntl.h> -#include <sys/time.h> -#include <sys/param.h> -#include <sys/stat.h> -#include <netdb.h> -#include <sys/types.h> -#include <db.h> -#include <limits.h> - -#define PERM_SECURE (S_IRUSR|S_IWUSR) -HASHINFO openinfo = { - 4096, /* bsize */ - 32, /* ffactor */ - 256, /* nelem */ - 2048 * 1024, /* cachesize */ - NULL, /* hash */ - 0 /* lorder */ -}; - -extern int optind; -extern char *optarg; - -static char *DomainName=NULL; -static char *InputFileName=NULL; -static char *OutputFileName=NULL; -static char *MasterName=NULL; -static char thisHost[MAXHOSTNAMELEN+1]; - -static void -unLoad(char *DbName) -{ - DB *dp; - DBT key, data; - int flag = R_FIRST; - - if ((dp = dbopen(DbName,O_RDONLY|O_EXCL, PERM_SECURE, - DB_HASH, &openinfo)) == NULL) { - fprintf(stderr, "%s: Cannot open\n", DbName); - perror(DbName); - exit(1); - } - - while (!(dp->seq) (dp, &key, &data, flag)) { - if (!data.data) { - fprintf(stderr, "Error\n"); - perror(DbName); - exit (1); - } - flag = R_NEXT; - fwrite(key.data, key.size, 1, stdout); - putc(' ', stdout); - fwrite(data.data, data.size, 1, stdout); - putc('\n', stdout); - } - (void)(dp->close) (dp); -} - - -static void -load( char *FileName, char *DbName) -{ - static char Buffer[BUFFERSIZE]; - static char filename[1024], filename2[1024]; - FILE *infile; - DB *dp; - DBT key, data; - - infile=strcmp(FileName, "-")?fopen(FileName, "r"):stdin; - if (infile==NULL) { - fprintf(stderr, "%s: Cannot open\n", FileName); - exit(1); - } - - sprintf(filename, "%s~", DbName); - - if ((dp = dbopen(filename,O_RDWR|O_EXCL|O_CREAT, PERM_SECURE, - DB_HASH, &openinfo)) == NULL) { - perror("dbopen"); - fprintf(stderr, "%s: Cannot open\n", filename); - exit(1); - } - - if (MasterName && *MasterName) { - key.data="YP_MASTER_NAME"; key.size=strlen(key.data); - data.data=MasterName; data.size=strlen(MasterName); - (dp->put)(dp,&key,&data,0); - } - - if (DomainName && *DomainName) { - key.data="YP_DOMAIN_NAME"; key.size=strlen(key.data); - data.data=DomainName; data.size=strlen(DomainName); - (dp->put)(dp,&key,&data,0); - } - - if (InputFileName && *InputFileName) { - key.data="YP_INPUT_NAME"; key.size=strlen(key.data); - data.data=InputFileName; data.size=strlen(InputFileName); - (dp->put)(dp,&key,&data,0); - } - - if (OutputFileName && *OutputFileName) { - key.data="YP_OUTPUT_NAME"; key.size=strlen(key.data); - data.data=OutputFileName; data.size=strlen(OutputFileName); - (dp->put)(dp,&key,&data,0); - } - - { - char OrderNum[12]; - struct timeval tv; - struct timezone tz; - gettimeofday(&tv, &tz); - sprintf(OrderNum, "%ld", tv.tv_sec); - key.data="YP_LAST_MODIFIED"; key.size=strlen(key.data); - data.data=OrderNum; data.size=strlen(OrderNum); - (dp->put)(dp,&key,&data,0); - } - - for(;;) { - register int r; - - fgets(Buffer, BUFFERSIZE, infile); - if (feof(infile)) break; - if (Buffer[0] == '+' || Buffer[0] == '-') continue; - r=strlen(Buffer)-1; - if (Buffer[r]!='\n' && r>=BUFFERSIZE) { - fprintf(stderr, "%s: Buffer overflow\n", FileName); - exit(1); - } else - Buffer[r]='\0'; - - for (r=0; Buffer[r]; r++) { - if (Buffer[r]==' ' || Buffer[r]=='\t') { - Buffer[r]='\0'; - r++; - break; - } - } - for (; Buffer[r]; r++) - if (Buffer[r]!=' ' && Buffer[r]!='\t') break; - - if (Buffer[r] == '+' || Buffer[r] == '-') continue; - - key.data=Buffer; key.size=strlen(Buffer); - data.data=Buffer+r; data.size=strlen(Buffer+r); - (dp->put)(dp,&key,&data,0); - } - (void)(dp->close)(dp); - - sprintf(filename, "%s", DbName); - sprintf(filename2, "%s~", DbName); - unlink(filename); - if (rename(filename2, filename)) { - perror("rename"); - fprintf(stderr, "Cannot rename %s to %s\n", filename2, filename); - exit(1); - } -} - -static void -Usage( void) -{ - fprintf(stderr, "usage: yp_mkdb -u dbname\n"); - fprintf(stderr, " yp_mkdb [-i inputfile] [-o outputfile]\n"); - fprintf(stderr, " [-m mastername] inputfile dbname\n"); - exit(1); -} - -void -main(int argc, char **argv) -{ - int UFlag=0; - - while(1) { - int c=getopt(argc, argv, "ui:o:m:d:"); - if (c==EOF) break; - switch (c) { - case 'u': - UFlag++; - break; - case 'd': - DomainName=optarg; - break; - case 'i': - InputFileName=optarg; - break; - case 'o': - OutputFileName=optarg; - break; - case 'm': - MasterName=optarg; - break; - case '?': - Usage(); - break; - } - } - argc-=optind; - argv+=optind; - - if (!MasterName) { - if (gethostname(thisHost, sizeof thisHost)<0) { - perror("gethostname"); - } else { - struct hostent *h; - h=gethostbyname(thisHost); - if (h) strncpy(thisHost, h->h_name, sizeof thisHost); - MasterName=thisHost; - } - } - if (UFlag) { - if (argc<1) Usage(); - unLoad(argv[0]); - } else { - if (argc<2) Usage(); - load(argv[0], argv[1]); - } - exit(0); -} - |