From 4a9a7addbc23be8e7db385697678f53a9d0b96a1 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 18 May 2015 14:38:08 +0100 Subject: mingw: provide fake getgroups and getgrouplist This makes it possible to enable the id and groups applets, though the results they return are worthless. --- README.md | 1 + configs/mingw32_defconfig | 6 +++--- include/mingw.h | 3 ++- win32/mingw.c | 22 ++++++++++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 77e6bad73..d4140487c 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,4 @@ Then just `make`. - Don't do wild things with Windows drive or UNC notation. - tar doesn't support seamless compression/decompression: use a pipeline to a compressor/decompressor. - Wildcard expansion is disabled by default, though it can be turned on at compile time. This only affects command line arguments to the binary: the BusyBox shell has full support for wildcards. + - Handling of users, groups and permissions is totally bogus. The system only admits to knowing about the current user and always returns the same hardcoded uid, gid and permission values. diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index bb652f05f..6804752f2 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.24.0.git -# Mon May 18 10:01:53 2015 +# Mon May 18 14:31:53 2015 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -193,8 +193,8 @@ CONFIG_DD=y CONFIG_FEATURE_DD_IBS_OBS=y CONFIG_FEATURE_DD_STATUS=y # CONFIG_HOSTID is not set -# CONFIG_ID is not set -# CONFIG_GROUPS is not set +CONFIG_ID=y +CONFIG_GROUPS=y CONFIG_SHUF=y CONFIG_TEST=y CONFIG_FEATURE_TEST_64=y diff --git a/include/mingw.h b/include/mingw.h index f3b260f5a..84522f032 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -48,6 +48,7 @@ IMPL(getgrnam,struct group *,NULL,const char *name UNUSED_PARAM); struct group *getgrgid(gid_t gid); NOIMPL(initgroups,const char *group UNUSED_PARAM,gid_t gid UNUSED_PARAM); static inline void endgrent(void) {} +int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups); /* * limits.h @@ -380,7 +381,7 @@ char *mingw_getcwd(char *pointer, int len); IMPL(getgid,int,DEFAULT_GID,void); -NOIMPL(getgroups,int n UNUSED_PARAM,gid_t *groups UNUSED_PARAM); +int getgroups(int n, gid_t *groups); IMPL(getppid,int,1,void); IMPL(getegid,int,DEFAULT_GID,void); IMPL(geteuid,int,DEFAULT_UID,void); diff --git a/win32/mingw.c b/win32/mingw.c index 5847e0fa0..bb08647a6 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -648,6 +648,28 @@ struct group *getgrgid(gid_t gid UNUSED_PARAM) return &g; } +int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups) +{ + if ( *ngroups == 0 ) { + *ngroups = 1; + return -1; + } + + *ngroups = 1; + groups[0] = DEFAULT_GID; + return 1; +} + +int getgroups(int n, gid_t *groups) +{ + if ( n == 0 ) { + return 1; + } + + groups[0] = DEFAULT_GID; + return 1; +} + int getlogin_r(char *buf, size_t len) { char *name; -- cgit v1.2.3-55-g6feb