From: Tom Yu Date: Wed, 19 Oct 1994 15:14:29 +0000 (+0000) Subject: sanity checkin X-Git-Tag: krb5-1.0-beta5~1101 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=467e3dcf398a76881e7440b03b269848d50577d6;p=krb5.git sanity checkin git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4535 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin.new/client/Makefile.in b/src/kadmin.new/client/Makefile.in index 41b81c859..58649de30 100644 --- a/src/kadmin.new/client/Makefile.in +++ b/src/kadmin.new/client/Makefile.in @@ -1,6 +1,8 @@ -CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) +CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) $(OVSEC_INC) +OVSEC_INC=-I/afs/dev.mit.edu/reference/ovsecure/sunos/stage/include +OVSEC_LIB=-L/afs/dev.mit.edu/reference/ovsecure/sunos/stage/lib -lclient -lcommon -lrpclib -ldyn LDFLAGS = -g - +LIBOBJS=@LIBOBJS@ ISODELIB=@ISODELIB@ COMERRLIB=$(BUILDTOP)/util/et/libcom_err.a SSLIB=$(BUILDTOP)/util/ss/libss.a @@ -9,14 +11,14 @@ KDBLIB=$(TOPLIBD)/libkdb5.a all:: -KLIB = $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(ISODELIB) $(SSLIB) $(COMERRLIB) $(DBMLIB) -DEPKLIB = $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) +KLIB = $(TOPLIBD)/libgssapi_krb5.a $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(ISODELIB) $(SSLIB) $(COMERRLIB) $(DBMLIB) +DEPKLIB = $(TOPLIBD)/libgssapi_krb5.a $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) -SRCS = +SRCS = -OBJS = getdate.o +OBJS = kadmin.o kadmin_ct.o ss_wrapper.o getdate.o $(LIBOBJS) -all:: getdate +all:: kadmin getdate.c getdate.h: getdate.y $(RM) getdate.c getdate.h y.tab.* @@ -24,9 +26,14 @@ getdate.c getdate.h: getdate.y $(MV) y.tab.c getdate.c $(MV) y.tab.h getdate.h -getdate: getdate.c - $(CC) -o getdate $(CFLAGS) -DTEST getdate.c +kadmin: $(OBJS) + $(CC) -o kadmin $(CFLAGS) $(OBJS) $(OVSEC_LIB) $(KLIB) $(LIBS) + +# needed until we run makedepend +kadmin_ct.c: kadmin_ct.ct + +kadmin_ct.o: kadmin_ct.c clean:: - $(RM) getdate getdate.c getdate.h y.tab.c y.tab.h + $(RM) kadmin $(OBJS) kadmin_ct.c getdate.c getdate.h y.tab.c y.tab.h diff --git a/src/kadmin.new/client/configure.in b/src/kadmin.new/client/configure.in index 4ade062db..e544ac18a 100644 --- a/src/kadmin.new/client/configure.in +++ b/src/kadmin.new/client/configure.in @@ -6,6 +6,8 @@ AC_PROG_INSTALL AC_PROG_YACC AC_HAVE_HEADERS(unistd.h sys/timeb.h alloca.h) AC_HAVE_FUNCS(ftime timezone) +AC_REPLACE_FUNCS([setenv]) +SS_RULES KRB_INCLUDE ISODE_INCLUDE WITH_KRB5ROOT diff --git a/src/kadmin.new/client/kadmin.c b/src/kadmin.new/client/kadmin.c index 87ca0d3f7..66b29d3bd 100644 --- a/src/kadmin.new/client/kadmin.c +++ b/src/kadmin.new/client/kadmin.c @@ -25,11 +25,14 @@ #include #include #include +#include +#include #include #include #include #include #include +#include /* special struct to convert flag names for principals to actual krb5_flags for a principal */ @@ -40,7 +43,7 @@ struct pflag { int set; /* 0 means clear, 1 means set (on '-') */ }; -static struct princ_flag flags = { +static struct pflag flags[] = { {"allow_postdated", 15, KRB5_KDB_DISALLOW_POSTDATED, 1}, {"allow_forwardable", 17, KRB5_KDB_DISALLOW_FORWARDABLE, 1}, {"allow_tgs_req", 13, KRB5_KDB_DISALLOW_TGT_BASED, 1}, @@ -72,6 +75,7 @@ static char *prflags[] = { char *getenv(); struct passwd *getpwuid(); +int exit_status = 0; void usage() { @@ -85,7 +89,7 @@ char *kadmin_startup(argc, argv) char *argv[]; { extern char *optarg; - char *realmname = NULL, princstr = NULL, *keytab = NULL, *query = NULL; + char *realmname = NULL, *princstr = NULL, *keytab = NULL, *query = NULL; char *luser; int optchar, freeprinc = 0; struct passwd *pw; @@ -194,7 +198,7 @@ void kadmin_delprinc(argc, argv) } } if ((argc == 2) && ((i = strlen(argv[1])) == 6) && - strcmp("-force", argv[1]) || (i != 6) { + strcmp("-force", argv[1]) || (i != 6)) { fprintf(stderr, "delete_principal: bad arguments\n"); return; } @@ -203,7 +207,7 @@ void kadmin_delprinc(argc, argv) com_err("delete_principal", retval, "while parsing principal name"); return; } - reval = ovsec_kadm_delete_principal(princ); + retval = ovsec_kadm_delete_principal(princ); krb5_free_principal(princ); if (retval) { com_err("delete_principal", retval, @@ -343,12 +347,13 @@ void kadmin_cpw(argc, argv) int kadmin_parse_princ_args(argc, argv, oprinc, mask, pass) int argc; char *argv[]; - ovsec_kadm_principal_ent_t *oprinc; + ovsec_kadm_principal_ent_t oprinc; u_int32 *mask; - char **pass + char **pass; { - int i; + int i, j; struct timeb now; + krb5_error_code retval; *mask = 0; *pass = NULL; @@ -430,7 +435,7 @@ int kadmin_parse_princ_args(argc, argv, oprinc, mask, pass) break; } else if (flags[j].set && argv[i][0] == '+' || !flags[j].set && argv[i][0] == '-') { - oprinc->attributes &= ~flags[j]; + oprinc->attributes &= ~flags[j].theflag; *mask |= OVSEC_KADM_ATTRIBUTES; break; } else { diff --git a/src/kadmin.new/client/kadmin_ct.ct b/src/kadmin.new/client/kadmin_ct.ct new file mode 100644 index 000000000..7b7fce7a9 --- /dev/null +++ b/src/kadmin.new/client/kadmin_ct.ct @@ -0,0 +1,36 @@ +# Copyright 1994 by the Massachusetts Institute of Technology. +# All Rights Reserved. +# +# Export of this software from the United States of America may +# require a specific license from the United States Government. +# It is the responsibility of any person or organization contemplating +# export to obtain such a license before exporting. +# +# WITHIN THAT CONSTRAINT, permission to use, copy, modify, and +# distribute this software and its documentation for any purpose and +# without fee is hereby granted, provided that the above copyright +# notice appear in all copies and that both that copyright notice and +# this permission notice appear in supporting documentation, and that +# the name of M.I.T. not be used in advertising or publicity pertaining +# to distribution of the software without specific, written prior +# permission. M.I.T. makes no representations about the suitability of +# this software for any purpose. It is provided "as is" without express +# or implied warranty. +# +# +# Command table for kadmin CLI for OVSecure +# + +command_table kadmin_cmds; + +request kadmin_delprinc, "Delete principal", + delete_principal, delprinc; + +request kadmin_renprinc, "Rename principal", + rename_principal, renprinc; + +request kadmin_cpw, "Change password", + change_password, cpw; + +request ss_quit, "Exit program.", + quit, exit, q; diff --git a/src/kadmin.new/client/setenv.c b/src/kadmin.new/client/setenv.c new file mode 100644 index 000000000..a2432c3d6 --- /dev/null +++ b/src/kadmin.new/client/setenv.c @@ -0,0 +1,165 @@ +/* + * Copyright (c) 1987, 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. + */ + +/* based on @(#)setenv.c 8.1 (Berkeley) 6/4/93 */ +/* based on @(#)getenv.c 8.1 (Berkeley) 6/4/93 */ + +#ifndef __STDC__ +#define const +#endif + +#include +#include +#include + +#ifndef __P +#define __P(x) () +#endif +char *__findenv __P((const char *, int *)); + +/* + * setenv -- + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +setenv(name, value, rewrite) + register const char *name; + register const char *value; + int rewrite; +{ + extern char **environ; + static int alloced; /* if allocated space before */ + register char *c; + int l_value, offset; + + if (*value == '=') /* no `=' in value */ + ++value; + l_value = strlen(value); + if ((c = __findenv(name, &offset))) { /* find if already exists */ + if (!rewrite) + return (0); + if (strlen(c) >= l_value) { /* old larger; copy over */ + while (*c++ = *value++); + return (0); + } + } else { /* create new slot */ + register int cnt; + register char **p; + + for (p = environ, cnt = 0; *p; ++p, ++cnt); + if (alloced) { /* just increase size */ + environ = (char **)realloc((char *)environ, + (size_t)(sizeof(char *) * (cnt + 2))); + if (!environ) + return (-1); + } + else { /* get new space */ + alloced = 1; /* copy old entries into it */ + p = (char **)malloc((size_t)(sizeof(char *) * (cnt + 2))); + if (!p) + return (-1); + memcpy(p, environ, cnt * sizeof(char *)); + environ = p; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (c = (char *)name; *c && *c != '='; ++c); /* no `=' in name */ + if (!(environ[offset] = /* name + `=' + value */ + malloc((size_t)((int)(c - name) + l_value + 2)))) + return (-1); + for (c = environ[offset]; (*c = *name++) && *c != '='; ++c); + for (*c++ = '='; *c++ = *value++;); + return (0); +} + +/* + * unsetenv(name) -- + * Delete environmental variable "name". + */ +void +unsetenv(name) + const char *name; +{ + extern char **environ; + register char **p; + int offset; + + while (__findenv(name, &offset)) /* if set multiple times */ + for (p = &environ[offset];; ++p) + if (!(*p = *(p + 1))) + break; +} + +/* + * getenv -- + * Returns ptr to value associated with name, if any, else NULL. + */ +char * +getenv(name) + const char *name; +{ + int offset; + + return (__findenv(name, &offset)); +} + +/* + * __findenv -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + */ +static char * +__findenv(name, offset) + register const char *name; + int *offset; +{ + extern char **environ; + register int len; + register const char *np; + register char **p, *c; + + if (name == NULL || environ == NULL) + return (NULL); + for (np = name; *np && *np != '='; ++np) + continue; + len = np - name; + for (p = environ; (c = *p) != NULL; ++p) + if (strncmp(c, name, len) == 0 && c[len] == '=') { + *offset = p - environ; + return (c + len + 1); + } + return (NULL); +} diff --git a/src/kadmin.new/client/ss_wrapper.c b/src/kadmin.new/client/ss_wrapper.c new file mode 100644 index 000000000..f7bbda516 --- /dev/null +++ b/src/kadmin.new/client/ss_wrapper.c @@ -0,0 +1,56 @@ +/* + * Copyright 1994 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * + * ss wrapper for kadmin + */ + +#include +#include +#include + +extern ss_request_table kadmin_cmds; +extern int exit_status; + +int main(argc, argv) + int argc; + char *argv[]; +{ + char *request; + krb5_error_code retval; + int sci_idx, code = 0; + + request = kadmin_startup(argc, argv); + sci_idx = ss_create_invocation("kadmin", "5.0", (char *) NULL, + &kadmin_cmds, &retval); + if (retval) { + ss_perror(sci_idx, retval, "creating invocation"); + exit(1); + } + if (request) { + (void) ss_execute_line(sci_idx, request, &code); + if (code != 0) { + ss_perror(sci_idx, code, request); + exit_status++; + } + } else + ss_listen(sci_idx, &retval); + return quit() ? 1 : exit_status; +}