From e20df456d7b954d32d06de0985b6ac687b09ab48 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Fri, 18 May 1990 16:48:35 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@889 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/aname/Imakefile | 4 ++ src/admin/aname/kdb5_anadd.c | 121 +++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 src/admin/aname/Imakefile create mode 100644 src/admin/aname/kdb5_anadd.c diff --git a/src/admin/aname/Imakefile b/src/admin/aname/Imakefile new file mode 100644 index 000000000..1175db4a0 --- /dev/null +++ b/src/admin/aname/Imakefile @@ -0,0 +1,4 @@ +DEPLIBS = $(OSLIB) +LOCAL_LIBRARIES = $(OSLIB) -lcom_err DbmLib + +SimpleProgramTarget(kdb5_anadd) diff --git a/src/admin/aname/kdb5_anadd.c b/src/admin/aname/kdb5_anadd.c new file mode 100644 index 000000000..0b541a294 --- /dev/null +++ b/src/admin/aname/kdb5_anadd.c @@ -0,0 +1,121 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * Program to add/delete entries to/from the aname translation database. + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_anadd_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern int errno; + +void +usage(name, code) +char *name; +int code; +{ + fprintf(stderr, "usage: %s {-d|-a} [-n dbname] pname [ lname ]\n\ +\t-d requires pname, -a requires pname and lname\n", name); + exit(code); +} + +void +main(argc, argv) +int argc; +char *argv[]; +{ + DBM *db; + datum key, contents; + int optchar; + extern char *optarg; + extern int optind; + int delete = 0, add = 0; + char *lname, *pname; + extern char *krb5_lname_file; + char *andbname = krb5_lname_file; + + while ((optchar = getopt(argc, argv, "dan:")) != EOF) { + switch(optchar) { + case 'd': /* delete */ + delete++; + if (add) { + fprintf(stderr, "only one of -a, -d\n"); + usage(argv[0], 1); + } + break; + case 'a': /* add */ + add++; + if (delete) { + fprintf(stderr, "only one of -a, -d\n"); + usage(argv[0], 1); + } + break; + case 'n': + andbname = optarg; + break; + case '?': + default: + usage(argv[0], 1); + /*NOTREACHED*/ + } + } + if (!delete && !add) { + printf("assuming you want to add\n"); + add = 1; + } + if (argc - optind < 1) { + fprintf(stderr, "must supply pname\n"); + usage(argv[0], 1); + } + if (add && (argc - optind < 2)) { + fprintf(stderr, "must supply pname and lname\n"); + usage(argv[0], 1); + } + pname = argv[optind]; + lname = argv[optind+1]; + + if (!(db = dbm_open(andbname, O_RDWR|O_CREAT, 0644))) { + com_err(argv[0], errno, "while opening/creating %s", + andbname); + exit(1); + } + key.dptr = pname; + key.dsize = strlen(pname)+1; /* include the null */ + + if (delete) { + if (dbm_delete(db, key)) { + com_err(argv[0], 0, "No such entry while deleting %s from %s", + pname, andbname); + dbm_close(db); + exit(1); + } + } else if (add) { + contents.dptr = lname; + contents.dsize = strlen(lname)+1; + if (dbm_store(db, key, contents, DBM_REPLACE)) { + com_err(argv[0], errno, "while inserting/replacing %s in %s", + pname, andbname); + dbm_close(db); + exit(1); + } + } + dbm_close(db); + exit(0); +} -- 2.26.2