commit - b0b69440cc3f1f8127d3b6f341eb0e61116f7918
commit + 73decf344937417c8419f0ef30936f105b3b2ed0
blob - d5ba7949d72cc6a35d217e62c9bc32fbcc22f9c5
blob + c9db309076e09acdd713fbdfca7542d75872d607
--- nsh.8
+++ nsh.8
.Ss INTERACTIVE FEATURES
When run without any command line arguments,
.Nm
-presents an unprivileged shell to the user.
+presents an interactive shell to the user.
+If
+.Nm
+is run as root user then
+.Nm
+shall start as a privileged full functionality shell.
+If
+.Nm
+is run as a non-root user then
+.Nm
+shall start as an unprivileged and limited functionality shell.
+Privileged
+.Nm
+shell functionality can be enabled using the
+.Cm enable
+command.
+.Pp
All
.Nm
interactive command line modes allow basic command line editing features from
.Ic sasync
daemon is documented in
.Xr sasyncd.conf 5 .
-.Pp
.Bd -literal -offset indent
nsh(config-p)/sasync
% Arguments may be abbreviated
.Pp
.Ic show environment Op Ar NAME
.Pp
-Display environment variables.
+Display environment variables.
If the
.Ar NAME
of a variable is specified then display the value of this variable.
Set the environment variable
.Ar NAME
to the specified
-.Ar VALUE.
+.Ar VALUE
+.
If a
.Ar NAME
or
.Cm setenv
are valid for the current session and will be inherited to
other programs started by
-.Nm .
+.Nm
+.
The
.Cm saveenv
command can be used to persist variables set by
.Pa ~/.nshenv .
.Pp
.Tg unsetenv
-.Pp
.Ic unsetenv Ar NAME
.Pp
Delete the variable
as well.
.Pp
.Tg saveenv
-.Pp
.Ic saveenv
.Pp
Save variables set by the
the root password.
A user can abuse
.Nm
-running as root to run arbitrary commands with the
-.Cm !
+running as root to run arbitrary commands with the !
shell escape syntax.
+.Pp
+e.g.
+.Bd -literal -offset indet
+nsh(p)/!adduser new-unauthorised-user
+.Ed
+.Pp
Access to root privileges must be restricted to trusted users only.
.Pp
*NB End Security Warning
as root via
.Xr doas 1
with arbitrary arguments:
-.Ed
.Bd -literal -offset indent
permit keepenv stacy as root cmd /usr/local/bin/nsh
.Ed
The user stacy can now start
.Nm
via doas with an arbitrary amount of arguments:
-.Pp
.Bd -literal -offset indent
doas /usr/local/bin/nsh ...
.Ed
a single username (the colon before the group name is required by
.Xr doas.conf 5
syntax and signifies a group name argument):
-.Pp
.Bd -literal -offset indent
permit keepenv :nshusers as root cmd /usr/local/bin/nsh args -e
.Ed
file that should be displayed.
Defaults to
.Pa /usr/local/man/man8/nsh.8
-.Pp
.Sh FILES
.Bl -tag -width /etc/suid_profile -compact
.It Pa /etc/nshrc