[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] setting the jail 'name' for use in the 'jexec' command




Jexec can accept either the JID or the jail 'Name'. If you run 'jls -v' you see ezjail does not set the name and the default of the jail is the same as the JID. Useless!

Having a 'name' on the jail allows you to use a non-moving target for jexec commands. For instance, you can restart you jails, not worry about the JID changing and can issue a command like this:

 jexec foobar tcsh

just add '_name' to your ezjail config, and patch your rc.d/ezjail file.

Rudy


--- ezjail.orig 2012-06-22 23:15:55.000000000 -0700
+++ ezjail      2012-06-22 23:29:25.000000000 -0700
@@ -112,6 +112,7 @@

       eval ezjail_zfs_datasets=\"\$jail_${ezjail_safename}_zfs_datasets\"
       eval ezjail_cpuset=\"\$jail_${ezjail_safename}_cpuset\"
+      eval ezjail_name=\"\$jail_${ezjail_safename}_name\"

       # Attach ZFS-datasets to the jail
       for zfs in ${ezjail_zfs_datasets}; do
@@ -120,6 +121,9 @@

       # Configure processor sets for the jail via cpuset(1)
[ -z "${ezjail_cpuset}" ] || /usr/bin/cpuset -l ${ezjail_cpuset} -j ${ezjail_id} || echo -n "Error: The defined cpuset is malformed"
+
+      # apply the shortcut name for use with jexec(8)
+ [ -z "${ezjail_name}" ] || /usr/sbin/jail -m jid=${ezjail_id} name=${ezjail_name} || echo -n "Error: The defined name is malformed"
     done
   fi