void-packages/srcpkgs/accountsservice/patches/musl-fgetspent_r.patch
Đoàn Trần Công Danh ae69000001 srcpkgs/a*: convert patches to -Np1
* arduino and antiword is kept at -Np0

```sh

git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

34 lines
1 KiB
Diff

diff --git a/src/daemon.c b/src/daemon.c
index 312394a..e7b3c58 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -140,6 +140,28 @@ error_get_type (void)
#define MAX_LOCAL_USERS 50
#endif
+#ifndef __GLIBC__
+ /* Musl libc does not support fgetspent_r(), write own
+ * wrapper
+ */
+static int fgetspent_r(FILE *fp, struct spwd *spbuf, char *buf, size_t buflen, struct spwd **spbufp) {
+ struct spwd *shadow_entry = fgetspent(fp);
+ if(!shadow_entry)
+ return -1;
+ size_t namplen = strlen(shadow_entry->sp_namp);
+ size_t pwdplen = strlen(shadow_entry->sp_pwdp);
+
+ if(namplen + pwdplen + 2 > buflen)
+ return -1;
+
+ *spbufp = memcpy(spbuf, shadow_entry, sizeof(struct spwd));
+ spbuf->sp_namp = strncpy(buf, shadow_entry->sp_namp, namplen + 1);
+ spbuf->sp_pwdp = strncpy(buf + namplen + 1, shadow_entry->sp_pwdp, pwdplen + 1);
+
+ return 0;
+}
+#endif
+
static struct passwd *
entry_generator_fgetpwent (Daemon *daemon,
GHashTable *users,