From patchwork Mon Mar 4 11:12:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 1283 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 84ADC16CF6; Mon, 4 Mar 2019 11:14:15 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 3D10D16C43 for ; Mon, 4 Mar 2019 11:14:15 +0000 (GMT) Received: from localhost ([127.0.0.1]:52013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0lXy-0001Wq-K8 for patchwork@mira.cbaines.net; Mon, 04 Mar 2019 06:14:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0lXn-0001VA-A6 for guix-patches@gnu.org; Mon, 04 Mar 2019 06:14:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0lXm-0004gs-EY for guix-patches@gnu.org; Mon, 04 Mar 2019 06:14:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h0lXm-0004gk-9x for guix-patches@gnu.org; Mon, 04 Mar 2019 06:14:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h0lXl-0006B1-Vm for guix-patches@gnu.org; Mon, 04 Mar 2019 06:14:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#34730] [PATCH 0/4] Add (gnu build accounts) and use it to create /etc/passwd & co. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 04 Mar 2019 11:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 34730 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34730@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155169798423649 (code B ref -1); Mon, 04 Mar 2019 11:14:01 +0000 Received: (at submit) by debbugs.gnu.org; 4 Mar 2019 11:13:04 +0000 Received: from localhost ([127.0.0.1]:59007 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0lWq-00069N-6G for submit@debbugs.gnu.org; Mon, 04 Mar 2019 06:13:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48978) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0lWm-00068r-B3 for submit@debbugs.gnu.org; Mon, 04 Mar 2019 06:13:01 -0500 Received: from lists.gnu.org ([209.51.188.17]:32990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h0lWg-0003M6-NF for submit@debbugs.gnu.org; Mon, 04 Mar 2019 06:12:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0lWf-0001Nr-RE for guix-patches@gnu.org; Mon, 04 Mar 2019 06:12:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0lWe-0003Kr-Og for guix-patches@gnu.org; Mon, 04 Mar 2019 06:12:53 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:45354) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h0lWe-0003HW-GR; Mon, 04 Mar 2019 06:12:52 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 329879AFF; Mon, 4 Mar 2019 12:12:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Cn86gPCqfuCe; Mon, 4 Mar 2019 12:12:46 +0100 (CET) Received: from gnu.org (unknown [IPv6:2001:660:6102:320:e120:2c8f:8909:cdfe]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 840989AC7; Mon, 4 Mar 2019 12:12:46 +0100 (CET) From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 4 Mar 2019 12:12:13 +0100 Message-Id: <20190304111213.8436-1-ludo@gnu.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hello Guix! This patch series adds a new module, (gnu build accounts), and uses it to create /etc/{passwd,group,shadow} upon system activation. This replaces functionality currently provided by the Shadow command-line tools (‘useradd’, ‘usermod’, etc.) and libc (‘getspnam’, ‘putpwent’, and all these wonderful APIs.) It’s more code on our side, but it’s overall much less code involved to create those databases. The code makes the UID/GID allocation strategy and state handling (preserving passwords and UIDs/GIDs, not reusing currently-used UIDs/GIDs, etc.) much clearer and auditable. Previously all this was buried in imperative calls to ‘useradd’ & co., which in turn have an ID allocation strategy baked deep down into the Shadow code. As a side effect the system boots slightly faster and we get PIDs starting at ~190 instead of ~300 on a bare-bones system. :-) Feedback welcome! Ludo’. Ludovic Courtès (4): system: Add (gnu system accounts). activation: Operate on and records. Add (gnu build accounts). activation: Build account databases with (gnu build accounts). Makefile.am | 1 + gnu/build/accounts.scm | 561 +++++++++++++++++++++++++++++++++++++++ gnu/build/activation.scm | 245 +++-------------- gnu/build/install.scm | 3 +- gnu/local.mk | 2 + gnu/system/accounts.scm | 109 ++++++++ gnu/system/shadow.scm | 92 +++---- tests/accounts.scm | 309 +++++++++++++++++++++ 8 files changed, 1061 insertions(+), 261 deletions(-) create mode 100644 gnu/build/accounts.scm create mode 100644 gnu/system/accounts.scm create mode 100644 tests/accounts.scm