Project

General

Profile

Bug #10159

Jails that have long names fail to autostart

Added by Hans Woithe over 5 years ago. Updated about 4 years ago.

Status:
Resolved
Priority:
Important
Assignee:
John Hixson
Category:
Middleware
Target version:
Severity:
New
Reason for Closing:
Reason for Blocked:
Needs QA:
Yes
Needs Doc:
Yes
Needs Merging:
Yes
Needs Automation:
No
Support Suite Ticket:
n/a
Hardware Configuration:
ChangeLog Required:
No

Description

Jails that have long names fail to autostart.

The ix-jail startup script is supposed to start all jails marked with autostart.
If the script is not given a list of jails it will try to find the jails to start.
It does this by calling jail_get defined in /etc/rc.freenas

https://github.com/freenas/freenas/blob/master/src/freenas/etc/ix.rc.d/ix-jail#L126

...
126: jails=$(jail_get|awk '{ print $1 }')
...

The jail_get function then calls warden to list the jails.
https://github.com/freenas/freenas/blob/master/build/nanobsd-cfg/Files/etc/rc.freenas#L599

...
599: ${WARDEN} list|tail +3
...

Warden calls listjails.sh
https://github.com/freenas/freenas/blob/master/src/pcbsd/warden/bin/warden#L910

...
910: lockf "/var/tmp/.wlist" ${PROGDIR}/scripts/backend/listjails.sh "$@" ;;
...

The listjails.sh does not guarantee a separator when printing out the jail's name.
This is the case in both FreeNAS and PC-BSD.

https://github.com/freenas/freenas/blob/master/src/pcbsd/warden/scripts/backend/listjails.sh#L245

...
245: warden_printf "%-24s%-12s%-12s%-12s\n" "${JAILNAME}" ${AUTO} ${STATUS} ${TYPE}
...

https://github.com/pcbsd/pcbsd/blob/master/src-sh/warden/scripts/backend/listjails.sh#L185

...
185: printf "%-24s%-12s%-12s%-12s\n" ${JAILNAME} ${AUTO} ${STATUS} ${TYPE}
...

So you can have a list that contains entries such as:

jailname-jailname-jailnameEnabled     Stopped     standard

This will not allow the jail_get_autostart function in /etc/rc.freenas to correctly identify if the jail needs to be automatically started, because it will get an incorrect jail name as the input string.
There are many ways to fix this of course.
For example, Warden could guarantee a separator.
If you are paranoid that this will break something else then, at the very least, the web and REST interfaces should limit the length of the Jail's name.

Associated revisions

Revision 58b451b1 (diff)
Added by John Hixson over 5 years ago

Use a space delimiter in warden list output Ticket: #10159

Revision 9fcb2963 (diff)
Added by John Hixson over 5 years ago

Use a space delimiter in warden list output Ticket: #10159 (cherry picked from commit 58b451b10148b5babec62749f352c64274b70a43)

Revision 46e2072f (diff)
Added by John Hixson over 5 years ago

Use a space delimiter in warden list output Ticket: #10159 (cherry picked from commit 58b451b10148b5babec62749f352c64274b70a43)

History

#1 Updated by Jordan Hubbard over 5 years ago

  • Assignee changed from John Hixson to Kris Moore
  • Target version set to Unspecified

Warden issue, and one which also affects PC-BSD at that, over to Kris.

#2 Avatar?id=14398&size=24x24 Updated by Kris Moore over 5 years ago

  • Assignee changed from Kris Moore to John Hixson

Bouncing this over to John Hixson, we've already begin the process of ripping out warden in favour of "iocage", so this won't be fixed on PC-BSD.

#3 Updated by John Hixson over 5 years ago

  • Status changed from Unscreened to Screened

#4 Updated by John Hixson over 5 years ago

I expect to look at this some time this week.

#5 Updated by John Hixson over 5 years ago

  • Status changed from Screened to Closed: Behaves correctly

What problem is occurring because of this? I got a chance to look at this, and there isn't an issue here. Yes, a warden list will mangle the output from long jail names, however, if you look at the very code you've pasted, it does a warden list -v, which was designed for this very issue. Run the same code posted with a long jail name and there is no problem. The desired output is obtained correctly.

#6 Updated by Hans Woithe over 5 years ago

The problem that is occurring because of this is that jails fail to automatically start when the FreeNAS machine is rebooted.

The "-v" you are referring to is from jail_get_autostart, I assume.
https://github.com/freenas/freenas/blob/master/build/nanobsd-cfg/Files/etc/rc.freenas#L543

...
543: ${WARDEN} list -v "${name}"|awk '/^autostart:/ { print $2 }'
...

The input string for ${name} is invalid and would be "jailname-jailname-jailnameEnabled" instead of "jailname-jailname-jailname." Warden would fail to print the verbose description of the jail because it cannot find the matching jail name since it is mangled.

#7 Updated by John Hixson over 5 years ago

  • Status changed from Closed: Behaves correctly to Screened

My apologies. I see what you are saying. Setting ix-jail with set -x clearly shows this as well. Fixed in 58b451b10148b5babec62749f352c64274b70a43.

#8 Updated by John Hixson over 5 years ago

  • Status changed from Screened to Ready For Release

#9 Updated by Jordan Hubbard about 5 years ago

  • Priority changed from No priority to Important

#10 Updated by Jordan Hubbard about 5 years ago

  • Status changed from Ready For Release to Resolved

#11 Avatar?id=14398&size=24x24 Updated by Kris Moore about 4 years ago

  • Target version changed from Unspecified to N/A

Also available in: Atom PDF