On Fri, Sep 26, 2008 at 6:53 AM, Mike Frysinger <[EMAIL PROTECTED]> wrote:
>> >> Maybe frame setgroups decl in #ifdef DARWIN thingy?
>> >
>> > ugh, no ... this is a failing of busybox.  it is purposefully not pulling
>> > in grp.h and thus not getting the setgroups() prototype when the internal
>> > pwd/grp stuff is enabled.  if you want to continue the "ignore it" route,
>>
>> I don't understand you. setgroups is orthogonal to most of other grp.h
>> things in a sense that it is not tied to the method of storage for
>> user/group database. It is used to tell kernel what group vector
>> is in effect. It makes sense to have private implementation of
>> user/group database (libpwdgrp) yet still use setgroups() from libc.
>
> i'm not making any statements about what is/isnt appropriate for internal
> implementation.  i'm stating that guessing at a C library prototype is wrong.
> the standards we work with dictate what the API must provide.  they allow
> crazy stuff to happen at the ABI level.  i hit this recently where a system
> header actually redirected a function call to a different ABI symbol
> altogether via an asm() directive while still providing the required API.
>
>> > then the prototype should be limited to that ifdef logic (i dont use the
>> > bb pwd/grp replacement code so i wouldnt notice it failing in that case).
>> >
>> > of course, if the build/host include paths werent so intertwined, it
>> > wouldnt be nearely as much of a problem ... we have to make sure libbb.h
>> > is "portable" because it gets pulled in by the applet generation code
>> > (applets/usage.c).  sticking random system prototypes into libbb.h makes
>> > this very fragile.
>>
>> Yes, just declaring setgroups() there like it is done now
>> is not a correct way. Better ideas?
>
> there isnt much in the way of clean solutions when we're talking about
> half-replacing sub sections of a C library.

Please try attached patch.

> one option might be to use #define's to "hide" the function prototypes that
> busybox provides an internal replacement for.
> #if ENABLE_USE_BB_PWD_GRP
> # define putspent HIDE_PROTOTYPE_putspent
> ...
> #endif
> #include <grp.h>
> #if ENABLE_USE_BB_PWD_GRP
> # undef putspent
> #endif

This was already done by pwd_.h etc. It just required a tiny tweak
(removal of struct definition) to allow it to coexist peacefully
with pwd.h #included before it.
--
vda
diff -d -urpN busybox.3/include/grp_.h busybox.4/include/grp_.h
--- busybox.3/include/grp_.h	2008-09-25 12:22:15.000000000 +0200
+++ busybox.4/include/grp_.h	2008-09-26 11:51:44.000000000 +0200
@@ -21,22 +21,13 @@
  *	POSIX Standard: 9.2.1 Group Database Access	<grp.h>
  */
 
-#ifndef	_GRP_H
-#define	_GRP_H 1
+#ifndef	BB_GRP_H
+#define	BB_GRP_H 1
 
 #if __GNUC_PREREQ(4,1)
 # pragma GCC visibility push(hidden)
 #endif
 
-/* The group structure.	 */
-struct group {
-	char *gr_name;          /* Group name.  */
-	char *gr_passwd;        /* Password.    */
-	gid_t gr_gid;           /* Group ID.    */
-	char **gr_mem;          /* Member list. */
-};
-
-
 #define setgrent     bb_internal_setgrent
 #define endgrent     bb_internal_endgrent
 #define getgrent     bb_internal_getgrent
diff -d -urpN busybox.3/include/libbb.h busybox.4/include/libbb.h
--- busybox.3/include/libbb.h	2008-09-25 12:44:22.000000000 +0200
+++ busybox.4/include/libbb.h	2008-09-26 11:54:20.000000000 +0200
@@ -69,21 +69,15 @@
 #include <dmalloc.h>
 #endif
 
-#if !ENABLE_USE_BB_PWD_GRP
-# include <pwd.h>
-# include <grp.h>
-#endif
+#include <pwd.h>
+#include <grp.h>
 #if ENABLE_FEATURE_SHADOWPASSWDS
-# if !ENABLE_USE_BB_SHADOW
-#  include <shadow.h>
-# endif
+# include <shadow.h>
 #endif
 
 /* Some libc's forget to declare these, do it ourself */
 
 extern char **environ;
-/* Set the group set for the current user to GROUPS (N of them).  */
-int setgroups(size_t n, const gid_t *groups);
 #if defined(__GLIBC__) && __GLIBC__ < 2
 int vdprintf(int d, const char *format, va_list ap);
 #endif
diff -d -urpN busybox.3/include/pwd_.h busybox.4/include/pwd_.h
--- busybox.3/include/pwd_.h	2008-09-25 12:22:15.000000000 +0200
+++ busybox.4/include/pwd_.h	2008-09-26 11:51:50.000000000 +0200
@@ -21,25 +21,13 @@
  *	POSIX Standard: 9.2.2 User Database Access	<pwd.h>
  */
 
-#ifndef	_PWD_H
-#define	_PWD_H 1
+#ifndef	BB_PWD_H
+#define	BB_PWD_H 1
 
 #if __GNUC_PREREQ(4,1)
 # pragma GCC visibility push(hidden)
 #endif
 
-/* The passwd structure.  */
-struct passwd {
-	char *pw_name;          /* Username.  */
-	char *pw_passwd;        /* Password.  */
-	uid_t pw_uid;           /* User ID.  */
-	gid_t pw_gid;           /* Group ID.  */
-	char *pw_gecos;         /* Real name.  */
-	char *pw_dir;           /* Home directory.  */
-	char *pw_shell;         /* Shell program.  */
-};
-
-
 #define setpwent    bb_internal_setpwent
 #define endpwent    bb_internal_endpwent
 #define getpwent    bb_internal_getpwent
diff -d -urpN busybox.3/include/rtc_.h busybox.4/include/rtc_.h
--- busybox.3/include/rtc_.h	2008-09-25 12:22:15.000000000 +0200
+++ busybox.4/include/rtc_.h	2008-09-26 11:51:15.000000000 +0200
@@ -4,8 +4,8 @@
  * Licensed under the GPL-2 or later.
  */
 
-#ifndef _BB_RTC_H_
-#define _BB_RTC_H_
+#ifndef BB_RTC_H
+#define BB_RTC_H
 
 #include "libbb.h"
 
diff -d -urpN busybox.3/include/shadow_.h busybox.4/include/shadow_.h
--- busybox.3/include/shadow_.h	2008-09-25 12:22:15.000000000 +0200
+++ busybox.4/include/shadow_.h	2008-09-26 11:52:00.000000000 +0200
@@ -19,8 +19,8 @@
 
 /* Declaration of types and functions for shadow password suite */
 
-#ifndef _SHADOW_H
-#define _SHADOW_H 1
+#ifndef BB_SHADOW_H
+#define BB_SHADOW_H 1
 
 #if __GNUC_PREREQ(4,1)
 # pragma GCC visibility push(hidden)
@@ -31,20 +31,6 @@
 #define _PATH_SHADOW "/etc/shadow"
 #endif
 
-/* Structure of the password file */
-struct spwd {
-	char *sp_namp;          /* Login name */
-	char *sp_pwdp;          /* Encrypted password */
-	long sp_lstchg;         /* Date of last change */
-	long sp_min;            /* Minimum number of days between changes */
-	long sp_max;            /* Maximum number of days between changes */
-	long sp_warn;           /* Number of days to warn user to change the password */
-	long sp_inact;          /* Number of days the account may be inactive */
-	long sp_expire;         /* Number of days since 1970-01-01 until account expires */
-	unsigned long sp_flag;  /* Reserved */
-};
-
-
 #define setspent    bb_internal_setspent
 #define endspent    bb_internal_endspent
 #define getspent    bb_internal_getspent
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to