From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 2/2] scripts: Add 'publish' command. Date: Mon, 30 Mar 2015 21:32:46 +0200 Message-ID: <87y4me5li9.fsf@gnu.org> References: <87egon1xkg.fsf@fsf.org> <878uev1xcz.fsf@fsf.org> <87k2yeha77.fsf@gnu.org> <87wq22gyxb.fsf@fsf.org> <87pp7u6p31.fsf@gnu.org> <87h9t3buuj.fsf@netris.org> <87lhifhfu1.fsf@fsf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcfQc-0001sX-BA for guix-devel@gnu.org; Mon, 30 Mar 2015 15:32:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcfQZ-0004QG-4O for guix-devel@gnu.org; Mon, 30 Mar 2015 15:32:54 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcfQZ-0004QC-1b for guix-devel@gnu.org; Mon, 30 Mar 2015 15:32:51 -0400 In-Reply-To: <87lhifhfu1.fsf@fsf.org> (David Thompson's message of "Sun, 29 Mar 2015 13:29:58 -0400") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: David Thompson Cc: guix-devel@gnu.org David Thompson skribis: > Mark H Weaver writes: > >> ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> >>> David Thompson skribis: >>> >>>> +(define (render-nar request store-item) >>>> + "Render archive of the store path corresponding to STORE-ITEM." >>>> + (let ((store-path (string-append %store-directory "/" store-item))) >>>> + ;; The ISO-8859-1 charset *must* be used otherwise HTTP clients w= ill >>>> + ;; interpret the byte stream as UTF-8 and arbitrarily change inva= lid byte >>>> + ;; sequences. >>>> + (if (file-exists? store-path) >>>> + (values '((content-type . (application/x-nix-archive >>>> + (charset . "ISO-8859-1")))) >>>> + (lambda (port) >>>> + (write-file store-path port))) >>>> + (not-found request)))) >>> >>> This is OK for now, but I just realized that this will be blocking the >>> server for the duration of the whole transfer. Someone could DoS you by >>> substituting TeX Live. ;-) >>> >>> We=E2=80=99ll need a solution but it seems that it=E2=80=99ll be hard t= o avoid threads. >>> >>> Thoughts? >> >> I haven't looked closely, but how about using subprocesses instead of >> threads? Sounds good. > That's along the lines of what I was thinking. One could spawn a bunch > of 'guix publish' processes on different ports and put a load balancer > in front of them. What about changing the =E2=80=98open=E2=80=99 method of the = (as in tests/lint.scm) so that it forks upon socket opening? (That could also be the moment where we=E2=80=99d drop privileges.) > I think that this problem, if it is to be solved with more Scheme code, > is an issue to address in Guile core by changing the http server > implementation. Once we have a sufficiently different and valuable server implementation, we could turn it into a (web server xxx) module. I think there=E2=80=99s value in keeping the simple/simplistic (web server ht= tp) too. Ludo=E2=80=99.