Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177869904
D61930.1795475372.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D61930.1795475372.diff
View Options
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -16,7 +16,7 @@
#
# Version information
#
-SYSRC_VERSION="9.3 Nov-18,2026"
+SYSRC_VERSION="9.4 Nov-22,2026"
#
# Options
@@ -27,7 +27,9 @@
DESCRIBE= # -d
EXISTING_ONLY= # -E
IGNORE_UNKNOWNS= # -i
+HUSER= # -u user
JAIL= # -j jail
+JUSER= # -U user
LIST_CONFS= # -l
LIST_SERVICE_CONFS= # -L
QUIET= # -q
@@ -147,6 +149,12 @@
"Process additional \`rc.conf.d' entries for service name."
f_err "$optfmt" "" \
"Ignored if \`-f file' is given."
+ f_err "$optfmt" "-U user" \
+ "Run as user inside the jail (jexec -U). Requires \`-j'."
+ f_err "$optfmt" "-u user" \
+ "Run as user from the host password database."
+ f_err "$optfmt" "" \
+ "Passed to jexec -u and chroot -u. Requires \`-j' or \`-R'."
f_err "$optfmt" "-v" \
"Verbose. Print the pathname of the specific rc.conf(5)"
f_err "$optfmt" "" \
@@ -252,7 +260,7 @@
#
# Process command-line flags
#
-while getopts AacDdEeFf:hij:LlNnqR:rs:vXx flag; do
+while getopts AacDdEeFf:hij:LlNnqR:rs:U:u:vXx flag; do
case "$flag" in
A) SHOW_ALL=2 ;;
a) SHOW_ALL=${SHOW_ALL:-1} ;;
@@ -280,6 +288,12 @@
s) [ "$OPTARG" ] ||
die "Missing or null argument to \`-s' flag"
SERVICE="$OPTARG" ;;
+ U) [ "$OPTARG" ] ||
+ die "Missing or null argument to \`-U' flag"
+ JUSER="$OPTARG" ;;
+ u) [ "$OPTARG" ] ||
+ die "Missing or null argument to \`-u' flag"
+ HUSER="$OPTARG" ;;
v) VERBOSE=1 QUIET= ;;
X) DELETE=2 ;;
x) DELETE=${DELETE:-1} ;;
@@ -525,6 +539,15 @@
#
# Process `-j jail' and `-R dir' command-line options
#
+if [ "$HUSER" -a "$JUSER" ]; then
+ die "-u and -U are mutually exclusive"
+fi
+if [ "$HUSER" -a ! "$JAIL" -a ! "$ROOTDIR" ]; then
+ die "-u requires \`-j jail' or \`-R dir'"
+fi
+if [ "$JUSER" -a ! "$JAIL" -a ! "$ROOTDIR" ]; then
+ die "-U requires \`-j jail'"
+fi
if [ "$JAIL" -o "$ROOTDIR" ]; then
#
# Reconstruct the arguments that we want to carry-over
@@ -572,12 +595,16 @@
if [ "$JAIL" ]; then
#
# Re-execute ourselves with sh(1) via jexec(8)
+ # NB: -U looked up in the jail password database, after attach
#
+ set -- "$JAIL"
+ [ "$HUSER" ] && set -- -u "$HUSER" "$@"
+ [ "$JUSER" ] && set -- -U "$JUSER" "$@"
( echo set -- $args
jail_depend
cat $0
) | env - RC_DEFAULTS="$RC_DEFAULTS" \
- /usr/sbin/jexec "$JAIL" /bin/sh
+ /usr/sbin/jexec "$@" /bin/sh
exit $?
elif [ "$ROOTDIR" ]; then
#
@@ -614,26 +641,39 @@
if [ "$jid" ]; then
#
# Re-execute outselves with sh(1) via jexec(8)
+ # NB: -U looked up in the jail, after attach
#
+ set -- "$jid"
+ [ "$HUSER" ] && set -- -u "$HUSER" "$@"
+ [ "$JUSER" ] && set -- -U "$JUSER" "$@"
( echo set -- $args
jail_depend
cat $0
) | env - RC_DEFAULTS="$RC_DEFAULTS" \
- /usr/sbin/jexec "$jid" /bin/sh
+ /usr/sbin/jexec "$@" /bin/sh
exit $?
fi
# Otherwise, fall through and allow chroot(8)
fi
+ #
+ # -U is the jail password lookup. chroot(8) has no equivalent.
+ #
+ if [ "$JUSER" ]; then
+ die "-U requires a running jail (use \`-j jail')"
+ fi
+
#
# Re-execute ourselves with sh(1) via chroot(8)
#
+ set -- "$ROOTDIR"
+ [ "$HUSER" ] && set -- -u "$HUSER" "$@"
( echo set -- $args
jail_depend
cat $0
) | env - RC_DEFAULTS="$RC_DEFAULTS" \
- /usr/sbin/chroot "$ROOTDIR" /bin/sh
+ /usr/sbin/chroot "$@" /bin/sh
exit $?
fi
fi
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
--- a/usr.sbin/sysrc/sysrc.8
+++ b/usr.sbin/sysrc/sysrc.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 18, 2026
+.Dd November 22, 2026
.Dt SYSRC 8
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Op Fl f Ar file
.Op Fl j Ar jail | Fl R Ar dir
.Op Fl s Ar name
+.Op Fl u Ar user | Fl U Ar user
.Ar name Ns Op Ns Oo +|-|. Oc Ns = Ns Ar value
.Ar ...
.Nm
@@ -44,6 +45,7 @@
.Op Fl f Ar file
.Op Fl j Ar jail | Fl R Ar dir
.Op Fl s Ar name
+.Op Fl u Ar user | Fl U Ar user
.Fl A | a
.Nm
.Op Fl E
@@ -178,6 +180,34 @@
Can be combined with
.Sq Fl l
to list configuration files used by service at startup.
+.It Fl U Ar user
+Run inside the jail as
+.Ar user .
+The name is looked up in the jail password database after attach
+.Pq Xr jexec 8 Fl U .
+Requires
+.Fl j ,
+or
+.Fl R
+pointing at a running jail.
+Cannot be combined with
+.Fl u .
+.It Fl u Ar user
+Run as
+.Ar user
+from the host password database.
+Passed to
+.Xr jexec 8
+and
+.Xr chroot 8
+as
+.Fl u .
+Requires
+.Fl j
+or
+.Fl R .
+Cannot be combined with
+.Fl U .
.It Fl v
Verbose.
Print the pathname of the specific
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 23, 11:09 PM (20 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41941773
Default Alt Text
D61930.1795475372.diff (4 KB)
Attached To
Mode
D61930: sysrc: Add -u and -U
Attached
Detach File
Event Timeline