Re: does numeric only name of jails not allowed (bug?)

From: Jesús_Daniel_Colmenares_Oviedo <dtxdf_at_freebsd.org>
Date: Sat, 09 Aug 2025 16:15:46 UTC
Hi,


A few months ago, I accidentally created a jail with a number as its 
name, and it won't start because some AppJail options depend on 
'${name}' when the jail.conf(5) file is generated. A solution is to 
detect when the name is a number and set the 'name' parameter 
explicitly, so that both 'jid' and 'name' can be used.


```

$ appjail quick 123 start overwrite=force

...

[00:00:03] [ debug ] [123] jail.conf generated:
[00:00:03] [ debug ] [123]     123 {
[00:00:03] [ debug ] [123]         exec.start = "/bin/sh /etc/rc";
[00:00:03] [ debug ] [123]         exec.stop = "/bin/sh /etc/rc.shutdown 
jail";
[00:00:03] [ debug ] [123]         mount.devfs;
[00:00:03] [ debug ] [123]         persist;
[00:00:03] [ debug ] [123]         exec.consolelog = 
"/var/log/appjail/jails/123/console/2025-08-09.log";
[00:00:03] [ debug ] [123]         mount.fstab = 
"/usr/local/appjail/jails/123/conf/fstab";
[00:00:03] [ debug ] [123]         host.hostname = "123.appjail";
[00:00:03] [ debug ] [123]         path = 
"/usr/local/appjail/jails/123/jail";
[00:00:03] [ debug ] [123]         name = "123";
[00:00:03] [ debug ] [123]     }

...

$ appjail quick n123 start overwrite=force

...

[00:00:02] [ debug ] [n123]     n123 {
[00:00:02] [ debug ] [n123]         exec.start = "/bin/sh /etc/rc";
[00:00:02] [ debug ] [n123]         exec.stop = "/bin/sh 
/etc/rc.shutdown jail";
[00:00:02] [ debug ] [n123]         mount.devfs;
[00:00:02] [ debug ] [n123]         persist;
[00:00:02] [ debug ] [n123]         exec.consolelog = 
"/var/log/appjail/jails/n123/console/2025-08-09.log";
[00:00:02] [ debug ] [n123]         mount.fstab = 
"/usr/local/appjail/jails/n123/conf/fstab";
[00:00:02] [ debug ] [n123]         host.hostname = "n123.appjail";
[00:00:02] [ debug ] [n123]         path = 
"/usr/local/appjail/jails/n123/jail";
[00:00:02] [ debug ] [n123]     }

...

```

On 8/6/25 10:37, Anthony Pankov wrote:
> Dear freebsd-hackers.
>
> It seems there is no sign that numeric only name is prohibited:
>
> "
> The jail name.  This is an arbitrary string that identifies a
>               jail (except it may not contain a ďż˝.ďż˝).
> "
>
> But
> # head jail-47777.conf
> ...
> 47777 {
>          host.hostname = "${name}";
> ...
>
> # jail -c 47777
> jail: 47777: host.hostname: variable "name" not found
>
> If I add letter prefix, say w47777, it worked.
>
> Because of strange error "variable "name" not found" it seems like a bug. Does it?
>
>