From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4186 Path: news.gmane.org!not-for-mail From: Michael Forney Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] shadow: Implement putspent Date: Mon, 4 Nov 2013 23:47:40 -0800 Message-ID: <1383637660-7768-1-git-send-email-mforney@mforney.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1383637809 1408 80.91.229.3 (5 Nov 2013 07:50:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Nov 2013 07:50:09 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4190-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 05 08:50:14 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1VdbOu-0006b9-LZ for gllmg-musl@plane.gmane.org; Tue, 05 Nov 2013 08:50:12 +0100 Original-Received: (qmail 32059 invoked by uid 550); 5 Nov 2013 07:50:11 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 32051 invoked from network); 5 Nov 2013 07:50:11 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=KqavOjOw3NOsmSOOqENF1cykJc77sRwlOIMVl7Inriw=; b=a1VvGyT4kM2VQb0Qoq7Bh9jbx7yhvvuK4oLgfkGywiXJDQNEezzmmrgvFkVHJJ5D1l H0+Nxa1MCuOyLmTKylxWIBL2w8txcLnWRDFCvro4p/vT4j+Evn6SwKLjhot0Qtl61eTX /nP8zCZ02CHyby6Mb/nmkb9kjKAPABsAhHc+5VyN0lIJEL7viFK2nMxRgkCmJSdxWIQp WmOtrqbpr8//PfmRLgzaNN1p3Huqrv+K5OOoqisQOBv8gUBZ7Wuc8Ds90z9gwZY4xM0D bgsjnmpvIJb/QsbaxWTW5qE5ZUO95U/XI486Tuzc7rhpwN60KczjbNR4bYOG5AmwlkSJ 8Vfg== X-Gm-Message-State: ALoCoQks8dPjR/M8rW1EEAwfUP49tlAChF/UgeDaYkEmeuifEhDIGTx1tZD8PYa5KMECmQeQTrD7 X-Received: by 10.236.207.200 with SMTP id n48mr429545yho.99.1383637799360; Mon, 04 Nov 2013 23:49:59 -0800 (PST) X-Mailer: git-send-email 1.8.4.2 Xref: news.gmane.org gmane.linux.lib.musl.general:4186 Archived-At: --- When I brought up implementing the shadow.h functions on IRC, several concerns were raised. However, it turns out that the shadow package only requires putspent. I didn't understand the concerns on IRC, so if there is an issue with the implementation of this function, please let me know and hopefully I'll be able to address it. src/passwd/fgetspent.c | 5 ----- src/passwd/putspent.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/passwd/putspent.c diff --git a/src/passwd/fgetspent.c b/src/passwd/fgetspent.c index a9a3c97..3dda784 100644 --- a/src/passwd/fgetspent.c +++ b/src/passwd/fgetspent.c @@ -4,8 +4,3 @@ struct spwd *fgetspent(FILE *f) { return 0; } - -int putspent(const struct spwd *sp, FILE *f) -{ - return -1; -} diff --git a/src/passwd/putspent.c b/src/passwd/putspent.c new file mode 100644 index 0000000..bb0a410 --- /dev/null +++ b/src/passwd/putspent.c @@ -0,0 +1,30 @@ +#include +#include + +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; +} -- 1.8.4.2