Bug 232657

Summary: usr.sbin/sysrc: incorrectly returns return code 0 after failing to modify a file
Product: Base System Reporter: Mateusz Kwiatkowski <kwiat3k>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Many People CC: 0mp, vasko.tim
Priority: --- Keywords: needs-patch
Version: 11.2-STABLE   
Hardware: Any   
OS: Any   

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.
Comment 1 Mateusz Kwiatkowski 2022-01-24 08:53:14 UTC
Can't reproduce on 13.0 so I assume it was fixed.
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-03-23 15:21:59 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=96424406ee8912401a8e14772d51fdc9aacd8411

commit 96424406ee8912401a8e14772d51fdc9aacd8411
Author:     Vasily Postnicov <shamaz.mazum@gmail.com>
AuthorDate: 2022-03-23 15:18:54 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-03-23 15:21:37 +0000

    games/shockolate: unbreak build on arm64

    Incoporate a patch from upstream which eliminates the wrong use of stdarg

    PR:     232657

 games/shockolate/Makefile                          |   2 +-
 .../patch-src_Libraries_3D_Source_interp.c (new)   | 718 +++++++++++++++++++++
 2 files changed, 719 insertions(+), 1 deletion(-)