diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-05 10:17:08 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-05 10:17:08 +0000 |
commit | 7d219aab70e6951ab82c27c202cac05016696723 (patch) | |
tree | 4c0679bfa391f71aee9b51505a5d3dc8f60a0cf7 /libpwdgrp | |
parent | 8f8f268cfdecb4cabeb2e649a73afc7a485aeff5 (diff) | |
download | busybox-7d219aab70e6951ab82c27c202cac05016696723.tar.gz |
build system overhaul
Diffstat (limited to 'libpwdgrp')
-rw-r--r-- | libpwdgrp/Kbuild | 7 | ||||
-rw-r--r-- | libpwdgrp/Makefile | 23 | ||||
-rw-r--r-- | libpwdgrp/Makefile.in | 51 | ||||
-rw-r--r-- | libpwdgrp/pwd_grp.c | 131 | ||||
-rw-r--r-- | libpwdgrp/pwd_grp_internal.c | 87 |
5 files changed, 31 insertions, 268 deletions
diff --git a/libpwdgrp/Kbuild b/libpwdgrp/Kbuild new file mode 100644 index 000000000..36a6ce393 --- /dev/null +++ b/libpwdgrp/Kbuild @@ -0,0 +1,7 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> +# +# Licensed under the GPL v2, see the file LICENSE in this tarball. + +lib-y:=pwd_grp.o diff --git a/libpwdgrp/Makefile b/libpwdgrp/Makefile deleted file mode 100644 index 630a7688f..000000000 --- a/libpwdgrp/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# Makefile for busybox -# -# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> -# -# Licensed under the GPL v2, see the file LICENSE in this tarball. - -ifndef top_srcdir -top_srcdir=.. -endif -ifndef top_builddir -top_builddir=.. -endif -srcdir=$(top_srcdir)/libpwgrp -LIBPWDGRP_DIR:=./ -include $(top_srcdir)/Rules.mak -include $(top_builddir)/.config -include Makefile.in -all: $(libraries-y) --include $(top_builddir)/.depend - -clean: - rm -f *.o *.a $(AR_TARGET) - diff --git a/libpwdgrp/Makefile.in b/libpwdgrp/Makefile.in deleted file mode 100644 index 2511d34ef..000000000 --- a/libpwdgrp/Makefile.in +++ /dev/null @@ -1,51 +0,0 @@ -# Makefile for busybox -# -# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> -# -# Licensed under the GPL v2, see the file LICENSE in this tarball. - -LIBPWDGRP_AR:=libpwdgrp.a -ifndef $(LIBPWDGRP_DIR) -LIBPWDGRP_DIR:=$(top_builddir)/libpwdgrp -endif -srcdir=$(top_srcdir)/libpwdgrp - -LIBPWDGRP-obj:=$(LIBPWDGRP_DIR)/$(LIBPWDGRP_AR) - -libraries-y+=$(LIBPWDGRP_DIR)/$(LIBPWDGRP_AR) - -LIBPWDGRP_MSRC0:=$(srcdir)/pwd_grp.c -LIBPWDGRP_MOBJ0-$(CONFIG_USE_BB_PWD_GRP):= fgetpwent_r.o fgetgrent_r.o \ - fgetpwent.o fgetgrent.o getpwnam_r.o getgrnam_r.o getpwuid_r.o \ - getgrgid_r.o getpwuid.o getgrgid.o getpwnam.o getgrnam.o getpw.o \ - getpwent_r.o getgrent_r.o getpwent.o getgrent.o \ - initgroups.o putpwent.o putgrent.o -LIBPWDGRP_MOBJS0=$(patsubst %,$(LIBPWDGRP_DIR)/%, $(LIBPWDGRP_MOBJ0-y)) - -LIBPWDGRP_MSRC1:=$(srcdir)/pwd_grp.c -LIBPWDGRP_MOBJ1-$(CONFIG_USE_BB_PWD_GRP):= __parsepwent.o __parsegrent.o \ - __pgsreader.o fgetspent_r.o fgetspent.o sgetspent_r.o getspnam_r.o \ - getspnam.o getspent_r.o getspent.o sgetspent.o \ - putspent.o __parsespent.o # getspuid_r.o getspuid.o -LIBPWDGRP_MOBJS1=$(patsubst %,$(LIBPWDGRP_DIR)/%, $(LIBPWDGRP_MOBJ1-y)) - -LIBPWDGRP_DEFINE0-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBPWDGRP_MOBJS0)))) -LIBPWDGRP_DEFINE1-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBPWDGRP_MOBJS1)))) - -LIBPWDGRP_SRC-y:=$(LIBPWDGRP_MSRC0) - -LIBRARY_SRC-y+=$(LIBPWDGRP_SRC-y) -LIBRARY_SRC-a+=$(LIBPWDGRP_SRC-y) - -LIBRARY_DEFINE-y+=$(LIBPWDGRP_DEFINE0-y) $(LIBPWDGRP_DEFINE1-y) -LIBRARY_DEFINE-a+=$(LIBPWDGRP_DEFINE0-y) $(LIBPWDGRP_DEFINE1-y) - - -$(LIBPWDGRP_DIR)/$(LIBPWDGRP_AR): $(LIBPWDGRP_MOBJS0) $(LIBPWDGRP_MOBJS1) - $(do_ar) - -$(LIBPWDGRP_MOBJS0): $(LIBPWDGRP_MSRC0) - $(compile.c) -DL_$(notdir $*) - -$(LIBPWDGRP_MOBJS1): $(LIBPWDGRP_MSRC1) - $(compile.c) -DL_$(notdir $*) diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index 132ec60be..ac65d4c5b 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c @@ -29,8 +29,6 @@ #include <assert.h> #include <ctype.h> -#include "shadow_.h" - #ifndef _PATH_SHADOW #define _PATH_SHADOW "/etc/shadow" #endif @@ -57,7 +55,7 @@ extern int __parsegrent(void *gr, char *line); extern int __parsespent(void *sp, char *line); extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, - char *__restrict line_buff, size_t buflen, FILE *f); + char *__restrict line_buff, size_t buflen, FILE *f); /**********************************************************************/ /* For the various fget??ent_r funcs, return @@ -75,8 +73,6 @@ extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, */ /**********************************************************************/ -#ifdef L_fgetpwent_r - int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf, char *__restrict buffer, size_t buflen, struct passwd **__restrict result) @@ -92,10 +88,6 @@ int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf, return rv; } -#endif -/**********************************************************************/ -#ifdef L_fgetgrent_r - int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf, char *__restrict buffer, size_t buflen, struct group **__restrict result) @@ -111,10 +103,6 @@ int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf, return rv; } -#endif -/**********************************************************************/ -#ifdef L_fgetspent_r - int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf, char *__restrict buffer, size_t buflen, struct spwd **__restrict result) @@ -130,13 +118,11 @@ int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf, return rv; } -#endif /**********************************************************************/ /* For the various fget??ent funcs, return NULL on failure and a * pointer to the appropriate struct (statically allocated) on success. */ /**********************************************************************/ -#ifdef L_fgetpwent struct passwd *fgetpwent(FILE *stream) { @@ -148,10 +134,6 @@ struct passwd *fgetpwent(FILE *stream) return result; } -#endif -/**********************************************************************/ -#ifdef L_fgetgrent - struct group *fgetgrent(FILE *stream) { static char buffer[GRP_BUFFER_SIZE]; @@ -162,10 +144,6 @@ struct group *fgetgrent(FILE *stream) return result; } -#endif -/**********************************************************************/ -#ifdef L_fgetspent - extern int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf, char *__restrict buffer, size_t buflen, struct spwd **__restrict result); @@ -179,10 +157,6 @@ struct spwd *fgetspent(FILE *stream) return result; } -#endif -/**********************************************************************/ -#ifdef L_sgetspent_r - int sgetspent_r(const char *string, struct spwd *result_buf, char *buffer, size_t buflen, struct spwd **result) { @@ -211,65 +185,53 @@ int sgetspent_r(const char *string, struct spwd *result_buf, return rv; } -#endif /**********************************************************************/ #ifdef GETXXKEY_R_FUNC #error GETXXKEY_R_FUNC is already defined! #endif -#ifdef L_getpwnam_r -#define GETXXKEY_R_FUNC getpwnam_r +#define GETXXKEY_R_FUNC getpwnam_R #define GETXXKEY_R_PARSER __parsepwent #define GETXXKEY_R_ENTTYPE struct passwd #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key)) #define DO_GETXXKEY_R_KEYTYPE const char *__restrict #define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD #include "pwd_grp_internal.c" -#endif -#ifdef L_getgrnam_r -#define GETXXKEY_R_FUNC getgrnam_r +#define GETXXKEY_R_FUNC getgrnam_R #define GETXXKEY_R_PARSER __parsegrent #define GETXXKEY_R_ENTTYPE struct group #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key)) #define DO_GETXXKEY_R_KEYTYPE const char *__restrict #define DO_GETXXKEY_R_PATHNAME _PATH_GROUP #include "pwd_grp_internal.c" -#endif -#ifdef L_getspnam_r -#define GETXXKEY_R_FUNC getspnam_r +#define GETXXKEY_R_FUNC getspnam_R #define GETXXKEY_R_PARSER __parsespent #define GETXXKEY_R_ENTTYPE struct spwd #define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key)) #define DO_GETXXKEY_R_KEYTYPE const char *__restrict #define DO_GETXXKEY_R_PATHNAME _PATH_SHADOW #include "pwd_grp_internal.c" -#endif -#ifdef L_getpwuid_r -#define GETXXKEY_R_FUNC getpwuid_r +#define GETXXKEY_R_FUNC getpwuid_R #define GETXXKEY_R_PARSER __parsepwent #define GETXXKEY_R_ENTTYPE struct passwd #define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key) #define DO_GETXXKEY_R_KEYTYPE uid_t #define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD #include "pwd_grp_internal.c" -#endif -#ifdef L_getgrgid_r -#define GETXXKEY_R_FUNC getgrgid_r +#define GETXXKEY_R_FUNC getgrgid_R #define GETXXKEY_R_PARSER __parsegrent #define GETXXKEY_R_ENTTYPE struct group #define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key) #define DO_GETXXKEY_R_KEYTYPE gid_t #define DO_GETXXKEY_R_PATHNAME _PATH_GROUP #include "pwd_grp_internal.c" -#endif /**********************************************************************/ -#ifdef L_getpwuid struct passwd *getpwuid(uid_t uid) { @@ -281,10 +243,6 @@ struct passwd *getpwuid(uid_t uid) return result; } -#endif -/**********************************************************************/ -#ifdef L_getgrgid - struct group *getgrgid(gid_t gid) { static char buffer[GRP_BUFFER_SIZE]; @@ -295,10 +253,6 @@ struct group *getgrgid(gid_t gid) return result; } -#endif -/**********************************************************************/ -#ifdef L_getspuid_r - /* This function is non-standard and is currently not built. It seems * to have been created as a reentrant version of the non-standard * functions getspuid. Why getspuid was added, I do not know. */ @@ -320,10 +274,6 @@ int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf, return rv; } -#endif -/**********************************************************************/ -#ifdef L_getspuid - /* This function is non-standard and is currently not built. * Why it was added, I do not know. */ @@ -337,10 +287,6 @@ struct spwd *getspuid(uid_t uid) return result; } -#endif -/**********************************************************************/ -#ifdef L_getpwnam - struct passwd *getpwnam(const char *name) { static char buffer[PWD_BUFFER_SIZE]; @@ -351,10 +297,6 @@ struct passwd *getpwnam(const char *name) return result; } -#endif -/**********************************************************************/ -#ifdef L_getgrnam - struct group *getgrnam(const char *name) { static char buffer[GRP_BUFFER_SIZE]; @@ -365,10 +307,6 @@ struct group *getgrnam(const char *name) return result; } -#endif -/**********************************************************************/ -#ifdef L_getspnam - struct spwd *getspnam(const char *name) { static char buffer[PWD_BUFFER_SIZE]; @@ -379,10 +317,6 @@ struct spwd *getspnam(const char *name) return result; } -#endif -/**********************************************************************/ -#ifdef L_getpw - int getpw(uid_t uid, char *buf) { struct passwd resultbuf; @@ -406,10 +340,8 @@ int getpw(uid_t uid, char *buf) return -1; } -#endif /**********************************************************************/ -#if defined(L_getpwent_r) || defined(L_getgrent_r) || defined(L_getspent_r) #if defined CONFIG_USE_BB_THREADSAFE_SHADOW && defined PTHREAD_MUTEX_INITIALIZER static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; # define LOCK pthread_mutex_lock(&mylock) @@ -418,9 +350,7 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; # define LOCK ((void) 0) # define UNLOCK ((void) 0) #endif -#endif -#ifdef L_getpwent_r static FILE *pwf /*= NULL*/; void setpwent(void) { @@ -468,10 +398,6 @@ int getpwent_r(struct passwd *__restrict resultbuf, return rv; } -#endif -/**********************************************************************/ -#ifdef L_getgrent_r - static FILE *grf /*= NULL*/; void setgrent(void) { @@ -518,10 +444,6 @@ int getgrent_r(struct group *__restrict resultbuf, return rv; } -#endif -/**********************************************************************/ -#ifdef L_getspent_r - static FILE *spf /*= NULL*/; void setspent(void) { @@ -567,10 +489,6 @@ int getspent_r(struct spwd *resultbuf, char *buffer, return rv; } -#endif -/**********************************************************************/ -#ifdef L_getpwent - struct passwd *getpwent(void) { static char line_buff[PWD_BUFFER_SIZE]; @@ -581,10 +499,6 @@ struct passwd *getpwent(void) return result; } -#endif -/**********************************************************************/ -#ifdef L_getgrent - struct group *getgrent(void) { static char line_buff[GRP_BUFFER_SIZE]; @@ -595,10 +509,6 @@ struct group *getgrent(void) return result; } -#endif -/**********************************************************************/ -#ifdef L_getspent - struct spwd *getspent(void) { static char line_buff[PWD_BUFFER_SIZE]; @@ -609,10 +519,6 @@ struct spwd *getspent(void) return result; } -#endif -/**********************************************************************/ -#ifdef L_sgetspent - struct spwd *sgetspent(const char *string) { static char line_buff[PWD_BUFFER_SIZE]; @@ -623,10 +529,6 @@ struct spwd *sgetspent(const char *string) return result; } -#endif -/**********************************************************************/ -#ifdef L_initgroups - int initgroups(const char *user, gid_t gid) { FILE *grfile; @@ -679,10 +581,6 @@ int initgroups(const char *user, gid_t gid) return rv; } -#endif -/**********************************************************************/ -#ifdef L_putpwent - int putpwent(const struct passwd *__restrict p, FILE *__restrict f) { int rv = -1; @@ -704,10 +602,6 @@ int putpwent(const struct passwd *__restrict p, FILE *__restrict f) return rv; } -#endif -/**********************************************************************/ -#ifdef L_putgrent - int putgrent(const struct group *__restrict p, FILE *__restrict f) { static const char format[] = ",%s"; @@ -749,10 +643,6 @@ int putgrent(const struct group *__restrict p, FILE *__restrict f) return rv; } -#endif -/**********************************************************************/ -#ifdef L_putspent - static const unsigned char _sp_off[] = { offsetof(struct spwd, sp_lstchg), /* 2 - not a char ptr */ offsetof(struct spwd, sp_min), /* 3 - not a char ptr */ @@ -799,11 +689,9 @@ DO_UNLOCK: return rv; } -#endif /**********************************************************************/ /* Internal uClibc functions. */ /**********************************************************************/ -#ifdef L___parsepwent static const unsigned char pw_off[] = { offsetof(struct passwd, pw_name), /* 0 */ @@ -860,9 +748,7 @@ int __parsepwent(void *data, char *line) return -1; } -#endif /**********************************************************************/ -#ifdef L___parsegrent static const unsigned char gr_off[] = { offsetof(struct group, gr_name), /* 0 */ @@ -958,9 +844,7 @@ int __parsegrent(void *data, char *line) return -1; } -#endif /**********************************************************************/ -#ifdef L___parsespent static const unsigned char sp_off[] = { offsetof(struct spwd, sp_namp), /* 0 */ @@ -1017,9 +901,7 @@ int __parsespent(void *data, char * line) return EINVAL; } -#endif /**********************************************************************/ -#ifdef L___pgsreader /* Reads until if EOF, or until if finds a line which fits in the buffer * and for which the parser function succeeds. @@ -1084,5 +966,4 @@ int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, return rv; } -#endif /**********************************************************************/ diff --git a/libpwdgrp/pwd_grp_internal.c b/libpwdgrp/pwd_grp_internal.c index 39c11f677..866ed3699 100644 --- a/libpwdgrp/pwd_grp_internal.c +++ b/libpwdgrp/pwd_grp_internal.c @@ -18,96 +18,45 @@ * */ -#include <features.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string.h> -#include <stddef.h> -#include <errno.h> -#include <assert.h> -#include <ctype.h> - -#include "pwd_.h" -#include "grp_.h" -#include "shadow_.h" -#include "libbb.h" - -#ifndef _PATH_SHADOW -#define _PATH_SHADOW "/etc/shadow" -#endif -#ifndef _PATH_PASSWD -#define _PATH_PASSWD "/etc/passwd" -#endif -#ifndef _PATH_GROUP -#define _PATH_GROUP "/etc/group" -#endif - -/**********************************************************************/ -/* Sizes for statically allocated buffers. */ - -/* If you change these values, also change _SC_GETPW_R_SIZE_MAX and - * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */ -#define PWD_BUFFER_SIZE 256 -#define GRP_BUFFER_SIZE 256 - -/**********************************************************************/ -/* Prototypes for internal functions. */ - -extern int __parsepwent(void *pw, char *line); -extern int __parsegrent(void *gr, char *line); -extern int __parsespent(void *sp, char *line); - -extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, - char *__restrict line_buff, size_t buflen, FILE *f); - - #ifndef GETXXKEY_R_FUNC #error GETXXKEY_R_FUNC is not defined! #endif -/**********************************************************************/ -#ifdef GETXXKEY_R_FUNC int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key, - GETXXKEY_R_ENTTYPE *__restrict resultbuf, - char *__restrict buffer, size_t buflen, - GETXXKEY_R_ENTTYPE **__restrict result) + GETXXKEY_R_ENTTYPE *__restrict resultbuf, + char *__restrict buffer, size_t buflen, + GETXXKEY_R_ENTTYPE **__restrict result) { FILE *stream; int rv; *result = NULL; - if (!(stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"))) { - rv = errno; - } else { - do { - if (!(rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf, - buffer, buflen, stream)) - ) { - if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */ - *result = resultbuf; - break; - } - } else { - if (rv == ENOENT) { /* end-of-file encountered. */ - rv = 0; - } + stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"); + if (!stream) + return errno; + while (1) { + rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf, buffer, buflen, stream); + if (!rv) { + if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */ + *result = resultbuf; break; } - } while (1); - fclose(stream); + } else { + if (rv == ENOENT) { /* end-of-file encountered. */ + rv = 0; + } + break; + } } + fclose(stream); return rv; } -#endif -/**********************************************************************/ #undef GETXXKEY_R_FUNC #undef GETXXKEY_R_PARSER #undef GETXXKEY_R_ENTTYPE #undef GETXXKEY_R_TEST #undef DO_GETXXKEY_R_KEYTYPE #undef DO_GETXXKEY_R_PATHNAME - |