From c1f49c33995f5466786e40e821515e8664a64558 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 4 Sep 1996 02:21:12 +0000 Subject: [PATCH] Removing attic files from the live source tree git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9023 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/cli/attic/Makefile | 11 - src/kadmin/cli/attic/Makefile.in | 45 -- src/kadmin/cli/attic/configure.in | 15 - src/kadmin/cli/attic/getdate.y | 1006 ----------------------------- src/kadmin/cli/attic/kadmin.c | 958 --------------------------- src/kadmin/cli/attic/kadmin_ct.ct | 67 -- src/kadmin/cli/attic/memmove.c | 144 ----- src/kadmin/cli/attic/setenv.c | 165 ----- src/kadmin/cli/attic/ss_wrapper.c | 56 -- 9 files changed, 2467 deletions(-) delete mode 100644 src/kadmin/cli/attic/Makefile delete mode 100644 src/kadmin/cli/attic/Makefile.in delete mode 100644 src/kadmin/cli/attic/configure.in delete mode 100644 src/kadmin/cli/attic/getdate.y delete mode 100644 src/kadmin/cli/attic/kadmin.c delete mode 100644 src/kadmin/cli/attic/kadmin_ct.ct delete mode 100644 src/kadmin/cli/attic/memmove.c delete mode 100644 src/kadmin/cli/attic/setenv.c delete mode 100644 src/kadmin/cli/attic/ss_wrapper.c diff --git a/src/kadmin/cli/attic/Makefile b/src/kadmin/cli/attic/Makefile deleted file mode 100644 index 79e432fe4..000000000 --- a/src/kadmin/cli/attic/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -TOP = ../.. -include $(TOP)/config.mk/template - -SRCS = kadmin.c kadmin_ct.ct ss_wrapper.c getdate.y -OBJS = kadmin.o kadmin_ct.o ss_wrapper.o getdate.o -PROG = cli_secure_admin - -LIBS = $(LIBADMCLNT) $(LIBRPCLIB) $(LIBGSSAPI_KRB5) $(LIBKRB5_ALL) \ - $(LIBSS) $(LIBDYN) $(LIBDB) $(NDBMLIB) $(BSDLIB) $(NETLIB) - -expand NormalProgram diff --git a/src/kadmin/cli/attic/Makefile.in b/src/kadmin/cli/attic/Makefile.in deleted file mode 100644 index 160016af9..000000000 --- a/src/kadmin/cli/attic/Makefile.in +++ /dev/null @@ -1,45 +0,0 @@ -CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) $(OVSECINC) -OVSECROOT=/home/tlyu/ovsecure -OVSECSTAGE=/afs/dev.mit.edu/reference/ovsecure/sunos/stage -OVSECINC=-I$(OVSECROOT)/include -I$(OVSECSTAGE)/include -OVSECLIB=-L$(OVSECSTAGE)/lib -lclient -lcommon -lrpclib -ldyn -LDFLAGS = -g -LIBOBJS=@LIBOBJS@ -ISODELIB=$(OVSECROOT)/lib/libisode.a -COMERRLIB=$(OVSECROOT)/lib/libcom_err.a -SSLIB=$(OVSECSTAGE)/lib/libss.a -DBMLIB=$(OVSECROOT)/lib/libdb.a -KDBLIB=$(OVSECROOT)/lib/libkdb5.a - -all:: - -KLIB = $(OVSECROOT)/lib/libgssapi_krb5.a $(OVSECROOT)/lib/libkrb5.a $(OVSECROOT)/lib/libcrypto.a $(ISODELIB) $(SSLIB) $(COMERRLIB) $(DBMLIB) -DEPKLIB = $(TOPLIBD)/libgssapi_krb5.a $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) - -SRCS = - -OBJS = kadmin.o kadmin_ct.o ss_wrapper.o getdate.o $(LIBOBJS) - -all:: kadmin -kadmin.o: - $(CC) -c $(CCOPTS) $(OVSECINC) $(DEFS) kadmin.c -getdate.c getdate.h: getdate.y - $(RM) getdate.c getdate.h y.tab.* - $(YACC) -d $(srcdir)/getdate.y - $(MV) y.tab.c getdate.c - $(MV) y.tab.h getdate.h - -kadmin: $(OBJS) - $(CC) -o kadmin $(CFLAGS) $(OBJS) $(OVSECLIB) $(KLIB) $(LIBS) - -# needed until we run makedepend -kadmin_ct.c: kadmin_ct.ct - -kadmin_ct.o: kadmin_ct.c - -clean:: - $(RM) kadmin $(OBJS) kadmin_ct.c getdate.c getdate.h y.tab.c y.tab.h - -# testing rule for building getdate -getdate: getdate.c - $(CC) -o getdate $(CFLAGS) -DTEST getdate.c diff --git a/src/kadmin/cli/attic/configure.in b/src/kadmin/cli/attic/configure.in deleted file mode 100644 index 8cca51316..000000000 --- a/src/kadmin/cli/attic/configure.in +++ /dev/null @@ -1,15 +0,0 @@ -AC_INIT(getdate.y) -WITH_CCOPTS -CONFIG_RULES -AC_SET_BUILDTOP -AC_PROG_INSTALL -AC_PROG_YACC -AC_HAVE_HEADERS(unistd.h sys/timeb.h alloca.h) -AC_HAVE_FUNCS(ftime timezone) -AC_CHECK_LIB(ndbm,main) -AC_CHECK_LIB(dbm,main) -AC_REPLACE_FUNCS([setenv memmove]) -KRB_INCLUDE -ISODE_INCLUDE -WITH_KRB5ROOT -V5_AC_OUTPUT_MAKEFILE diff --git a/src/kadmin/cli/attic/getdate.y b/src/kadmin/cli/attic/getdate.y deleted file mode 100644 index 6b03e73bb..000000000 --- a/src/kadmin/cli/attic/getdate.y +++ /dev/null @@ -1,1006 +0,0 @@ -%{ -/* -** Originally written by Steven M. Bellovin while -** at the University of North Carolina at Chapel Hill. Later tweaked by -** a couple of people on Usenet. Completely overhauled by Rich $alz -** and Jim Berets in August, 1990; -** send any email to Rich. -** -** This grammar has nine shift/reduce conflicts. -** -** This code is in the public domain and has no copyright. -*/ -/* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */ -/* SUPPRESS 288 on yyerrlab *//* Label unused */ - -#ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -#include -#else -#include "config.h" -#endif -#endif - -/* Since the code of getdate.y is not included in the Emacs executable - itself, there is no need to #define static in this file. Even if - the code were included in the Emacs executable, it probably - wouldn't do any harm to #undef it here; this will only cause - problems if we try to write to a static variable, which I don't - think this code needs to do. */ -#ifdef emacs -#undef static -#endif - -/* The following block of alloca-related preprocessor directives is here - solely to allow compilation by non GNU-C compilers of the C parser - produced from this file by old versions of bison. Newer versions of - bison include a block similar to this one in bison.simple. */ - -#ifdef __GNUC__ -#undef alloca -#define alloca __builtin_alloca -#else -#ifdef HAVE_ALLOCA_H -#include -#else -#ifdef _AIX /* for Bison */ - #pragma alloca -#else -void *alloca (); -#endif -#endif -#endif - -#include -#include - -/* The code at the top of get_date which figures out the offset of the - current time zone checks various CPP symbols to see if special - tricks are need, but defaults to using the gettimeofday system call. - Include if that will be used. */ - -#if defined(vms) - -#include -#include - -#else - -#include - -#ifdef TIME_WITH_SYS_TIME -#include -#include -#else -#ifdef HAVE_SYS_TIME_H -#include -#else -#include -#endif -#endif - -#ifdef timezone -#undef timezone /* needed for sgi */ -#endif - -#if defined(HAVE_SYS_TIMEB_H) -#include -#else -/* -** We use the obsolete `struct timeb' as part of our interface! -** Since the system doesn't have it, we define it here; -** our callers must do likewise. -*/ -struct timeb { - time_t time; /* Seconds since the epoch */ - unsigned short millitm; /* Field not used */ - short timezone; /* Minutes west of GMT */ - short dstflag; /* Field not used */ -}; -#endif /* defined(HAVE_SYS_TIMEB_H) */ - -#endif /* defined(vms) */ - -#if defined (STDC_HEADERS) || defined (USG) -#include -#endif - -/* Some old versions of bison generate parsers that use bcopy. - That loses on systems that don't provide the function, so we have - to redefine it here. */ -#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy) -#define bcopy(from, to, len) memcpy ((to), (from), (len)) -#endif - -extern struct tm *gmtime(); -extern struct tm *localtime(); - -#define yyparse getdate_yyparse -#define yylex getdate_yylex -#define yyerror getdate_yyerror - -static int yylex (); -static int yyerror (); - -#if !defined(lint) && !defined(SABER) -static char RCS[] = - "$Header$"; -#endif /* !defined(lint) && !defined(SABER) */ - - -#define EPOCH 1970 -#define HOUR(x) ((time_t)(x) * 60) -#define SECSPERDAY (24L * 60L * 60L) - - -/* -** An entry in the lexical lookup table. -*/ -typedef struct _TABLE { - char *name; - int type; - time_t value; -} TABLE; - - -/* -** Daylight-savings mode: on, off, or not yet known. -*/ -typedef enum _DSTMODE { - DSTon, DSToff, DSTmaybe -} DSTMODE; - -/* -** Meridian: am, pm, or 24-hour style. -*/ -typedef enum _MERIDIAN { - MERam, MERpm, MER24 -} MERIDIAN; - - -/* -** Global variables. We could get rid of most of these by using a good -** union as the yacc stack. (This routine was originally written before -** yacc had the %union construct.) Maybe someday; right now we only use -** the %union very rarely. -*/ -static char *yyInput; -static DSTMODE yyDSTmode; -static time_t yyDayOrdinal; -static time_t yyDayNumber; -static int yyHaveDate; -static int yyHaveDay; -static int yyHaveRel; -static int yyHaveTime; -static int yyHaveZone; -static time_t yyTimezone; -static time_t yyDay; -static time_t yyHour; -static time_t yyMinutes; -static time_t yyMonth; -static time_t yySeconds; -static time_t yyYear; -static MERIDIAN yyMeridian; -static time_t yyRelMonth; -static time_t yyRelSeconds; - -%} - -%union { - time_t Number; - enum _MERIDIAN Meridian; -} - -%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT -%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST - -%type tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT -%type tSEC_UNIT tSNUMBER tUNUMBER tZONE -%type tMERIDIAN o_merid - -%% - -spec : /* NULL */ - | spec item - ; - -item : time { - yyHaveTime++; - } - | zone { - yyHaveZone++; - } - | date { - yyHaveDate++; - } - | day { - yyHaveDay++; - } - | rel { - yyHaveRel++; - } - | number - ; - -time : tUNUMBER tMERIDIAN { - yyHour = $1; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = $2; - } - | tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = 0; - yyMeridian = $4; - } - | tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($4 % 100 + ($4 / 100) * 60); - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = $6; - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($6 % 100 + ($6 / 100) * 60); - } - ; - -zone : tZONE { - yyTimezone = $1; - yyDSTmode = DSToff; - } - | tDAYZONE { - yyTimezone = $1; - yyDSTmode = DSTon; - } - | - tZONE tDST { - yyTimezone = $1; - yyDSTmode = DSTon; - } - ; - -day : tDAY { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tDAY ',' { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tUNUMBER tDAY { - yyDayOrdinal = $1; - yyDayNumber = $2; - } - ; - -date : tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - } - | tUNUMBER '/' tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - yyYear = $5; - } - | tUNUMBER tSNUMBER tSNUMBER { - /* ISO 8601 format. yyyy-mm-dd. */ - yyYear = $1; - yyMonth = -$2; - yyDay = -$3; - } - | tUNUMBER tMONTH tSNUMBER { - /* e.g. 17-JUN-1992. */ - yyDay = $1; - yyMonth = $2; - yyYear = -$3; - } - | tMONTH tUNUMBER { - yyMonth = $1; - yyDay = $2; - } - | tMONTH tUNUMBER ',' tUNUMBER { - yyMonth = $1; - yyDay = $2; - yyYear = $4; - } - | tUNUMBER tMONTH { - yyMonth = $2; - yyDay = $1; - } - | tUNUMBER tMONTH tUNUMBER { - yyMonth = $2; - yyDay = $1; - yyYear = $3; - } - ; - -rel : relunit tAGO { - yyRelSeconds = -yyRelSeconds; - yyRelMonth = -yyRelMonth; - } - | relunit - ; - -relunit : tUNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tSNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tMINUTE_UNIT { - yyRelSeconds += $1 * 60L; - } - | tSNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tUNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tSEC_UNIT { - yyRelSeconds++; - } - | tSNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tUNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tMONTH_UNIT { - yyRelMonth += $1; - } - ; - -number : tUNUMBER { - if (yyHaveTime && yyHaveDate && !yyHaveRel) - yyYear = $1; - else { - if($1>10000) { - yyHaveDate++; - yyDay= ($1)%100; - yyMonth= ($1/100)%100; - yyYear = $1/10000; - } - else { - yyHaveTime++; - if ($1 < 100) { - yyHour = $1; - yyMinutes = 0; - } - else { - yyHour = $1 / 100; - yyMinutes = $1 % 100; - } - yySeconds = 0; - yyMeridian = MER24; - } - } - } - ; - -o_merid : /* NULL */ { - $$ = MER24; - } - | tMERIDIAN { - $$ = $1; - } - ; - -%% - -/* Month and day table. */ -static TABLE const MonthDayTable[] = { - { "january", tMONTH, 1 }, - { "february", tMONTH, 2 }, - { "march", tMONTH, 3 }, - { "april", tMONTH, 4 }, - { "may", tMONTH, 5 }, - { "june", tMONTH, 6 }, - { "july", tMONTH, 7 }, - { "august", tMONTH, 8 }, - { "september", tMONTH, 9 }, - { "sept", tMONTH, 9 }, - { "october", tMONTH, 10 }, - { "november", tMONTH, 11 }, - { "december", tMONTH, 12 }, - { "sunday", tDAY, 0 }, - { "monday", tDAY, 1 }, - { "tuesday", tDAY, 2 }, - { "tues", tDAY, 2 }, - { "wednesday", tDAY, 3 }, - { "wednes", tDAY, 3 }, - { "thursday", tDAY, 4 }, - { "thur", tDAY, 4 }, - { "thurs", tDAY, 4 }, - { "friday", tDAY, 5 }, - { "saturday", tDAY, 6 }, - { NULL } -}; - -/* Time units table. */ -static TABLE const UnitsTable[] = { - { "year", tMONTH_UNIT, 12 }, - { "month", tMONTH_UNIT, 1 }, - { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 }, - { "week", tMINUTE_UNIT, 7 * 24 * 60 }, - { "day", tMINUTE_UNIT, 1 * 24 * 60 }, - { "hour", tMINUTE_UNIT, 60 }, - { "minute", tMINUTE_UNIT, 1 }, - { "min", tMINUTE_UNIT, 1 }, - { "second", tSEC_UNIT, 1 }, - { "sec", tSEC_UNIT, 1 }, - { NULL } -}; - -/* Assorted relative-time words. */ -static TABLE const OtherTable[] = { - { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, - { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, - { "today", tMINUTE_UNIT, 0 }, - { "now", tMINUTE_UNIT, 0 }, - { "last", tUNUMBER, -1 }, - { "this", tMINUTE_UNIT, 0 }, - { "next", tUNUMBER, 2 }, - { "first", tUNUMBER, 1 }, -/* { "second", tUNUMBER, 2 }, */ - { "third", tUNUMBER, 3 }, - { "fourth", tUNUMBER, 4 }, - { "fifth", tUNUMBER, 5 }, - { "sixth", tUNUMBER, 6 }, - { "seventh", tUNUMBER, 7 }, - { "eighth", tUNUMBER, 8 }, - { "ninth", tUNUMBER, 9 }, - { "tenth", tUNUMBER, 10 }, - { "eleventh", tUNUMBER, 11 }, - { "twelfth", tUNUMBER, 12 }, - { "ago", tAGO, 1 }, - { NULL } -}; - -/* The timezone table. */ -/* Some of these are commented out because a time_t can't store a float. */ -static TABLE const TimezoneTable[] = { - { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ - { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ - { "utc", tZONE, HOUR( 0) }, - { "wet", tZONE, HOUR( 0) }, /* Western European */ - { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ - { "wat", tZONE, HOUR( 1) }, /* West Africa */ - { "at", tZONE, HOUR( 2) }, /* Azores */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ - { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ -#endif -#if 0 - { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */ - { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */ - { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */ -#endif - { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ - { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ - { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ - { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ - { "cst", tZONE, HOUR( 6) }, /* Central Standard */ - { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ - { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ - { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ - { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ - { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ - { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ - { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ - { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ - { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ - { "cat", tZONE, HOUR(10) }, /* Central Alaska */ - { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ - { "nt", tZONE, HOUR(11) }, /* Nome */ - { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ - { "cet", tZONE, -HOUR(1) }, /* Central European */ - { "met", tZONE, -HOUR(1) }, /* Middle European */ - { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */ - { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ - { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */ - { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */ - { "fwt", tZONE, -HOUR(1) }, /* French Winter */ - { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */ - { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */ - { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */ -#if 0 - { "it", tZONE, -HOUR(3.5) },/* Iran */ -#endif - { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */ - { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */ -#if 0 - { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */ -#endif - { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */ -#if 0 - /* For completeness. NST is also Newfoundland Stanard, and SST is - * also Swedish Summer. */ - { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */ - { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */ -#endif /* 0 */ - { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */ - { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */ -#if 0 - { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */ -#endif - { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */ - { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */ -#if 0 - { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */ - { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */ -#endif - { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ - { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ - { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ - { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ - { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ - { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ - { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ - { NULL } -}; - -/* Military timezone table. */ -static TABLE const MilitaryTable[] = { - { "a", tZONE, HOUR( 1) }, - { "b", tZONE, HOUR( 2) }, - { "c", tZONE, HOUR( 3) }, - { "d", tZONE, HOUR( 4) }, - { "e", tZONE, HOUR( 5) }, - { "f", tZONE, HOUR( 6) }, - { "g", tZONE, HOUR( 7) }, - { "h", tZONE, HOUR( 8) }, - { "i", tZONE, HOUR( 9) }, - { "k", tZONE, HOUR( 10) }, - { "l", tZONE, HOUR( 11) }, - { "m", tZONE, HOUR( 12) }, - { "n", tZONE, HOUR(- 1) }, - { "o", tZONE, HOUR(- 2) }, - { "p", tZONE, HOUR(- 3) }, - { "q", tZONE, HOUR(- 4) }, - { "r", tZONE, HOUR(- 5) }, - { "s", tZONE, HOUR(- 6) }, - { "t", tZONE, HOUR(- 7) }, - { "u", tZONE, HOUR(- 8) }, - { "v", tZONE, HOUR(- 9) }, - { "w", tZONE, HOUR(-10) }, - { "x", tZONE, HOUR(-11) }, - { "y", tZONE, HOUR(-12) }, - { "z", tZONE, HOUR( 0) }, - { NULL } -}; - - - - -/* ARGSUSED */ -static int -yyerror(s) - char *s; -{ - return 0; -} - - -static time_t -ToSeconds(Hours, Minutes, Seconds, Meridian) - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; -{ - if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) - return -1; - switch (Meridian) { - case MER24: - if (Hours < 0 || Hours > 23) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERam: - if (Hours < 1 || Hours > 12) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERpm: - if (Hours < 1 || Hours > 12) - return -1; - return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; - default: - abort (); - } - /* NOTREACHED */ -} - - -static time_t -Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) - time_t Month; - time_t Day; - time_t Year; - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; - DSTMODE DSTmode; -{ - static int DaysInMonth[12] = { - 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - time_t tod; - time_t Julian; - int i; - - if (Year < 0) - Year = -Year; - if (Year < 100) - Year += 1900; - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) - ? 29 : 28; - if (Year < EPOCH || Year > 1999 - || Month < 1 || Month > 12 - /* Lint fluff: "conversion from long may lose accuracy" */ - || Day < 1 || Day > DaysInMonth[(int)--Month]) - return -1; - - for (Julian = Day - 1, i = 0; i < Month; i++) - Julian += DaysInMonth[i]; - for (i = EPOCH; i < Year; i++) - Julian += 365 + (i % 4 == 0); - Julian *= SECSPERDAY; - Julian += yyTimezone * 60L; - if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) - return -1; - Julian += tod; - if (DSTmode == DSTon - || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) - Julian -= 60 * 60; - return Julian; -} - - -static time_t -DSTcorrect(Start, Future) - time_t Start; - time_t Future; -{ - time_t StartDay; - time_t FutureDay; - - StartDay = (localtime(&Start)->tm_hour + 1) % 24; - FutureDay = (localtime(&Future)->tm_hour + 1) % 24; - return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; -} - - -static time_t -RelativeDate(Start, DayOrdinal, DayNumber) - time_t Start; - time_t DayOrdinal; - time_t DayNumber; -{ - struct tm *tm; - time_t now; - - now = Start; - tm = localtime(&now); - now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); - now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); - return DSTcorrect(Start, now); -} - - -static time_t -RelativeMonth(Start, RelMonth) - time_t Start; - time_t RelMonth; -{ - struct tm *tm; - time_t Month; - time_t Year; - - if (RelMonth == 0) - return 0; - tm = localtime(&Start); - Month = 12 * tm->tm_year + tm->tm_mon + RelMonth; - Year = Month / 12; - Month = Month % 12 + 1; - return DSTcorrect(Start, - Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - MER24, DSTmaybe)); -} - - -static int -LookupWord(buff) - char *buff; -{ - register char *p; - register char *q; - register const TABLE *tp; - int i; - int abbrev; - - /* Make it lowercase. */ - for (p = buff; *p; p++) - if (isupper(*p)) - *p = tolower(*p); - - if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { - yylval.Meridian = MERam; - return tMERIDIAN; - } - if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { - yylval.Meridian = MERpm; - return tMERIDIAN; - } - - /* See if we have an abbreviation for a month. */ - if (strlen(buff) == 3) - abbrev = 1; - else if (strlen(buff) == 4 && buff[3] == '.') { - abbrev = 1; - buff[3] = '\0'; - } - else - abbrev = 0; - - for (tp = MonthDayTable; tp->name; tp++) { - if (abbrev) { - if (strncmp(buff, tp->name, 3) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - else if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - if (strcmp(buff, "dst") == 0) - return tDST; - - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Strip off any plural and try the units table again. */ - i = strlen(buff) - 1; - if (buff[i] == 's') { - buff[i] = '\0'; - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - buff[i] = 's'; /* Put back for "this" in OtherTable. */ - } - - for (tp = OtherTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Military timezones. */ - if (buff[1] == '\0' && isalpha(*buff)) { - for (tp = MilitaryTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - /* Drop out any periods and try the timezone table again. */ - for (i = 0, p = q = buff; *q; q++) - if (*q != '.') - *p++ = *q; - else - i++; - *p = '\0'; - if (i) - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - return tID; -} - - -static int -yylex() -{ - register char c; - register char *p; - char buff[20]; - int Count; - int sign; - - for ( ; ; ) { - while (isspace(*yyInput)) - yyInput++; - - if (isdigit(c = *yyInput) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - if (!isdigit(*++yyInput)) - /* skip the '-' sign */ - continue; - } - else - sign = 0; - for (yylval.Number = 0; isdigit(c = *yyInput++); ) - yylval.Number = 10 * yylval.Number + c - '0'; - yyInput--; - if (sign < 0) - yylval.Number = -yylval.Number; - return sign ? tSNUMBER : tUNUMBER; - } - if (isalpha(c)) { - for (p = buff; isalpha(c = *yyInput++) || c == '.'; ) - if (p < &buff[sizeof buff - 1]) - *p++ = c; - *p = '\0'; - yyInput--; - return LookupWord(buff); - } - if (c != '(') - return *yyInput++; - Count = 0; - do { - c = *yyInput++; - if (c == '\0') - return c; - if (c == '(') - Count++; - else if (c == ')') - Count--; - } while (Count > 0); - } -} - - -#define TM_YEAR_ORIGIN 1900 - -/* Yield A - B, measured in seconds. */ -static time_t -difftm(a, b) - struct tm *a, *b; -{ - int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); - int by = b->tm_year + (TM_YEAR_ORIGIN - 1); - return - ( - ( - ( - /* difference in day of year */ - a->tm_yday - b->tm_yday - /* + intervening leap days */ - + ((ay >> 2) - (by >> 2)) - - (ay/100 - by/100) - + ((ay/100 >> 2) - (by/100 >> 2)) - /* + difference in years * 365 */ - + (time_t)(ay-by) * 365 - )*24 + (a->tm_hour - b->tm_hour) - )*60 + (a->tm_min - b->tm_min) - )*60 + (a->tm_sec - b->tm_sec); -} - -time_t -get_date(p, now) - char *p; - struct timeb *now; -{ - struct tm *tm, gmt; - struct timeb ftz; - time_t Start; - time_t tod; - - yyInput = p; - if (now == NULL) { - now = &ftz; - (void)time(&ftz.time); - - if (! (tm = gmtime (&ftz.time))) - return -1; - gmt = *tm; /* Make a copy, in case localtime modifies *tm. */ - ftz.timezone = difftm (&gmt, localtime (&ftz.time)) / 60; - } - - tm = localtime(&now->time); - yyYear = tm->tm_year; - yyMonth = tm->tm_mon + 1; - yyDay = tm->tm_mday; - yyTimezone = now->timezone; - yyDSTmode = DSTmaybe; - yyHour = 0; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = MER24; - yyRelSeconds = 0; - yyRelMonth = 0; - yyHaveDate = 0; - yyHaveDay = 0; - yyHaveRel = 0; - yyHaveTime = 0; - yyHaveZone = 0; - - if (yyparse() - || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) - return -1; - - if (yyHaveDate || yyHaveTime || yyHaveDay) { - Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, - yyMeridian, yyDSTmode); - if (Start < 0) - return -1; - } - else { - Start = now->time; - if (!yyHaveRel) - Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec; - } - - Start += yyRelSeconds; - Start += RelativeMonth(Start, yyRelMonth); - - if (yyHaveDay && !yyHaveDate) { - tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber); - Start += tod; - } - - /* Have to do *something* with a legitimate -1 so it's distinguishable - * from the error return value. (Alternately could set errno on error.) */ - return Start == -1 ? 0 : Start; -} - - -#if defined(TEST) - -/* ARGSUSED */ -main(ac, av) - int ac; - char *av[]; -{ - char buff[128]; - time_t d; - - (void)printf("Enter date, or blank line to exit.\n\t> "); - (void)fflush(stdout); - while (gets(buff) && buff[0]) { - d = get_date(buff, (struct timeb *)NULL); - if (d == -1) - (void)printf("Bad format - couldn't convert.\n"); - else - (void)printf("%s", ctime(&d)); - (void)printf("\t> "); - (void)fflush(stdout); - } - exit(0); - /* NOTREACHED */ -} -#endif /* defined(TEST) */ diff --git a/src/kadmin/cli/attic/kadmin.c b/src/kadmin/cli/attic/kadmin.c deleted file mode 100644 index 91d2a71e4..000000000 --- a/src/kadmin/cli/attic/kadmin.c +++ /dev/null @@ -1,958 +0,0 @@ -/* - * 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. - * - * kadmin.c: base functions for a kadmin command line interface using - * the OVSecure library - */ - -#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 */ -struct pflag { - char *flagname; /* name of flag as typed to CLI */ - int flaglen; /* length of string (not counting -,+) */ - krb5_flags theflag; /* actual principal flag to set/clear */ - int set; /* 0 means clear, 1 means set (on '-') */ -}; - -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}, -{"allow_renewable", 15, KRB5_KDB_DISALLOW_RENEWABLE, 1}, -{"allow_proxiable", 15, KRB5_KDB_DISALLOW_PROXIABLE, 1}, -{"allow_dup_skey", 14, KRB5_KDB_DISALLOW_DUP_SKEY, 1}, -{"allow_tix", 9, KRB5_KDB_DISALLOW_ALL_TIX, 1}, -{"requires_preauth", 16, KRB5_KDB_REQUIRES_PRE_AUTH, 0}, -{"requres_hwauth", 14, KRB5_KDB_REQUIRES_HW_AUTH, 0}, -{"needchange", 10, KRB5_KDB_REQUIRES_PWCHANGE, 0}, -{"allow_svr", 9, KRB5_KDB_DISALLOW_SVR, 1}, -{"password_changing_service", 25, KRB5_KDB_PWCHANGE_SERVICE, 0 } -}; - -static char *prflags[] = { - "DISALLOW_POSTDATED", /* 0x00000001 */ - "DISALLOW_FORWARDABLE", /* 0x00000002 */ - "DISALLOW_TGT_BASED", /* 0x00000004 */ - "DISALLOW_RENEWABLE", /* 0x00000008 */ - "DISALLOW_PROXIABLE", /* 0x00000010 */ - "DISALLOW_DUP_SKEY", /* 0x00000020 */ - "DISALLOW_ALL_TIX", /* 0x00000040 */ - "REQUIRES_PRE_AUTH", /* 0x00000080 */ - "REQUIRES_HW_AUTH", /* 0x00000100 */ - "REQUIRES_PWCHANGE", /* 0x00000200 */ - "UNKNOWN_0x00000400", /* 0x00000400 */ - "UNKNOWN_0x00000800", /* 0x00000800 */ - "DISALLOW_SVR", /* 0x00001000 */ - "PWCHANGE_SERVICE" /* 0x00002000 */ -}; - -char *getenv(); -struct passwd *getpwuid(); -int exit_status = 0; -char *def_realm = NULL; - -void *ovsec_hndl = NULL; - -void usage() -{ - fprintf(stderr, - "usage: kadmin [-r realm] [-p principal] [-k keytab] [-q query]\n"); - exit(1); -} - -/* this is a wrapper to go around krb5_parse_principal so we can set - the default realm up properly */ -krb5_error_code kadmin_parse_name(name, principal) - char *name; - krb5_principal *principal; -{ - char *cp, *fullname; - krb5_error_code retval; - - /* assumes def_realm is initialized! */ - fullname = (char *)malloc(strlen(name) + 1 + strlen(def_realm) + 1); - if (fullname == NULL) - return ENOMEM; - strcpy(fullname, name); - cp = strchr(fullname, '@'); - while (cp) { - if (cp - fullname && *(cp - 1) != '\\') - break; - else - cp = strchr(cp, '@'); - } - if (cp == NULL) { - strcat(fullname, "@"); - strcat(fullname, def_realm); - } - retval = krb5_parse_name(fullname, principal); - free(fullname); - return retval; -} - -char *kadmin_startup(argc, argv) - int argc; - char *argv[]; -{ - extern char *optarg; - char *princstr = NULL, *keytab = NULL, *query = NULL; - char *luser, *canon, *cp; - int optchar, freeprinc = 0; - struct passwd *pw; - ovsec_kadm_ret_t retval; - krb5_ccache cc; - krb5_principal princ; - - while ((optchar = getopt(argc, argv, "r:p:k:q:")) != EOF) { - switch (optchar) { - case 'r': - def_realm = optarg; - break; - case 'p': - princstr = optarg; - break; - case 'k': - fprintf(stderr, "kadmin: -k not supported yet\n"); - exit(1); - break; - case 'q': - query = optarg; - break; - default: - usage(); - } - } - if (def_realm == NULL && krb5_get_default_realm(&def_realm)) { - if (freeprinc) - free(princstr); - fprintf(stderr, "kadmin: unable to get default realm\n"); - exit(1); - } - if (princstr == NULL) { - if (!krb5_cc_default(&cc) && !krb5_cc_get_principal(cc, &princ)) { - char *realm = NULL; - if (krb5_unparse_name(princ, &canon)) { - fprintf(stderr, - "kadmin: unable to canonicalize principal\n"); - krb5_free_principal(princ); - exit(1); - } - /* strip out realm of principal if it's there */ - realm = strchr(canon, '@'); - while (realm) { - if (realm - canon && *(realm - 1) != '\\') - break; - else - realm = strchr(realm, '@'); - } - if (realm) - *realm++ = '\0'; - cp = strchr(canon, '/'); - while (cp) { - if (cp - canon && *(cp - 1) != '\\') - break; - else - cp = strchr(cp, '/'); - } - if (cp != NULL) - *cp = '\0'; - princstr = (char*)malloc(strlen(canon) + 6 /* "/admin" */ + - (realm ? 1 + strlen(realm) : 0) + 1); - if (princstr == NULL) { - fprintf(stderr, "kadmin: out of memory\n"); - exit(1); - } - strcpy(princstr, canon); - strcat(princstr, "/admin"); - if (realm) { - strcat(princstr, "@"); - strcat(princstr, realm); - } - free(canon); - krb5_free_principal(princ); - freeprinc++; - } else if (luser = getenv("USER")) { - princstr = malloc(strlen(luser) + 7 /* "/admin@" */ - + strlen(def_realm) + 1); - if (princstr == NULL) { - fprintf(stderr, "kadmin: out of memory\n"); - exit(1); - } - strcpy(princstr, luser); - strcat(princstr, "/admin"); - strcat(princstr, "@"); - strcat(princstr, def_realm); - freeprinc++; - } else if (pw = getpwuid(getuid())) { - princstr = malloc(strlen(pw->pw_name) + 7 /* "/admin@" */ - + strlen(def_realm) + 1); - if (princstr == NULL) { - fprintf(stderr, "kadmin: out of memory\n"); - exit(1); - } - strcpy(princstr, pw->pw_name); - strcat(princstr, "/admin@"); - strcat(princstr, def_realm); - freeprinc++; - } else { - fprintf(stderr, "kadmin: unable to figure out a principal name\n"); - exit(1); - } - } - retval = ovsec_kadm_init_with_password(princstr, NULL, - OVSEC_KADM_ADMIN_SERVICE, - def_realm, - OVSEC_KADM_STRUCT_VERSION, - OVSEC_KADM_API_VERSION_1, - &ovsec_hndl); - if (freeprinc) - free(princstr); - if (retval) { /* assume kadm_init does init_ets() */ - com_err("kadmin", retval, "while initializing kadmin interface"); - exit(1); - } - return query; -} - -int quit() -{ - ovsec_kadm_destroy(ovsec_hndl); - /* insert more random cleanup here */ -} - -void kadmin_delprinc(argc, argv) - int argc; - char *argv[]; -{ - ovsec_kadm_ret_t retval; - krb5_principal princ; - char *canon; - char reply[5]; - - if (argc < 2 || argc > 3) { - fprintf(stderr, "delete_principal: wrong number of arguments\n"); - return; - } - if (argc == 3 && - (strlen(argv[1]) == 6 ? strcmp("-force", argv[1]) : 1)) { - fprintf(stderr, "delete_principal: bad arguments\n"); - return; - } - retval = kadmin_parse_name(argv[argc - 1], &princ); - if (retval) { - com_err("delete_principal", retval, "while parsing principal name"); - return; - } - retval = krb5_unparse_name(princ, &canon); - if (retval) { - com_err("delete_principal", retval, - "while canonicalizing principal"); - krb5_free_principal(princ); - return; - } - if (argc == 2) { - printf("Are you sure you want to delete the principal \"%s\"? (yes/no): ", canon); - fgets(reply, sizeof (reply), stdin); - if (strcmp("yes\n", reply)) { - fprintf(stderr, "Principal \"%s\" not deleted\n", canon); - free(canon); - krb5_free_principal(princ); - return; - } - } - retval = ovsec_kadm_delete_principal(ovsec_hndl, princ); - krb5_free_principal(princ); - if (retval) { - com_err("delete_principal", retval, - "while deleteing principal \"%s\"", canon); - free(canon); - return; - } - printf("Principal \"%s\" deleted.\nMake sure that you have removed this principal from all ACLs before reusing.\n", canon); - free(canon); - return; -} - -void kadmin_renprinc(argc, argv) - int argc; - char *argv[]; -{ - krb5_principal oldprinc, newprinc; - char *oldcanon, *newcanon; - char reply[5]; - ovsec_kadm_ret_t retval; - - if (argc < 3 || argc > 4) { - fprintf(stderr, "rename_principal: wrong number of arguments\n"); - return; - } - if (argc == 4 && - (strlen(argv[1]) == 6 ? strcmp("-force", argv[1]) : 1)) { - fprintf(stderr, "rename_principal: bad arguments\n"); - return; - } - retval = kadmin_parse_name(argv[argc - 2], &oldprinc); - if (retval) { - com_err("rename_principal", retval, "while parsing old principal"); - return; - } - retval = kadmin_parse_name(argv[argc - 1], &newprinc); - if (retval) { - krb5_free_principal(oldprinc); - com_err("rename_principal", retval, "while parsing new principal"); - return; - } - retval = krb5_unparse_name(oldprinc, &oldcanon); - if (retval) { - com_err("rename_principal", retval, - "while canonicalizing old principal"); - krb5_free_principal(newprinc); - krb5_free_principal(oldprinc); - return; - } - retval = krb5_unparse_name(newprinc, &newcanon); - if (retval) { - com_err("rename_principal", retval, - "while canonicalizing new principal"); - free(oldcanon); - krb5_free_principal(newprinc); - krb5_free_principal(oldprinc); - return; - } - if (argc == 3) { - printf("Are you sure you want to rename the principal \"%s\" to \"%s\"? (yes/no): ", - oldcanon, newcanon); - fgets(reply, sizeof (reply), stdin); - if (strcmp("yes\n", reply)) { - fprintf(stderr, - "rename_principal: \"%s\" NOT renamed to \"%s\".\n", - oldcanon, newcanon); - free(newcanon); - free(oldcanon); - krb5_free_principal(newprinc); - krb5_free_principal(oldprinc); - return; - } - } - retval = ovsec_kadm_rename_principal(ovsec_hndl, oldprinc, newprinc); - krb5_free_principal(oldprinc); - krb5_free_principal(newprinc); - if (retval) { - com_err("rename_principal", retval, - "while renaming \"%s\" to \"%s\".", oldcanon, - newcanon); - free(newcanon); - free(oldcanon); - return; - } - printf("Principal \"%s\" renamed to \"%s\".\nMake sure that you have removed \"%s\" from all ACLs before reusing.\n", - oldcanon, newcanon, newcanon); - return; -} - -void kadmin_cpw(argc, argv) - int argc; - char *argv[]; -{ - ovsec_kadm_ret_t retval; - static char newpw[1024]; - static char prompt1[1024], prompt2[1024]; - char *canon; - krb5_principal princ; - - if (argc < 2 || argc > 4) { - fprintf(stderr, "change_password: too many arguments\n"); - return; - } - retval = kadmin_parse_name(argv[argc - 1], &princ); - if (retval) { - com_err("change_password", retval, "while parsing principal name"); - return; - } - retval = krb5_unparse_name(princ, &canon); - if (retval) { - com_err("change_password", retval, "while canonicalizing principal"); - krb5_free_principal(princ); - return; - } - if ((argc == 4) && (strlen(argv[1]) == 3) && !strcmp("-pw", argv[1])) { - retval = ovsec_kadm_chpass_principal(ovsec_hndl, princ, argv[2]); - krb5_free_principal(princ); - if (retval) { - com_err("change_password", retval, - "while changing password for \"%s\".", canon); - free(canon); - return; - } - printf("Password for \"%s\" changed.\n", canon); - free(canon); - return; - } else if ((argc == 3) && (strlen(argv[1]) == 8) && - !strcmp("-randkey", argv[1])) { - krb5_keyblock *newkey = NULL; - retval = ovsec_kadm_randkey_principal(ovsec_hndl, princ, &newkey); - krb5_free_principal(princ); - if (retval) { - com_err("change_password", retval, - "while randomizing key for \"%s\".", canon); - free(canon); - return; - } - memset(newkey->contents, 0, newkey->length); - printf("Key for \"%s\" randomized.\n", canon); - free(canon); - return; - } else if (argc == 2) { - int i = sizeof (newpw) - 1; - - sprintf(prompt1, "Enter password for principal \"%.900s\": ", - argv[1]); - sprintf(prompt2, - "Re-enter password for principal \"%.900s\": ", - argv[1]); - retval = krb5_read_password(prompt1, prompt2, - newpw, &i); - if (retval) { - com_err("change_password", retval, - "while reading password for \"%s\".", canon); - free(canon); - krb5_free_principal(princ); - return; - } - retval = ovsec_kadm_chpass_principal(ovsec_hndl, princ, newpw); - krb5_free_principal(princ); - memset(newpw, 0, sizeof (newpw)); - if (retval) { - com_err("change_password", retval, - "while changing password for \"%s\".", canon); - free(canon); - return; - } - printf("Password for \"%s\" changed.\n", canon); - free(canon); - return; - } - fprintf(stderr, "change_password: bad arguments\n"); - free(canon); - krb5_free_principal(princ); - return; -} - -int kadmin_parse_princ_args(argc, argv, oprinc, mask, pass, caller) - int argc; - char *argv[]; - ovsec_kadm_principal_ent_t oprinc; - u_int32 *mask; - char **pass, *caller; -{ - int i, j; - struct timeb now; - krb5_error_code retval; - - *mask = 0; - *pass = NULL; - ftime(&now); - for (i = 1; i < argc - 1; i++) { - if (strlen(argv[i]) == 7 && - !strcmp("-expire", argv[i])) { - if (++i > argc - 2) - return -1; - else { - oprinc->princ_expire_time = get_date(argv[i], now); - *mask |= OVSEC_KADM_PRINC_EXPIRE_TIME; - continue; - } - } - if (strlen(argv[i]) == 9 && - !strcmp("-pwexpire", argv[i])) { - if (++i > argc - 2) - return -1; - else { - oprinc->pw_expiration = get_date(argv[i], now); - *mask |= OVSEC_KADM_PW_EXPIRATION; - continue; - } - } - if (strlen(argv[i]) == 8 && - !strcmp("-maxlife", argv[i])) { - if (++i > argc - 2) - return -1; - else { - oprinc->max_life = get_date(argv[i], now) - now.time; - *mask |= OVSEC_KADM_MAX_LIFE; - continue; - } - } - if (strlen(argv[i]) == 5 && - !strcmp("-kvno", argv[i])) { - if (++i > argc - 2) - return -1; - else { - oprinc->kvno = atoi(argv[i]); - *mask |= OVSEC_KADM_KVNO; - continue; - } - } - if (strlen(argv[i]) == 8 && - !strcmp("-policy", argv[i])) { - if (++i > argc - 2) - return -1; - else { - oprinc->policy = argv[i]; - *mask |= OVSEC_KADM_POLICY; - continue; - } - } - if (strlen(argv[i]) == 12 && - !strcmp("-clearpolicy", argv[i])) { - oprinc->policy = NULL; - *mask |= OVSEC_KADM_POLICY_CLR; - continue; - } - if (strlen(argv[i]) == 3 && - !strcmp("-pw", argv[i])) { - if (++i > argc - 2) - return -1; - else { - *pass = argv[i]; - continue; - } - } - for (j = 0; j < sizeof (flags) / sizeof (struct pflag); j++) { - if (strlen(argv[i]) == flags[j].flaglen + 1 && - !strcmp(flags[j].flagname, - &argv[i][1] /* strip off leading + or - */)) { - if (flags[j].set && argv[i][0] == '-' || - !flags[j].set && argv[i][0] == '+') { - oprinc->attributes |= flags[j].theflag; - *mask |= OVSEC_KADM_ATTRIBUTES; - break; - } else if (flags[j].set && argv[i][0] == '+' || - !flags[j].set && argv[i][0] == '-') { - oprinc->attributes &= ~flags[j].theflag; - *mask |= OVSEC_KADM_ATTRIBUTES; - break; - } else { - return -1; - } - } - } - return -1; - } - if (i != argc - 1) { - fprintf(stderr, "%s: parser lost count!\n", caller); - return -1; - } - retval = kadmin_parse_name(argv[i], &oprinc->principal); - if (retval) { - com_err(caller, retval, "while parsing principal"); - return -1; - } - return 0; -} - -void kadmin_addprinc(argc, argv) - int argc; - char *argv[]; -{ - ovsec_kadm_principal_ent_rec princ; - u_int32 mask; - char *pass, *canon; - krb5_error_code retval; - static char newpw[1024]; - static char prompt1[1024], prompt2[1024]; - - princ.attributes = 0; - if (kadmin_parse_princ_args(argc, argv, - &princ, &mask, &pass, "add_principal")) { - fprintf(stderr, "add_principal: bad arguments\n"); - return; - } - retval = krb5_unparse_name(princ.principal, &canon); - if (retval) { - com_err("add_principal", - retval, "while canonicalizing principal"); - krb5_free_principal(princ.principal); - return; - } - if (pass == NULL) { - int i = sizeof (newpw) - 1; - - sprintf(prompt1, "Enter password for principal \"%.900s\": ", - argv[1]); - sprintf(prompt2, - "Re-enter password for principal \"%.900s\": ", - argv[1]); - retval = krb5_read_password(prompt1, prompt2, - newpw, &i); - if (retval) { - com_err("add_principal", retval, - "while reading password for \"%s\".", canon); - free(canon); - krb5_free_principal(princ.principal); - return; - } - pass = newpw; - } - mask |= OVSEC_KADM_PRINCIPAL; - retval = ovsec_kadm_create_principal(ovsec_hndl, &princ, mask, pass); - krb5_free_principal(princ.principal); - if (retval) { - com_err("add_principal", retval, "while creating \"%s\".", - canon); - free(canon); - return; - } - printf("Principal \"%s\" created.\n", canon); - free(canon); -} - -void kadmin_modprinc(argc, argv) - int argc; - char *argv[]; -{ - ovsec_kadm_principal_ent_rec princ; - u_int32 mask; - krb5_error_code retval; - char *pass, *canon; - - princ.attributes = 0; - if (kadmin_parse_princ_args(argc, argv, - &princ, &mask, &pass, "modify_principal")) { - fprintf(stderr, "modify_principal: bad arguments\n"); - return; - } - retval = krb5_unparse_name(princ.principal, &canon); - if (retval) { - com_err("modify_principal", retval, - "while canonicalizing principal"); - krb5_free_principal(princ.principal); - return; - } - retval = ovsec_kadm_modify_principal(ovsec_hndl, &princ, mask); - if (retval) { - com_err("modify_principal", retval, "while modifying \"%s\".", - argv[argc - 1]); - return; - } -} - -void kadmin_getprinc(argc, argv) - int argc; - char *argv[]; -{ - ovsec_kadm_principal_ent_t dprinc; - krb5_principal princ; - krb5_error_code retval; - char *canon, *modcanon; - int i; - - if (argc < 2 || argc > 3) { - fprintf(stderr, "get_principal: wrong number of arguments\n"); - return; - } - if (argc == 3 && - (strlen(argv[1]) == 6 ? strcmp("-terse", argv[1]) : 1)) { - fprintf(stderr, "get_principal: bad arguments\n"); - return; - } - retval = kadmin_parse_name(argv[argc - 1], &princ); - if (retval) { - com_err("get_principal", retval, "while parsing principal"); - return; - } - retval = krb5_unparse_name(princ, &canon); - if (retval) { - com_err("get_principal", retval, "while canonicalizing principal"); - krb5_free_principal(princ); - return; - } - retval = ovsec_kadm_get_principal(ovsec_hndl, princ, &dprinc); - krb5_free_principal(princ); - if (retval) { - com_err("get_principal", retval, "while retrieving \"%s\".", canon); - free(canon); - return; - } - retval = krb5_unparse_name(dprinc->mod_name, &modcanon); - if (retval) { - com_err("get_principal", retval, "while unparsing modname"); - ovsec_kadm_free_principal_ent(ovsec_hndl, dprinc); - free(canon); - return; - } - if (argc == 2) { - printf("Principal: %s\n", canon); - printf("Expiration date: %d\n", dprinc->princ_expire_time); - printf("Last password change: %d\n", dprinc->last_pwd_change); - printf("Password expiration date: %d\n", dprinc->pw_expiration); - printf("Maximum life: %d\n", dprinc->max_life); - printf("Last modified: by %s\n\ton %d\n", - modcanon, dprinc->mod_date); - printf("Attributes: "); - for (i = 0; i < sizeof (prflags) / sizeof (char *); i++) { - if (dprinc->attributes & (krb5_flags) 1 << i) - printf(" %s", prflags[i]); - } - printf("\n"); - printf("Key version: %d\n", dprinc->kvno); - printf("Master key version: %d\n", dprinc->mkvno); - printf("Policy: %s\n", dprinc->policy); - } else { - printf("\"%s\"\t%d\t%d\t%d\t%d\t\"%s\"\t%d\t%d\t%d\t%d\t\"%s\"\n", - canon, dprinc->princ_expire_time, dprinc->last_pwd_change, - dprinc->pw_expiration, dprinc->max_life, modcanon, - dprinc->mod_date, dprinc->attributes, dprinc->kvno, - dprinc->mkvno, dprinc->policy); - } - free(modcanon); - ovsec_kadm_free_principal_ent(ovsec_hndl, dprinc); - free(canon); -} - -int kadmin_parse_policy_args(argc, argv, policy, mask, caller) - int argc; - char *argv[]; - ovsec_kadm_policy_ent_t policy; - u_int32 *mask; - char *caller; -{ - int i; - struct timeb now; - krb5_error_code retval; - - ftime(&now); - *mask = 0; - for (i = 1; i < argc - 1; i++) { - if (strlen(argv[i]) == 8 && - !strcmp(argv[i], "-maxlife")) { - if (++i > argc -2) - return -1; - else { - policy->pw_max_life = get_date(argv[i], now) - now.time; - *mask |= OVSEC_KADM_PW_MAX_LIFE; - continue; - } - } else if (strlen(argv[i]) == 8 && - !strcmp(argv[i], "-minlife")) { - if (++i > argc - 2) - return -1; - else { - policy->pw_min_life = get_date(argv[i], now) - now.time; - *mask |= OVSEC_KADM_PW_MIN_LIFE; - continue; - } - } else if (strlen(argv[i]) == 10 && - !strcmp(argv[i], "-minlength")) { - if (++i > argc - 2) - return -1; - else { - policy->pw_min_length = atoi(argv[i]); - *mask |= OVSEC_KADM_PW_MIN_LENGTH; - continue; - } - } else if (strlen(argv[i]) == 11 && - !strcmp(argv[i], "-minclasses")) { - if (++i > argc - 2) - return -1; - else { - policy->pw_min_classes = atoi(argv[i]); - *mask |= OVSEC_KADM_PW_MIN_CLASSES; - continue; - } - } else if (strlen(argv[i]) == 8 && - !strcmp(argv[i], "-history")) { - if (++i > argc - 2) - return -1; - else { - policy->pw_history_num = atoi(argv[i]); - *mask |= OVSEC_KADM_PW_HISTORY_NUM; - continue; - } - } else - return -1; - } - if (i != argc -1) { - fprintf(stderr, "%s: parser lost count!\n", caller); - return -1; - } else - return 0; -} - -void kadmin_addpol(argc, argv) - int argc; - char *argv[]; -{ - krb5_error_code retval; - u_int32 mask; - ovsec_kadm_policy_ent_rec policy; - - if (kadmin_parse_policy_args(argc, argv, &policy, &mask, "add_policy")) { - fprintf(stderr, "add_policy: bad arguments\n"); - return; - } else { - policy.policy = argv[argc - 1]; - mask |= OVSEC_KADM_POLICY; - retval = ovsec_kadm_create_policy(ovsec_hndl, &policy, mask); - if (retval) { - com_err("add_policy", retval, "while creating policy \"%s\".", - policy.policy); - return; - } - } - return; -} - -void kadmin_modpol(argc, argv) - int argc; - char *argv[]; -{ - krb5_error_code retval; - u_int32 mask; - ovsec_kadm_policy_ent_rec policy; - - if (kadmin_parse_policy_args(argc, argv, &policy, &mask, - "modify_policy")) { - fprintf(stderr, "modify_policy: bad arguments\n"); - return; - } else { - policy.policy = argv[argc - 1]; - retval = ovsec_kadm_modify_policy(ovsec_hndl, &policy, mask); - if (retval) { - com_err("modify_policy", retval, "while modifying policy \"%s\".", - policy.policy); - return; - } - } - return; -} - -void kadmin_delpol(argc, argv) - int argc; - char *argv[]; -{ - krb5_error_code retval; - char reply[5]; - - if (argc < 2 || argc > 3) { - fprintf(stderr, "delete_policy: wrong number of arguments\n"); - return; - } - if (argc == 3 && - (strlen(argv[1]) == 6 ? strcmp("-force", argv[1]) : 1)) { - fprintf(stderr, "delete_policy: bad arguments\n"); - return; - } - if (argc == 2) { - printf("Are you sure you want to delete the policy \"%s\"? (yes/no): ", argv[1]); - fgets(reply, sizeof (reply), stdin); - if (strcmp("yes\n", reply)) { - fprintf(stderr, "Policy \"%s\" not deleted.\n", argv[1]); - return; - } - } - retval = ovsec_kadm_delete_policy(ovsec_hndl, argv[argc - 1]); - if (retval) { - com_err("delete_policy:", retval, "while deleting policy \"%s\"", - argv[argc - 1]); - return; - } - return; -} - -void kadmin_getpol(argc, argv) - int argc; - char *argv[]; -{ - krb5_error_code retval; - ovsec_kadm_policy_ent_t policy; - - if (argc < 2 || argc > 3) { - fprintf(stderr, "get_policy: wrong number of arguments\n"); - return; - } - if (argc == 3 && - (strlen(argv[1]) == 6 ? strcmp("-terse", argv[1]) : 1)) { - fprintf(stderr, "get_policy: bad arguments\n"); - return; - } - retval = ovsec_kadm_get_policy(ovsec_hndl, argv[argc - 1], &policy); - if (retval) { - com_err("get_policy", retval, "while retrieving policy \"%s\".", - argv[argc - 1]); - return; - } - if (argc == 2) { - printf("Policy: %s\n", policy->policy); - printf("Maximum password life: %d\n", policy->pw_max_life); - printf("Minimum password life: %d\n", policy->pw_min_life); - printf("Minimum password length: %d\n", policy->pw_min_length); - printf("Minimum number of password character classes: %d\n", - policy->pw_min_classes); - printf("Number of old keys kept: %d\n", policy->pw_history_num); - printf("Reference count: %d\n", policy->policy_refcnt); - } else { - printf("\"%s\"\t%d\t%d\t%d\t%d\t%d\t%d\n", - policy->policy, policy->pw_max_life, policy->pw_min_life, - policy->pw_min_length, policy->pw_min_classes, - policy->pw_history_num, policy->policy_refcnt); - } - ovsec_kadm_free_policy_ent(ovsec_hndl, policy); - return; -} - -kadmin_getprivs(argc, argv) - int argc; - char *argv[]; -{ - static char *privs[] = {"GET", "ADD", "MODIFY", "DELETE"}; - krb5_error_code retval; - int i; - u_int32 plist; - - if (argc != 1) { - fprintf(stderr, "get_privs: bad arguments\n"); - return; - } - retval = ovsec_kadm_get_privs(ovsec_hndl, &plist); - if (retval) { - com_err("get_privs", retval, "while retrieving privileges"); - return; - } - printf("current privileges:"); - for (i = 0; i < sizeof (privs) / sizeof (char *); i++) { - if (plist & 1 << i) - printf(" %s", privs[i]); - } - printf("\n"); - return; -} diff --git a/src/kadmin/cli/attic/kadmin_ct.ct b/src/kadmin/cli/attic/kadmin_ct.ct deleted file mode 100644 index f5a67ed53..000000000 --- a/src/kadmin/cli/attic/kadmin_ct.ct +++ /dev/null @@ -1,67 +0,0 @@ -# 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_addprinc, "Add principal", - add_prinicpal, addprinc, ank; - -request kadmin_delprinc, "Delete principal", - delete_principal, delprinc; - -request kadmin_modprinc, "Modify principal", - modify_principal, modprinc; - -request kadmin_renprinc, "Rename principal", - rename_principal, renprinc; - -request kadmin_cpw, "Change password", - change_password, cpw; - -request kadmin_getprinc, "Get principal", - get_principal, getprinc; - -request kadmin_addpol, "Add policy", - add_policy, addpol; - -request kadmin_modpol, "Modify policy", - modify_policy, modpol; - -request kadmin_delpol, "Delete policy", - delete_policy, delpol; - -request kadmin_getpol, "Get policy", - get_policy, getpol; - -request kadmin_getprivs, "Get privileges", - get_privs, getprivs; - -# list_requests is generic -- unrelated to Kerberos -request ss_list_requests, "List available requests.", - list_requests, lr, "?"; - -request ss_quit, "Exit program.", - quit, exit, q; - -end; - diff --git a/src/kadmin/cli/attic/memmove.c b/src/kadmin/cli/attic/memmove.c deleted file mode 100644 index abc91e923..000000000 --- a/src/kadmin/cli/attic/memmove.c +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * 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. - */ - -#define MEMMOVE - -/* based on @(#)bcopy.c 5.11 (Berkeley) 6/21/91 */ - -#include -#include -#ifdef USE_STRING_H -#include -#else -#include -#endif - -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef int word; /* "word" used for optimal copy speed */ - -#define wsize sizeof(word) -#define wmask (wsize - 1) - -/* - * Copy a block of memory, handling overlap. - * This is the routine that actually implements - * (the portable versions of) bcopy, memcpy, and memmove. - */ -#ifdef MEMCOPY -void * -memcpy(dst0, src0, length) -#else -#ifdef MEMMOVE -void * -memmove(dst0, src0, length) -#else -void -bcopy(src0, dst0, length) -#endif -#endif - void *dst0; - const void *src0; - register size_t length; -{ - register char *dst = dst0; - register const char *src = src0; - register size_t t; - - if (length == 0 || dst == src) /* nothing to do */ - goto done; - - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) - - if ((unsigned long)dst < (unsigned long)src) { - /* - * Copy forward. - */ - t = (int)src; /* only need low bits */ - if ((t | (int)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (int)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); - } else { - /* - * Copy backwards. Otherwise essentially the same. - * Alignment works as before, except that it takes - * (t&wmask) bytes to align, not wsize-(t&wmask). - */ - src += length; - dst += length; - t = (int)src; - if ((t | (int)dst) & wmask) { - if ((t ^ (int)dst) & wmask || length <= wsize) - t = length; - else - t &= wmask; - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: -#if defined(MEMCOPY) || defined(MEMMOVE) - return (dst0); -#else - return; -#endif -} diff --git a/src/kadmin/cli/attic/setenv.c b/src/kadmin/cli/attic/setenv.c deleted file mode 100644 index a2432c3d6..000000000 --- a/src/kadmin/cli/attic/setenv.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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/cli/attic/ss_wrapper.c b/src/kadmin/cli/attic/ss_wrapper.c deleted file mode 100644 index f7bbda516..000000000 --- a/src/kadmin/cli/attic/ss_wrapper.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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; -} -- 2.26.2