diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-04-04 19:23:47 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-04-04 19:23:47 -0400 |
commit | ddfb267b0e72499f6022981733264a063ec881f0 (patch) | |
tree | 854193fad4a1c8ba4dac7816a4bac90e16f15654 /src | |
parent | 771c6cead0684487a0699750ff740e3d3894200a (diff) | |
download | musl-ddfb267b0e72499f6022981733264a063ec881f0.zip musl-ddfb267b0e72499f6022981733264a063ec881f0.tar.gz musl-ddfb267b0e72499f6022981733264a063ec881f0.tar.bz2 |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/passwd/fgetspent.c | 11 | ||||
-rw-r--r-- | src/passwd/putgrent.c | 14 | ||||
-rw-r--r-- | src/passwd/putpwent.c | 9 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/passwd/fgetspent.c b/src/passwd/fgetspent.c new file mode 100644 index 0000000..a9a3c97 --- /dev/null +++ b/src/passwd/fgetspent.c @@ -0,0 +1,11 @@ +#include "pwf.h" + +struct spwd *fgetspent(FILE *f) +{ + return 0; +} + +int putspent(const struct spwd *sp, FILE *f) +{ + return -1; +} diff --git a/src/passwd/putgrent.c b/src/passwd/putgrent.c new file mode 100644 index 0000000..d7847b1 --- /dev/null +++ b/src/passwd/putgrent.c @@ -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; +} diff --git a/src/passwd/putpwent.c b/src/passwd/putpwent.c new file mode 100644 index 0000000..80fbf38 --- /dev/null +++ b/src/passwd/putpwent.c @@ -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; +} |