Skip to content

Commit f76c4c6

Browse files
authored
Merge pull request managarm#1833 from marv7000/lightdm-fixes
Fixes for lightdm and dependencies
2 parents 76037ce + f084ab0 commit f76c4c6

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

options/ansi/include/math.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ extern int signgam;
378378
double j0(double __x);
379379
double j1(double __x);
380380
double jn(int __n, double __x);
381+
double y0(double __x);
382+
double y1(double __x);
383+
double yn(int __n, double __x);
381384
#endif /* defined(_DEFAULT_SOURCE) || __MLIBC_XOPEN */
382385

383386
#if defined(_GNU_SOURCE)

options/posix/generic/grp.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,30 @@ int setgroups(size_t size, const gid_t *list) {
299299
return 0;
300300
}
301301

302-
int initgroups(const char *, gid_t) {
303-
mlibc::infoLogger() << "mlibc: initgroups is a stub" << frg::endlog;
304-
return 0;
302+
int initgroups(const char *user, gid_t gid) {
303+
int ngroups = 32;
304+
gid_t *groups = static_cast<gid_t *>(malloc(sizeof(gid_t) * ngroups));
305+
if(!groups) {
306+
errno = ENOMEM;
307+
return -1;
308+
}
309+
if(getgrouplist(user, gid, groups, &ngroups) < 0) {
310+
// Resize if it doesn't fit.
311+
gid_t *resized = static_cast<gid_t *>(realloc(groups, sizeof(gid_t) * ngroups));
312+
if(!resized) {
313+
free(groups);
314+
errno = ENOMEM;
315+
return -1;
316+
}
317+
groups = resized;
318+
if(getgrouplist(user, gid, groups, &ngroups) < 0) {
319+
free(groups);
320+
return -1;
321+
}
322+
}
323+
int ret = setgroups(static_cast<size_t>(ngroups), groups);
324+
free(groups);
325+
return ret;
305326
}
306327

307328
int putgrent(const struct group *g, FILE *f) {

0 commit comments

Comments
 (0)