From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4248 Path: news.gmane.org!not-for-mail From: Michael Forney Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 0/2] Implement fgetspent Date: Wed, 20 Nov 2013 19:13:39 -0800 Message-ID: <1385003621-10289-1-git-send-email-mforney@mforney.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1385003926 7240 80.91.229.3 (21 Nov 2013 03:18:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Nov 2013 03:18:46 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4252-gllmg-musl=m.gmane.org@lists.openwall.com Thu Nov 21 04:18:52 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 1VjKn4-0003Kn-TB for gllmg-musl@plane.gmane.org; Thu, 21 Nov 2013 04:18:50 +0100 Original-Received: (qmail 3934 invoked by uid 550); 21 Nov 2013 03:18:50 -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 3926 invoked from network); 21 Nov 2013 03:18:49 -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=95vQoLD6swg3YSiWe8pDTXZn6QpJS3508vEKsqC8DuI=; b=MpLmM2wmze16hkwu7KuVq686gElsbnWave3gZpA/j0sFkHOJgzIyJmm3QL3aah6ytL pwK81jXKfw+R1SqOPol0R/Nra1Ac+VWlSEsiP5y6ZlcNQe8LDcv2rMaIDdhZ/1MSuaXk 7esQctBgT129UH8YkMFliT4SfC+Bl4kAdGeHQSf0BlPy8En91ZrHgJ4NbAL0epkiDIbZ zVsF3QLvvhZX3LrAl+H2PPOrM3HufqTopDNih2S+u+N8Ud2YUy7ecktyLWKjPPgiggOm /lSrC5HCdA8rhoSnWmmmFCQMpbHLTzNlRfD0UB4Fdw1xEOF0IIOxS0K6bObD6Feklj4D QdTw== X-Gm-Message-State: ALoCoQlVYRTiM/dbwCeT+rDJj/m9cmLS15qmDkI2IFJBZEYUzAuGbmBQ0p0+Av+YUCJjTdKe0dsa X-Received: by 10.236.119.102 with SMTP id m66mr47855yhh.90.1385003917678; Wed, 20 Nov 2013 19:18:37 -0800 (PST) X-Mailer: git-send-email 1.8.4.2 Xref: news.gmane.org gmane.linux.lib.musl.general:4248 Archived-At: Hi Rich, It turns out that one more function, fgetspent, is needed for the common shadow+pam_unix setup used in many desktop systems. Otherwise, when changing your password, pam_unix will attempt to enumerate through the shadow entries with fgetspent, rewriting them as it goes (and replacing the entry to be updated). This leaves you with a shadow file containing only the updated entry. In the first patch, I moved spent parsing to an internal function, __parsespent. I opted to use __parsespent instead of __getspent_a (similar to the passwd and group functions) for several reasons: - To minimize the changes necessary to getspnam_r - To avoid the extra memcpy as in getpw_r - It seemed like a more self-contained function (which didn't rely on the source of the entry). - It would make it easier to implement sgetspent if we ever wanted that (though, so far, I haven't found anything that requires this) However, if this is not desired, I can send a new patch which uses a function __getspent_a, similar to __get{pw,gr}ent_a. Michael Forney (2): shadow: Move spent parsing to internal function shadow: Implement fgetspent src/passwd/fgetspent.c | 11 ++++++++++- src/passwd/getspnam_r.c | 34 +--------------------------------- src/passwd/parsespent.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/passwd/pwf.h | 2 +- 4 files changed, 54 insertions(+), 35 deletions(-) create mode 100644 src/passwd/parsespent.c -- 1.8.4.2