# ezjail problem after upgrading 9.0 -> 9.1



## biotecs (Apr 10, 2013)

Hello, 

After a successful upgrade FreeBSD 9.0 RELEASE to 9.1 RELEASE:


```
FreeBSD my.domain 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
```

I got problems with my jails which I control with ezjail-admin. I did upgrade the jails with:


```
ezjail-admin update -b
ezjail-admin update -p -i
```

and tried to start them after a reboot of the host system. But the result looks like this:


```
sudo ezjail-admin start www
Configuring jails:.
Starting jails:eval: 1: Syntax error: redirection unexpected
Error: Could not start www.
  You need to start it by hand.
```

I also tried to start them with


```
sudo /etc/rc.d/jail onestart www
Configuring jails:.
Starting jails:/etc/rc.d/jail: ERROR: jail: No hostname has been defined for www
```

The ezjail configuration file for this jail seems to be ok and filled with a hostname:


```
vi /usr/local/etc/ezjail/www

export jail_www_hostname="www"
export jail_www_ip="10.0.0.2"
export jail_www_rootdir="/usr/jails/www"
export jail_www_exec_start="/bin/sh /etc/rc"
export jail_www_exec_stop=""
export jail_www_mount_enable="YES"
export jail_www_devfs_enable="YES"
export jail_www_devfs_ruleset="devfsrules_jail"
export jail_www_procfs_enable="YES"
export jail_www_fdescfs_enable="YES"
export jail_www_image=""
export jail_www_imagetype=""
export jail_www_attachparams=""
export jail_www_attachblocking=""
export jail_www_forceblocking=""
export jail_www_zfs_datasets=""
export jail_www_cpuset=""
export jail_www_fib=""
```

I also tried


```
sysctl security.jail.mount_allowed="1"
```

but don't think that this was the problem. 

I am very thankful for any suggestions.


----------



## _martin (Apr 10, 2013)

Hi, 

Did you upgrade your ezjail too? Which version are you running?


----------



## biotecs (Apr 10, 2013)

Hi,

Yes, it should be up to date:


```
pkg_info | grep ezjail
ezjail-3.2.3        Framework to easily create, manipulate, and run FreeBSD jai
```


----------



## _martin (Apr 10, 2013)

Note you can't start jail with /etc/rc.d/jail and assume it will work with your ezjail configuration (it actually works the other way around). 

As ezjail is "only" a wrapper script around jail, try running script in debug mode:

`# sh -x /usr/local/bin/ezjail-admin start www`

It seems shell script is failing on some eval expression.


----------



## biotecs (Apr 11, 2013)

Yes, my fault, I forgot that because of ezjail I don't have any configurations like 


```
jail_www_hostname="www.example.org"
```

in rc.conf. 

After some detailed reviews of the error outputs and shell scripts I was able to track the problem down to the script /etc/rc.d/jail at this line:

[cmd=]eval /sbin/devfs rule -s 4 '<<<<<<<' current version[/cmd]

Until now I wasn't able to find the line inside the script, but maybe someone knows the script much better than me. Couple lines before the error look like this:


```
+ rulecmd='add path stderr unhide'
+ [ -n 'add path stderr unhide' ]
+ debug 'adding rule (add path stderr unhide)'
+ eval /sbin/devfs rule -s 3 add path stderr unhide
+ /sbin/devfs rule -s 3 add path stderr unhide
+ [ 0 -ne 0 ]
+ read line
+ rulecmd=''
+ [ -n '' ]
+ [ 0 -ne 0 ]
+ read line
+ continue
+ read line
+ continue
+ read line
+ expr '[devfsrules_jail=4]' : '\[.*=\([0-9]*\)\]'
+ rulenum=4
+ [ -z 4 ]
+ expr '[devfsrules_jail=4]' : '\[\(.*\)=[0-9]*\]'
+ rulename=devfsrules_jail
+ [ -z devfsrules_jail ]
+ eval 'devfsrules_jail=$rulenum'
+ devfsrules_jail=4
+ debug 'found ruleset: devfsrules_jail=4'
+ /sbin/devfs rule -s 4 delset
+ [ 0 -ne 0 ]
+ read line
+ rulecmd='add include $devfsrules_hide_all'   
+ [ -n 'add include $devfsrules_hide_all' ]
+ debug 'adding rule (add include $devfsrules_hide_all)'
+ eval /sbin/devfs rule -s 4 add include '$devfsrules_hide_all'
+ /sbin/devfs rule -s 4 add include 1   
+ [ 0 -ne 0 ]
+ read line
+ rulecmd='add include $devfsrules_unhide_basic'
+ [ -n 'add include $devfsrules_unhide_basic' ]
+ debug 'adding rule (add include $devfsrules_unhide_basic)'
+ eval /sbin/devfs rule -s 4 add include '$devfsrules_unhide_basic'
+ /sbin/devfs rule -s 4 add include 2
+ [ 0 -ne 0 ]
+ read line
+ rulecmd='add include $devfsrules_unhide_login'  
+ [ -n 'add include $devfsrules_unhide_login' ]
+ debug 'adding rule (add include $devfsrules_unhide_login)'
+ eval /sbin/devfs rule -s 4 add include '$devfsrules_unhide_login'
+ /sbin/devfs rule -s 4 add include 3
+ [ 0 -ne 0 ]
+ read line
+ rulecmd='<<<<<<< current version'
+ [ -n '<<<<<<< current version' ]
+ debug 'adding rule (<<<<<<< current version)'
+ eval /sbin/devfs rule -s 4 '<<<<<<<' current version
```

There seem to be a corrupt devfs rule or a wrong variable.


----------



## SirDice (Apr 11, 2013)

biotecs said:
			
		

> ```
> eval /sbin/devfs rule -s 4 '<<<<<<<' current version
> ```


This looks like a skipped step with mergemaster(8). Edit the file and look for


```
<<<<<<<<<<
and
>>>>>>>>>>
```

You need to "merge" that bit of the config yourself.


----------



## biotecs (Apr 12, 2013)

Thank you so much, I would not have recognized this in years, because I thought I already merged all files!


----------



## SirDice (Apr 12, 2013)

I'm guessing that means it works now? :beer


----------



## biotecs (Apr 12, 2013)

You are guessing right, it works without any problems. 

Thanks again.


----------

