mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-23 06:32:05 +03:00
add put*ent functions for passwd/group files and similar for shadow
since shadow does not yet support enumeration (getspent), the corresponding FILE-based get and put versions are also subbed out for now. this is partly out of laziness and partly because it's not clear how they should work in the presence of TCB shadow files. the stubs should make it possible to compile some software that expects them to exist, but such software still may not work properly.
This commit is contained in:
parent
771c6cead0
commit
ddfb267b0e
@ -36,6 +36,7 @@ void setgrent(void);
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
struct group *fgetgrent(FILE *stream);
|
||||
int putgrent(const struct group *, FILE *);
|
||||
#endif
|
||||
|
||||
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
|
@ -39,6 +39,7 @@ int getpwnam_r (const char *, struct passwd *, char *, size_t, struct passwd **)
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
struct passwd *fgetpwent(FILE *);
|
||||
int putpwent(const struct passwd *, FILE *);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
11
src/passwd/fgetspent.c
Normal file
11
src/passwd/fgetspent.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "pwf.h"
|
||||
|
||||
struct spwd *fgetspent(FILE *f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int putspent(const struct spwd *sp, FILE *f)
|
||||
{
|
||||
return -1;
|
||||
}
|
14
src/passwd/putgrent.c
Normal file
14
src/passwd/putgrent.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int putgrent(const struct group *gr, FILE *f)
|
||||
{
|
||||
int r;
|
||||
size_t i;
|
||||
flockfile(f);
|
||||
r = fprintf(f, "%s:%s:%d:", gr->gr_name, gr->gr_passwd, gr->gr_gid);
|
||||
if (gr->gr_mem) for (i=0; gr->gr_mem[i]; i++)
|
||||
if (fprintf(f, "%s%s", i?",":"", gr->gr_mem[i])<0) r = -1;
|
||||
funlockfile(f);
|
||||
return r<0 ? -1 : 0;
|
||||
}
|
9
src/passwd/putpwent.c
Normal file
9
src/passwd/putpwent.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int putpwent(const struct passwd *pw, FILE *f)
|
||||
{
|
||||
return fprintf(f, "%s:%s:%d:%d:%s:%s:%s\n",
|
||||
pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid,
|
||||
pw->pw_gecos, pw->pw_dir, pw->pw_shell)<0 ? -1 : 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user