1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| | #include <shadow.h>
#include <stdio.h>
int putspent(const struct spwd *sp, FILE *f)
{
flockfile(f);
if (sp->sp_namp && fputs(sp->sp_namp, f) == EOF) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_pwdp && fputs(sp->sp_pwdp, f) == EOF) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_lstchg != -1 && fprintf(f, "%d", sp->sp_lstchg) < 0) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_min != -1 && fprintf(f, "%d", sp->sp_min) < 0) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_max != -1 && fprintf(f, "%d", sp->sp_max) < 0) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_warn != -1 && fprintf(f, "%d", sp->sp_warn) < 0) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_inact != -1 && fprintf(f, "%d", sp->sp_inact) < 0) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_expire != -1 && fprintf(f, "%d", sp->sp_expire) < 0) goto fail;
if (fputc(':', f) == EOF) goto fail;
if (sp->sp_flag != -1 && fprintf(f, "%d", sp->sp_flag) < 0) goto fail;
if (fputc('\n', f) == EOF) goto fail;
funlockfile(f);
return 0;
fail:
funlockfile(f);
return -1;
}
|