f0c61a0bdc7d2cb9f02a62f1c0cba24ff1f62981
[openwrt.git] / package / busybox / patches / 110-no_shadow.patch
1 --- busybox-1.3.1/include/libbb.h       Wed Dec 27 05:56:18 2006
2 +++ busybox-1.3.1.shadow/include/libbb.h        Sat Dec 30 15:24:07 2006
3 @@ -46,11 +46,13 @@
4  #ifdef CONFIG_LOCALE_SUPPORT
5  #include <locale.h>
6  #else
7 -#define setlocale(x,y)
8 +#define setlocale(x,y) ((void)0)
9  #endif
10  
11  #include "pwd_.h"
12  #include "grp_.h"
13 +/* ifdef it out, because it may include <shadow.h> */
14 +/* and we may not even _have_ <shadow.h>! */
15  #if ENABLE_FEATURE_SHADOWPASSWDS
16  #include "shadow_.h"
17  #endif
18 @@ -59,7 +61,7 @@
19  #include <limits.h>
20  #include <sys/param.h>
21  #ifndef PATH_MAX
22 -#define  PATH_MAX         256
23 +#define PATH_MAX 256
24  #endif
25  
26  /* Tested to work correctly (IIRC :]) */
27 --- busybox-1.3.1/libpwdgrp/pwd_grp.c   Wed Dec 27 05:56:32 2006
28 +++ busybox-1.3.1.shadow/libpwdgrp/pwd_grp.c    Sat Dec 30 15:24:07 2006
29 @@ -52,7 +52,9 @@
30  
31  extern int __parsepwent(void *pw, char *line);
32  extern int __parsegrent(void *gr, char *line);
33 +#if ENABLE_USE_BB_SHADOW
34  extern int __parsespent(void *sp, char *line);
35 +#endif
36  
37  extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,
38                 char *__restrict line_buff, size_t buflen, FILE *f);
39 @@ -103,6 +105,7 @@
40         return rv;
41  }
42  
43 +#if ENABLE_USE_BB_SHADOW
44  int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
45                                 char *__restrict buffer, size_t buflen,
46                                 struct spwd **__restrict result)
47 @@ -117,6 +120,7 @@
48  
49         return rv;
50  }
51 +#endif
52  
53  /**********************************************************************/
54  /* For the various fget??ent funcs, return NULL on failure and a
55 @@ -144,6 +148,7 @@
56         return result;
57  }
58  
59 +#if ENABLE_USE_BB_SHADOW
60  extern int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
61                                 char *__restrict buffer, size_t buflen,
62                                 struct spwd **__restrict result);
63 @@ -184,6 +189,7 @@
64   DONE:
65         return rv;
66  }
67 +#endif
68  
69  /**********************************************************************/
70  
71 @@ -207,6 +213,7 @@
72  #define DO_GETXXKEY_R_PATHNAME  _PATH_GROUP
73  #include "pwd_grp_internal.c"
74  
75 +#if ENABLE_USE_BB_SHADOW
76  #define GETXXKEY_R_FUNC                        getspnam_R
77  #define GETXXKEY_R_PARSER              __parsespent
78  #define GETXXKEY_R_ENTTYPE             struct spwd
79 @@ -214,6 +221,7 @@
80  #define DO_GETXXKEY_R_KEYTYPE  const char *__restrict
81  #define DO_GETXXKEY_R_PATHNAME  _PATH_SHADOW
82  #include "pwd_grp_internal.c"
83 +#endif
84  
85  #define GETXXKEY_R_FUNC                        getpwuid_R
86  #define GETXXKEY_R_PARSER              __parsepwent
87 @@ -253,6 +261,7 @@
88         return result;
89  }
90  
91 +#if 0 //ENABLE_USE_BB_SHADOW
92  /* This function is non-standard and is currently not built.  It seems
93   * to have been created as a reentrant version of the non-standard
94   * functions getspuid.  Why getspuid was added, I do not know. */
95 @@ -286,6 +295,7 @@
96         getspuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result);
97         return result;
98  }
99 +#endif
100  
101  struct passwd *getpwnam(const char *name)
102  {
103 @@ -307,6 +317,7 @@
104         return result;
105  }
106  
107 +#if ENABLE_USE_BB_SHADOW
108  struct spwd *getspnam(const char *name)
109  {
110         static char buffer[PWD_BUFFER_SIZE];
111 @@ -316,6 +327,7 @@
112         getspnam_r(name, &resultbuf, buffer, sizeof(buffer), &result);
113         return result;
114  }
115 +#endif
116  
117  int getpw(uid_t uid, char *buf)
118  {
119 @@ -444,6 +456,7 @@
120         return rv;
121  }
122  
123 +#if ENABLE_USE_BB_SHADOW
124  static FILE *spf /*= NULL*/;
125  void setspent(void)
126  {
127 @@ -488,6 +501,7 @@
128         UNLOCK;
129         return rv;
130  }
131 +#endif
132  
133  struct passwd *getpwent(void)
134  {
135 @@ -509,6 +523,7 @@
136         return result;
137  }
138  
139 +#if ENABLE_USE_BB_SHADOW
140  struct spwd *getspent(void)
141  {
142         static char line_buff[PWD_BUFFER_SIZE];
143 @@ -528,6 +543,7 @@
144         sgetspent_r(string, &spwd, line_buff, sizeof(line_buff), &result);
145         return result;
146  }
147 +#endif
148  
149  int initgroups(const char *user, gid_t gid)
150  {
151 @@ -643,6 +659,7 @@
152         return rv;
153  }
154  
155 +#if ENABLE_USE_BB_SHADOW
156  static const unsigned char _sp_off[] = {
157         offsetof(struct spwd, sp_lstchg),       /* 2 - not a char ptr */
158         offsetof(struct spwd, sp_min),          /* 3 - not a char ptr */
159 @@ -688,6 +705,7 @@
160  DO_UNLOCK:
161         return rv;
162  }
163 +#endif
164  
165  /**********************************************************************/
166  /* Internal uClibc functions.                                   */
167 @@ -846,6 +864,7 @@
168  
169  /**********************************************************************/
170  
171 +#if ENABLE_USE_BB_SHADOW
172  static const unsigned char sp_off[] = {
173         offsetof(struct spwd, sp_namp),         /* 0 */
174         offsetof(struct spwd, sp_pwdp),         /* 1 */
175 @@ -900,6 +919,7 @@
176  
177         return EINVAL;
178  }
179 +#endif
180  
181  /**********************************************************************/
182  
183 --- busybox-1.3.1/loginutils/passwd.c   Wed Dec 27 05:56:20 2006
184 +++ busybox-1.3.1.shadow/loginutils/passwd.c    Sat Dec 30 15:24:07 2006
185 @@ -275,7 +275,8 @@
186         }
187  
188         filename = bb_path_passwd_file;
189 -       if (ENABLE_FEATURE_SHADOWPASSWDS) {
190 +#if ENABLE_FEATURE_SHADOWPASSWDS
191 +       {
192                 struct spwd *sp = getspnam(name);
193                 if (!sp) {
194                         /* LOGMODE_BOTH */
195 @@ -287,6 +288,7 @@
196                         pw->pw_passwd = sp->sp_pwdp;
197                 }
198         }
199 +#endif
200  
201         /* Decide what the new password will be */
202         newp = NULL;
203 --- busybox-1.3.1/loginutils/sulogin.c  Wed Dec 27 05:56:20 2006
204 +++ busybox-1.3.1.shadow/loginutils/sulogin.c   Sat Dec 30 15:24:07 2006
205 @@ -41,7 +41,6 @@
206         char *timeout_arg;
207         const char * const *p;
208         struct passwd *pwd;
209 -       struct spwd *spwd;
210         const char *shell;
211  
212         logmode = LOGMODE_BOTH;
213 @@ -75,13 +74,15 @@
214                 goto auth_error;
215         }
216  
217 -       if (ENABLE_FEATURE_SHADOWPASSWDS) {
218 -               spwd = getspnam(pwd->pw_name);
219 +#if ENABLE_FEATURE_SHADOWPASSWDS
220 +       {
221 +               struct spwd *spwd = getspnam(pwd->pw_name);
222                 if (!spwd) {
223                         goto auth_error;
224                 }
225                 pwd->pw_passwd = spwd->sp_pwdp;
226         }
227 +#endif
228  
229         while (1) {
230                 /* cp points to a static buffer that is zeroed every time */