summaryrefslogtreecommitdiff
path: root/crypto/kerberosIV/lib/acl
diff options
context:
space:
mode:
authorMark Murray <markm@FreeBSD.org>1999-09-19 14:19:32 +0000
committerMark Murray <markm@FreeBSD.org>1999-09-19 14:19:32 +0000
commitf4c5d10e699c47c4d903bcf9f8486ecea140ef8f (patch)
tree36ce70fe2e8419130e546c38a7790e8ab224a362 /crypto/kerberosIV/lib/acl
parent03656ac1b015e707cea8379d6dab400f41a2dd86 (diff)
Notes
Diffstat (limited to 'crypto/kerberosIV/lib/acl')
-rw-r--r--crypto/kerberosIV/lib/acl/Makefile.in32
-rw-r--r--crypto/kerberosIV/lib/acl/acl.h4
-rw-r--r--crypto/kerberosIV/lib/acl/acl_files.c100
3 files changed, 53 insertions, 83 deletions
diff --git a/crypto/kerberosIV/lib/acl/Makefile.in b/crypto/kerberosIV/lib/acl/Makefile.in
index 59894e488c07..2a781901cd2d 100644
--- a/crypto/kerberosIV/lib/acl/Makefile.in
+++ b/crypto/kerberosIV/lib/acl/Makefile.in
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.in,v 1.21 1997/05/06 03:46:37 assar Exp $
+# $Id: Makefile.in,v 1.29 1999/03/10 19:01:14 joda Exp $
#
SHELL = /bin/sh
@@ -8,10 +8,13 @@ srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
+LINK = @LINK@
AR = ar
+LN_S = @LN_S@
RANLIB = @RANLIB@
-DEFS = @DEFS@
-CFLAGS = @CFLAGS@
+DEFS = @DEFS@ -DROKEN_RENAME
+CFLAGS = @CFLAGS@ $(WFLAGS)
+WFLAGS = @WFLAGS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
@@ -41,14 +44,14 @@ Wall:
make CFLAGS="-g -Wall -Wno-comment -Wmissing-prototypes -Wmissing-declarations -D__USE_FIXED_PROTOTYPES__"
.c.o:
- $(CC) -c $(CPPFLAGS) $(DEFS) -I../../include -I$(srcdir) $(CFLAGS) $(PICFLAGS) $<
+ $(CC) -c $(DEFS) -I../../include -I$(srcdir) -I. $(CFLAGS) $(PICFLAGS) $(CPPFLAGS) $<
install: all
- $(MKINSTALLDIRS) $(libdir)
- $(INSTALL_DATA) -m 0555 $(LIB) $(libdir)
+ $(MKINSTALLDIRS) $(DESTDIR)$(libdir)
+ $(INSTALL_DATA) -m 0555 $(LIB) $(DESTDIR)$(libdir)/$(LIB)
uninstall:
- rm -f $(libdir)/$(LIB)
+ rm -f $(DESTDIR)$(libdir)/$(LIB)
TAGS: $(SOURCES)
etags $(SOURCES)
@@ -61,17 +64,11 @@ clean:
mostlyclean: clean
distclean: clean
- rm -f Makefile *.tab.c *~
+ rm -f Makefile *.tab.c *~ roken_rename.h
realclean: distclean
rm -f TAGS
-dist: $(DISTFILES)
- for file in $(DISTFILES); do \
- ln $$file ../`cat ../.fname`/lib \
- || cp -p $$file ../`cat ../.fname`/lib; \
- done
-
$(LIBNAME).a: $(OBJECTS)
rm -f $@
$(AR) cr $@ $(OBJECTS)
@@ -81,4 +78,9 @@ $(LIBNAME).$(SHLIBEXT): $(OBJECTS)
rm -f $@
$(LDSHARED) -o $@ $(OBJECTS)
-$(OBJECTS): ../../include/config.h
+$(OBJECTS): ../../include/config.h roken_rename.h
+
+roken_rename.h:
+ $(LN_S) $(srcdir)/../krb/roken_rename.h .
+
+.PHONY: all Wall install uninstall check clean mostlyclean distclean realclean
diff --git a/crypto/kerberosIV/lib/acl/acl.h b/crypto/kerberosIV/lib/acl/acl.h
index 305b66c9db2a..0a6fa569cf49 100644
--- a/crypto/kerberosIV/lib/acl/acl.h
+++ b/crypto/kerberosIV/lib/acl/acl.h
@@ -36,13 +36,11 @@
* SUCH DAMAGE.
*/
-/* $Id: acl.h,v 1.5 1997/04/01 08:17:52 joda Exp $ */
+/* $Id: acl.h,v 1.6 1997/12/05 03:31:47 joda Exp $ */
#ifndef __ACL_H
#define __ACL_H
-#include <sys/cdefs.h>
-
void acl_canonicalize_principal __P((char *principal, char *canon));
int acl_initialize __P((char *acl_file, int perm));
int acl_exact_match __P((char *acl, char *principal));
diff --git a/crypto/kerberosIV/lib/acl/acl_files.c b/crypto/kerberosIV/lib/acl/acl_files.c
index fc00b8016be0..12098b7ebbd5 100644
--- a/crypto/kerberosIV/lib/acl/acl_files.c
+++ b/crypto/kerberosIV/lib/acl/acl_files.c
@@ -22,7 +22,7 @@ or implied warranty.
#include "config.h"
#include "protos.h"
-RCSID("$Id: acl_files.c,v 1.10 1997/05/02 14:28:56 assar Exp $");
+RCSID("$Id: acl_files.c,v 1.13 1999/03/13 21:21:32 assar Exp $");
#include <stdio.h>
#include <stdlib.h>
@@ -71,67 +71,28 @@ RCSID("$Id: acl_files.c,v 1.10 1997/05/02 14:28:56 assar Exp $");
#define COR(a,b) ((a!=NULL)?(a):(b))
-/* Canonicalize a principal name */
-/* If instance is missing, it becomes "" */
-/* If realm is missing, it becomes the local realm */
-/* Canonicalized form is put in canon, which must be big enough to hold
- MAX_PRINCIPAL_SIZE characters */
+/*
+ * Canonicalize a principal name.
+ * If instance is missing, it becomes ""
+ * If realm is missing, it becomes the local realm
+ * Canonicalized form is put in canon, which must be big enough to
+ * hold MAX_PRINCIPAL_SIZE characters
+ *
+ */
+
void
acl_canonicalize_principal(char *principal, char *canon)
{
- char *dot, *atsign, *end;
- int len;
-
- dot = strchr(principal, INST_SEP);
- atsign = strchr(principal, REALM_SEP);
-
- /* Maybe we're done already */
- if(dot != NULL && atsign != NULL) {
- if(dot < atsign) {
- /* It's for real */
- /* Copy into canon */
- strncpy(canon, principal, MAX_PRINCIPAL_SIZE);
- canon[MAX_PRINCIPAL_SIZE-1] = '\0';
- return;
- } else {
- /* Nope, it's part of the realm */
- dot = NULL;
- }
- }
-
- /* No such luck */
- end = principal + strlen(principal);
-
- /* Get the principal name */
- len = min(ANAME_SZ, COR(dot, COR(atsign, end)) - principal);
- strncpy(canon, principal, len);
- canon += len;
-
- /* Add INST_SEP */
- *canon++ = INST_SEP;
-
- /* Get the instance, if it exists */
- if(dot != NULL) {
- ++dot;
- len = min(INST_SZ, COR(atsign, end) - dot);
- strncpy(canon, dot, len);
- canon += len;
- }
-
- /* Add REALM_SEP */
- *canon++ = REALM_SEP;
-
- /* Get the realm, if it exists */
- /* Otherwise, default to local realm */
- if(atsign != NULL) {
- ++atsign;
- len = min(REALM_SZ, end - atsign);
- strncpy(canon, atsign, len);
- canon += len;
- *canon++ = '\0';
- } else if(krb_get_lrealm(canon, 1) != KSUCCESS) {
- strcpy(canon, KRB_REALM);
+ krb_principal princ;
+ int ret;
+ ret = krb_parse_name(principal, &princ);
+ if(ret) { /* ? */
+ *canon = '\0';
+ return;
}
+ if(princ.realm[0] == '\0')
+ krb_get_lrealm(princ.realm, 1);
+ krb_unparse_name_r(&princ, canon);
}
/* Get a lock to modify acl_file */
@@ -256,12 +217,13 @@ acl_initialize(char *acl_file, int perm)
/* Eliminate all whitespace character in buf */
/* Modifies its argument */
static void
- nuke_whitespace(char *buf)
+nuke_whitespace(char *buf)
{
- char *pin, *pout;
+ unsigned char *pin, *pout;
- for(pin = pout = buf; *pin != '\0'; pin++)
- if(!isspace(*pin)) *pout++ = *pin;
+ for(pin = pout = (unsigned char *)buf; *pin != '\0'; pin++)
+ if(!isspace(*pin))
+ *pout++ = *pin;
*pout = '\0'; /* Terminate the string */
}
@@ -281,9 +243,15 @@ make_hash(int size)
if(size < 1) size = 1;
h = (struct hashtbl *) malloc(sizeof(struct hashtbl));
+ if (h == NULL)
+ return NULL;
h->size = size;
h->entries = 0;
h->tbl = (char **) calloc(size, sizeof(char *));
+ if (h->tbl == NULL) {
+ free (h);
+ return NULL;
+ }
return(h);
}
@@ -339,8 +307,10 @@ add_hash(struct hashtbl *h, char *el)
hv = hashval(el) % h->size;
while(h->tbl[hv] != NULL && strcmp(h->tbl[hv], el)) hv = (hv+1) % h->size;
s = strdup(el);
- h->tbl[hv] = s;
- h->entries++;
+ if (s != NULL) {
+ h->tbl[hv] = s;
+ h->entries++;
+ }
}
/* Returns nonzero if el is in h */
@@ -403,7 +373,7 @@ acl_load(char *name)
}
/* Set up the acl */
- strcpy(acl_cache[i].filename, name);
+ strcpy_truncate(acl_cache[i].filename, name, LINESIZE);
if((acl_cache[i].fd = open(name, O_RDONLY, 0)) < 0) return(-1);
/* Force reload */
acl_cache[i].acl = (struct hashtbl *) 0;