From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#26353: GuixSD /tmp cleaner fails to clean when Umlauts like "=?UTF-8?Q?=C3=A4?=" are used in filenames Date: Wed, 12 Apr 2017 15:04:01 +0200 Message-ID: <87poghdbge.fsf@gnu.org> References: <20170403202146.2a9317ce@scratchpost.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyHxM-00088r-Rr for bug-guix@gnu.org; Wed, 12 Apr 2017 09:05:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyHxH-0004bR-11 for bug-guix@gnu.org; Wed, 12 Apr 2017 09:05:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:45721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cyHxG-0004bL-U5 for bug-guix@gnu.org; Wed, 12 Apr 2017 09:05:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cyHxG-0007KK-K4 for bug-guix@gnu.org; Wed, 12 Apr 2017 09:05:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20170403202146.2a9317ce@scratchpost.org> (Danny Milosavljevic's message of "Mon, 3 Apr 2017 20:56:32 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Danny Milosavljevic Cc: 26353@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Danny, Danny Milosavljevic skribis: > the GuixSD /tmp cleaner fails to clean when Umlauts like "=C3=A4" are use= d in filenames. It will just leave them there. > > For example I have an immortal file "/tmp/!x!home!dannym!scratchpost.org!= www!mirror!science!physics!03._Relativit=C3=A4tstheorie!.webseealso~". The problem is that the =E2=80=9Cactivation scripts=E2=80=9D run in the C l= ocale and thus Guile interprets file names in this locale encoding (i.e., ASCII), which fails. I believe the attached patch mostly fixes the problem. Could you try and report back? I say =E2=80=9Cmostly=E2=80=9D because if /tmp contains a file in an encodi= ng other than that of the system locale, we still have a problem. Once we=E2=80=99ve switched to Guile 2.2, we should probably force use of an ISO-8859-1 locale to avoid file name decoding altogether. Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/services.scm b/gnu/services.scm index 9f6e323e1..500724eec 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -248,9 +248,9 @@ directory." ;; The service that produces the boot script. (service boot-service-type #t)) -(define (cleanup-gexp _) +(define (cleanup-gexp locale) "Return as a monadic value a gexp to clean up /tmp and similar places upon -boot." +boot. Run with LOCALE to ensure file names are properly decoded." (with-monad %store-monad (with-imported-modules '((guix build utils)) (return #~(begin @@ -272,6 +272,13 @@ boot." #t)))) ;; Ignore I/O errors so the system can boot. (fail-safe + ;; Guile decodes file names according to the current + ;; locale's encoding so attempt to use an appropriate + ;; locale. See . + ;; TODO: With Guile 2.2, choose an ISO-8859-1 locale + ;; to disable decoding altogether. + (setlocale LC_CTYPE #$locale) + (delete-file-recursively "/tmp") (delete-file-recursively "/var/run") (mkdir "/tmp") @@ -280,7 +287,8 @@ boot." (chmod "/var/run" #o755)))))))) (define cleanup-service-type - ;; Service that cleans things up in /tmp and similar. + ;; Service that cleans things up in /tmp and similar. Its value is the name + ;; of a locale to install before traversing these directories. (service-type (name 'cleanup) (extensions (list (service-extension boot-service-type diff --git a/gnu/system.scm b/gnu/system.scm index 0f52351cf..5e0d2db7d 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -309,7 +309,8 @@ a container or that of a \"bare metal\" system." ;; activation code. %shepherd-root-service %activation-service - (service cleanup-service-type #f) + (service cleanup-service-type + (operating-system-locale os)) (pam-root-service (operating-system-pam-services os)) (account-service (append (operating-system-accounts os) --=-=-=--