From 50dfa596d3f83c7de5fde6b5e54b8a8b9484dcb6 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Fri, 9 Oct 1998 07:32:38 +0000 Subject: [PATCH] o move path in libutil.h to paths.h o make property_read() take a fd instead to avoid stdio.h mess o update auth to new interface. --- lib/libutil/auth.c | 12 +++++++----- lib/libutil/libutil.h | 4 ++-- lib/libutil/property.c | 5 ++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/libutil/auth.c b/lib/libutil/auth.c index 0894066cc119..05c3917a9531 100644 --- a/lib/libutil/auth.c +++ b/lib/libutil/auth.c @@ -32,9 +32,11 @@ * */ -#include +#include #include #include +#include +#include #include static properties P; @@ -42,15 +44,15 @@ static properties P; static int initauthconf(const char *path) { - FILE *fp; + int fd; if (!P) { - if ((fp = fopen(path, "r")) == NULL) { + if ((fd = open(path, O_RDONLY)) < 0) { syslog(LOG_ERR, "initauthconf: unable to open file: %s", path); return 1; } - P = properties_read(fp); - fclose(fp); + P = properties_read(fd); + close(fd); if (!P) { syslog(LOG_ERR, "initauthconf: unable to parse file: %s", path); return 1; diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index 7b8f3b3caf11..2aa2ad030a61 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -18,7 +18,7 @@ * 5. Modifications may be freely made to this file providing the above * conditions are met. * - * $Id: libutil.h,v 1.18 1998/10/08 23:10:41 jkh Exp $ + * $Id: libutil.h,v 1.19 1998/10/09 07:28:14 jkh Exp $ */ #ifndef _LIBUTIL_H_ @@ -54,7 +54,7 @@ int uu_lock __P((const char *_ttyname)); int uu_unlock __P((const char *_ttyname)); int uu_lock_txfr __P((const char *_ttyname, pid_t _pid)); int _secure_path __P((const char *_path, uid_t _uid, gid_t _gid)); -properties properties_read __P((FILE *fp)); +properties properties_read __P((int fd)); void properties_free __P((properties list)); char *property_find __P((properties list, const char *name)); char *auth_getval __P((const char *name)); diff --git a/lib/libutil/property.c b/lib/libutil/property.c index 3de550b12679..d7c93d7fc5df 100644 --- a/lib/libutil/property.c +++ b/lib/libutil/property.c @@ -53,7 +53,7 @@ property_alloc(char *name, char *value) } properties -properties_read(FILE *fp) +properties_read(int fd) { properties head, ptr; char hold_n[MAX_NAME + 1]; @@ -75,7 +75,7 @@ properties_read(FILE *fp) } switch(state) { case FILL: - if ((max = fread(buf, 1, sizeof buf, fp)) <= 0) { + if ((max = read(fd, buf, sizeof buf)) <= 0) { state = STOP; break; } @@ -214,4 +214,3 @@ properties_free(properties list) list = tmp; } } -