*** empty log message ***
authorJohn Kohl <jtkohl@mit.edu>
Fri, 18 May 1990 16:48:35 +0000 (16:48 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Fri, 18 May 1990 16:48:35 +0000 (16:48 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@889 dc483132-0cff-0310-8789-dd5450dbe970

src/admin/aname/Imakefile [new file with mode: 0644]
src/admin/aname/kdb5_anadd.c [new file with mode: 0644]

diff --git a/src/admin/aname/Imakefile b/src/admin/aname/Imakefile
new file mode 100644 (file)
index 0000000..1175db4
--- /dev/null
@@ -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 (file)
index 0000000..0b541a2
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * 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 <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <krb5/ext-proto.h>
+#include <krb5/dbm.h>
+#include <sys/file.h>
+#include <com_err.h>
+#include <stdio.h>
+#include <errno.h>
+
+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);
+}