From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id qLKEB9jfJGZ+eQAA62LTzQ:P1 (envelope-from ) for ; Sun, 21 Apr 2024 11:43:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id qLKEB9jfJGZ+eQAA62LTzQ (envelope-from ) for ; Sun, 21 Apr 2024 11:43:52 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713692631; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=5/GF9do3ZOLAwPzowUWheZ+G6BNV/tVywsTwtwbG9h8=; b=JGiaZVsyBkNaqiGRLWcuviePXcoOZALf/cPfrTYfe1/z3mTXTDwdm4hpMclG5CsaZQtAlq PTOSLvWi128GpVGjdRXQoipqVD5cXRwq321Wf2aui2CBd42KaE4pk4LYSv5Du12PhtTGGl rpWqbqyXD6rE0gNFGYYCHL7ER9Qw36h+7dBcVX6P+wWdEs5vIMhzrD/aDuUi22i0Bin9Mr Ep4IJHbNzJBCQeX32Kmtq6yPjHLA6bqUjhvFVKZpH+lMWUp/ccIGx39jw+kbO58f8D2w69 MEjAyqlXhifDHzWnLmOBhSETeGe6gAJH6fMaUSzP+tKcQuzAi14pz7wyOfzF9Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713692631; a=rsa-sha256; cv=none; b=hW4yeVsVsRw7ZWj/CE9Bl4XiyOfx64xTYmIG2TMfU9hOxYTbcQXbP4KEvbjBSR21soati5 3jtiqrTKXUYS7+fkMApvugx+i1yhjCg3fJSffxeeLx2JfXewxGqyyF0SJL0zaBxK6rjMTj 36IJ4IjbDnbAA8jCKWmtqEBd0YXj5767AXmF2tF1Oh2Dy60baMIq7JHID75v6IaPOnc3d0 36QEz5tcqaHPagio2KKMto8BLyEQi6tMLq1Rin3yjLILPX6Fsk05vhQ5azT+5MTn+GeMcc jB2GlL4Mbyb0V759Qj68BSsqyfIkVsuO/O6TAcT48dKrIopuYUz4lYvBEu9SPQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D613F3B1AB for ; Sun, 21 Apr 2024 11:43:51 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryTjh-0005Mx-66; Sun, 21 Apr 2024 05:43:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ryTjf-0005Kh-Kn for guix-patches@gnu.org; Sun, 21 Apr 2024 05:43:47 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryTjf-0002jP-Cs for guix-patches@gnu.org; Sun, 21 Apr 2024 05:43:47 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ryTju-0006TD-JZ for guix-patches@gnu.org; Sun, 21 Apr 2024 05:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70494] [PATCH 03/23] syscalls: Add missing pieces for derivation build environment. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 21 Apr 2024 09:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70494 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70494@debbugs.gnu.org Cc: Christopher Baines Received: via spool by 70494-submit@debbugs.gnu.org id=B70494.171369258724230 (code B ref 70494); Sun, 21 Apr 2024 09:44:02 +0000 Received: (at 70494) by debbugs.gnu.org; 21 Apr 2024 09:43:07 +0000 Received: from localhost ([127.0.0.1]:41739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTiy-0006I8-PE for submit@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:06 -0400 Received: from mira.cbaines.net ([212.71.252.8]:43358) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTiw-0006HN-5u for 70494@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:03 -0400 Received: from localhost (unknown [212.132.255.10]) by mira.cbaines.net (Postfix) with ESMTPSA id 3EC2B27BBEA; Sun, 21 Apr 2024 10:42:46 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 208978ff; Sun, 21 Apr 2024 09:42:46 +0000 (UTC) From: Christopher Baines Date: Sun, 21 Apr 2024 10:42:21 +0100 Message-ID: <538dc2b842f748ae1b5ece7885af99dbe00bff5f.1713692561.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <87bk632h36.fsf@cbaines.net> References: <87bk632h36.fsf@cbaines.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.88 X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -4.88 X-Migadu-Queue-Id: D613F3B1AB X-TUID: 5W6KPsgXGaSJ From: Caleb Ristvedt * guix/build/syscalls.scm (ADDR_NO_RANDOMIZE, UNAME26, PER_LINUX32): New variables. Flags needed for improving determinism / impersonating a 32-bit machine on a 64-bit machine. (initialize-loopback, setdomainname, personality): New procedures. (octal-escaped): New procedure. (mount-points): Use octal-escaped to properly handle unusual characters in mount point filenames. Signed-off-by: Christopher Baines Change-Id: I2f2aa38fe8f97f2565461d20331b95040a2d7539 --- guix/build/syscalls.scm | 45 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 92f2bb21fc..487ee68b43 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -162,6 +162,7 @@ (define-module (guix build syscalls) configure-network-interface add-network-route/gateway delete-network-route + initialize-loopback interface? interface-name @@ -212,7 +213,12 @@ (define-module (guix build syscalls) utmpx-address login-type utmpx-entries - (read-utmpx-from-port . read-utmpx))) + (read-utmpx-from-port . read-utmpx) + personality + ADDR_NO_RANDOMIZE + setdomainname + UNAME26 + PER_LINUX32)) ;;; Commentary: ;;; @@ -1952,6 +1958,16 @@ (define* (set-network-interface-up name (lambda () (close-port sock))))) +(define (initialize-loopback) + (let ((sock (socket PF_INET SOCK_DGRAM IPPROTO_IP))) + (dynamic-wind + (const #t) + (lambda () + (set-network-interface-flags sock "lo" + (logior IFF_UP IFF_LOOPBACK IFF_RUNNING))) + (lambda () + (close sock))))) + ;;; ;;; Network routes. @@ -2523,4 +2539,31 @@ (define (read-utmpx-from-port port) ((? bytevector? bv) (read-utmpx bv)))) +;; TODO: verify these constants are correct on platforms other than x86-64 +(define ADDR_NO_RANDOMIZE #x0040000) +(define UNAME26 #x0020000) +(define PER_LINUX32 #x0008) + +(define personality + (let ((proc (syscall->procedure int "personality" `(,unsigned-long)))) + (lambda (persona) + (let-values (((ret err) (proc persona))) + (if (= -1 ret) + (throw 'system-error "personality" "~A" + (list (strerror err)) + (list err)) + ret))))) + +(define setdomainname + (let ((proc (syscall->procedure int "setdomainname" (list '* int)))) + (lambda (domain-name) + (let-values (((ret err) (proc (string->pointer/utf-8 domain-name) + (bytevector-length (string->utf8 + domain-name))))) + (if (= -1 ret) + (throw 'system-error "setdomainname" "~A" + (list (strerror err)) + (list err)) + ret))))) + ;;; syscalls.scm ends here -- 2.41.0