Bug 242437 - Jail rc script does not return non-0 exit code on problems
Summary: Jail rc script does not return non-0 exit code on problems
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-jail (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-04 20:53 UTC by Philipp Erbelding
Modified: 2019-12-05 10:48 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Erbelding 2019-12-04 20:53:10 UTC
Trying to start jails using "service jail start <jailname>".

I found two types of failures that cause the /etc/rc.d/jail script to return 0 after printing "cannot start jail" and not starting the jail.

The two cases are: 
1. An exec.prestart command fails
2. The named jail does not exist

Examples:

[root@kwik-e /etc]# service jail start lmcv6
Starting jails: cannot start jail  "lmcv6": 
ifconfig: BRDGADD epair4b: File exists
jail: lmcv6: ifconfig bridge1 addm epair4b: failed
.
[root@kwik-e /etc]# echo $?
0

[root@kwik-e ~]# service jail start doesnotexist
Starting jails: cannot start jail  "doesnotexist": 
jail: "doesnotexist" not found
.
[root@kwik-e ~]# echo $?
0


Looking at the code quickly it looks to me that no failures are handled with regards to the exit code of the script itself.

Some logic might need to be defined to deal with partial failures when starting multiple or all jails. Returning 1 on anything except complete and utter success would also work for me.