From owner-freebsd-virtualization@freebsd.org Tue Oct 27 14:50:39 2015 Return-Path: Delivered-To: freebsd-virtualization@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BDA12A1F771 for ; Tue, 27 Oct 2015 14:50:39 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 572531D1D for ; Tue, 27 Oct 2015 14:50:39 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by wijp11 with SMTP id p11so217602176wij.0 for ; Tue, 27 Oct 2015 07:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=gxCMBavmH6ceY9M9hd267ASsnxjRJCnfPhRj9LNcn8s=; b=zk1iarfaJXO5HJ0dY1iuLhm+VLQdyU6uLaDg9SceJrMzd6XtSgp+ZyYAr/AxeV/kC1 8OZY6PlrVkPMGApqNHW23mTZTNKbN3QtYZNB4kB/1NeyxrFTXKmop6e3q4XBgAHiNVGb bnpWG1d0st7KPFIu6EvXgUjdu8V45nwrk50sVtl9zcASWDm+5rz7MUT+IrYsHxBXAmo4 v8SVCFwYYk1FcM4KyoFkwBeBW6o/6hlaRfyOLqdx8OO4lCusVMYscjcon8SrOoaED2P1 atAQDEPIdL5aB5kwqiUytmZkt2jj/r1eXfeUROspOLc41yUpf8i1uW8zvY/U6UAZvGcB orBQ== X-Received: by 10.194.2.5 with SMTP id 5mr55193027wjq.153.1445957437801; Tue, 27 Oct 2015 07:50:37 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by smtp.gmail.com with ESMTPSA id i10sm18043344wij.9.2015.10.27.07.50.35 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Oct 2015 07:50:36 -0700 (PDT) Date: Tue, 27 Oct 2015 15:50:34 +0100 From: Mateusz Guzik To: Sergey Zakharchenko Cc: freebsd-virtualization@freebsd.org Subject: Re: Docker: jail: name cannot be numeric fix Message-ID: <20151027145033.GA24588@dft-labs.eu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2015 14:50:39 -0000 On Tue, Oct 27, 2015 at 05:19:26PM +0300, Sergey Zakharchenko wrote: > Hello, > > This is just a quick note that the problem mentioned in the Docker > wiki https://wiki.freebsd.org/Docker : > > > {{{ > > docker run -t -i centos /bin/bash > > jail: name cannot be numeric (unless it is the jid > > }}} > > > > Unknown: Noticed when re-running a container. > > is not of an 'unknown' origin: it lies in sys/kern/kern_jail.c 's > detection of numeric JIDs, which dates back to 2009: > > https://svnweb.freebsd.org/base/head/sys/kern/kern_jail.c?revision=285685&view=markup > > else if (*namelc == '0' || (strtoul(namelc, &p, 10) != jid && *p == '\0'))) > > It thinks everything that starts with a '0' is numeric, and doesn't > check that it's the only character, e.g. namelc[1] == '\0'. This check > is incorrect for some of the hex jail names that Docker generates. > This is demonstrated by e.g. the following: > > ---> Running in 062a4f391fd9 > jail: name cannot be numeric (unless it is the jid) > > Should I send a PR? > What's the significance of said names? The issue here is that said id may contain to letters, effectivley looking like a number and that cannot be allowed due to jid/name confusion. While arbitrary names would be desirable, we are not going to get them without some weird effort. As such, the right fix would e.g. prefix all names with a letter and/or re-generated a name if it does not contain any non-numeric characters. The bogus check with 0 is only a side issue, which may or may not make sense to be addressed. -- Mateusz Guzik