diff options
author | Rob Landley <rob@landley.net> | 2006-07-15 23:00:46 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-07-15 23:00:46 +0000 |
commit | df822f2606a5c56a8af5785d4e507aff2eeaaace (patch) | |
tree | 087cd0a58a163f3ea7819e59abecbd901227486a | |
parent | 1870737480b8beaa6c8834b916da7f73f4fb4807 (diff) | |
download | busybox-w32-df822f2606a5c56a8af5785d4e507aff2eeaaace.tar.gz busybox-w32-df822f2606a5c56a8af5785d4e507aff2eeaaace.tar.bz2 busybox-w32-df822f2606a5c56a8af5785d4e507aff2eeaaace.zip |
We need xsetuid() and xsetgid() because per-user process resource limits can
prevent a process from switching to a user that has too many processes, and
when that happens WE'RE STILL ROOT. See http://lwn.net/Articles/190331/
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/xfuncs.c | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h index 2f9041273..549b4fc0c 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -185,6 +185,8 @@ extern void utoa_to_buf(unsigned n, char *buf, unsigned buflen); | |||
185 | extern char *utoa(unsigned n); | 185 | extern char *utoa(unsigned n); |
186 | extern void itoa_to_buf(int n, char *buf, unsigned buflen); | 186 | extern void itoa_to_buf(int n, char *buf, unsigned buflen); |
187 | extern char *itoa(int n); | 187 | extern char *itoa(int n); |
188 | extern void xsetgid(gid_t gid); | ||
189 | extern void xsetuid(uid_t uid); | ||
188 | 190 | ||
189 | #define BB_GETOPT_ERROR 0x80000000UL | 191 | #define BB_GETOPT_ERROR 0x80000000UL |
190 | extern const char *bb_opt_complementally; | 192 | extern const char *bb_opt_complementally; |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index bcd0751ee..d843414f9 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -282,3 +282,15 @@ char *itoa(int n) | |||
282 | return local_buf; | 282 | return local_buf; |
283 | } | 283 | } |
284 | #endif | 284 | #endif |
285 | |||
286 | #ifdef L_setuid | ||
287 | void xsetgid(gid_t gid) | ||
288 | { | ||
289 | if (setgid(gid)) bb_error_msg_and_die("setgid"); | ||
290 | } | ||
291 | |||
292 | void xsetuid(uid_t uid) | ||
293 | { | ||
294 | if (setuid(uid)) bb_error_msg_and_die("setuid"); | ||
295 | } | ||
296 | #endif | ||