aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/0001-linedit-deluser-use-POSIX-getpwent-instead-of-getpwe.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/busybox/0001-linedit-deluser-use-POSIX-getpwent-instead-of-getpwe.patch')
-rw-r--r--main/busybox/0001-linedit-deluser-use-POSIX-getpwent-instead-of-getpwe.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/main/busybox/0001-linedit-deluser-use-POSIX-getpwent-instead-of-getpwe.patch b/main/busybox/0001-linedit-deluser-use-POSIX-getpwent-instead-of-getpwe.patch
new file mode 100644
index 0000000000..9707c95a6c
--- /dev/null
+++ b/main/busybox/0001-linedit-deluser-use-POSIX-getpwent-instead-of-getpwe.patch
@@ -0,0 +1,69 @@
+From f47fa75ef19a43848dedb4a2bff79368878362bf Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 22 Apr 2014 12:41:20 +0000
+Subject: [PATCH] linedit, deluser: use POSIX getpwent instead of getpwent_r
+
+This fixes building with musl libc.
+
+Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
+---
+ libbb/lineedit.c | 11 ++++-------
+ loginutils/deluser.c | 11 +++++------
+ 2 files changed, 9 insertions(+), 13 deletions(-)
+
+diff --git a/libbb/lineedit.c b/libbb/lineedit.c
+index 8564307..99e6e2c 100644
+--- a/libbb/lineedit.c
++++ b/libbb/lineedit.c
+@@ -672,20 +672,17 @@ static char *username_path_completion(char *ud)
+ */
+ static NOINLINE unsigned complete_username(const char *ud)
+ {
+- /* Using _r function to avoid pulling in static buffers */
+- char line_buff[256];
+- struct passwd pwd;
+- struct passwd *result;
++ struct passwd *pw;
+ unsigned userlen;
+
+ ud++; /* skip ~ */
+ userlen = strlen(ud);
+
+ setpwent();
+- while (!getpwent_r(&pwd, line_buff, sizeof(line_buff), &result)) {
++ while ((pw = getpwent())) {
+ /* Null usernames should result in all users as possible completions. */
+- if (/*!userlen || */ strncmp(ud, pwd.pw_name, userlen) == 0) {
+- add_match(xasprintf("~%s/", pwd.pw_name));
++ if (/*!userlen || */ strncmp(ud, pw->pw_name, userlen) == 0) {
++ add_match(xasprintf("~%s/", pw->pw_name));
+ }
+ }
+ endpwent();
+diff --git a/loginutils/deluser.c b/loginutils/deluser.c
+index e39ac55..d7d9b24 100644
+--- a/loginutils/deluser.c
++++ b/loginutils/deluser.c
+@@ -73,14 +73,13 @@ int deluser_main(int argc, char **argv)
+ if (!member) {
+ /* "delgroup GROUP" */
+ struct passwd *pw;
+- struct passwd pwent;
+ /* Check if the group is in use */
+-#define passwd_buf bb_common_bufsiz1
+- while (!getpwent_r(&pwent, passwd_buf, sizeof(passwd_buf), &pw)) {
+- if (pwent.pw_gid == gr->gr_gid)
+- bb_error_msg_and_die("'%s' still has '%s' as their primary group!", pwent.pw_name, name);
++ setpwent();
++ while ((pw = getpwent())) {
++ if (pw->pw_gid == gr->gr_gid)
++ bb_error_msg_and_die("'%s' still has '%s' as their primary group!", pw->pw_name, name);
+ }
+- //endpwent();
++ endpwent();
+ }
+ pfile = bb_path_group_file;
+ if (ENABLE_FEATURE_SHADOWPASSWDS)
+--
+1.9.2
+