Bug 232657 - usr.sbin/sysrc: incorrectly returns return code 0 after failing to modify a file
Summary: usr.sbin/sysrc: incorrectly returns return code 0 after failing to modify a file
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 11.2-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs mailing list
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2018-10-24 18:39 UTC by Mateusz Kwiatkowski
Modified: 2019-05-02 06:59 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Kwiatkowski 2018-10-24 18:39:11 UTC
To reproduce try to modify file in non existing directory:
$ sysrc -f ./nonexistent/testfile foo="bar"
/usr/sbin/sysrc: cannot create ./nonexistent/testfile: No such file or directory
$ echo $?
0

The exit code is 0 while I was expecting to see ENOENT (2).

It's the same when I try to modify file that is not accessible:
$ sysrc -f /etc/rc.conf foo=bar
/usr/sbin/sysrc: cannot create /etc/rc.conf: Permission denied
$ echo $?
0

In this case EACCESS (13) should be returned.

I don't think that distinguishing these errors is needed. Returning anything different than 0 should do the job.