yellowman / nsh

OpenBSD networking configuration shell
http://www.nmedia.net/nsh/
Other
174 stars 27 forks source link

add a runat command and scripting via the nsh command-line #140

Closed stspdotname closed 1 year ago

stspdotname commented 1 year ago

Add a runat command, which based on at(1), to allow nsh commands to be run at some time in the future. The name "runat" instead of "at" was chosen to avoid conflicts with future commands that begin with "at" (like we saw when "pin" and "ping" when we had to rename the former to "setpin" to disambiguate the two).

To allow for runat to work without having to store nsh commands in a temporary file which would never get removed, extend the nsh command line interface. We now allow an arbitrary list of nsh commands to be provided on the command line if the -i and -c options are not used.

In privileged mode it is possible to use a ! command on the command line to insert arbitrary shell commands within the list of nsh commands to run.

For ease of use, the runat command supports tab-completion for some variants of the timespec syntax of at(1). It does not attempt to tab-complete the list of commands, however, as this would be much too complicated.

Some basic verification of commands to run is performed before a job gets scheduled. For now, we make sure that an internal or external command to run actually exists, and that commands which require privileged mode are scheduled in privileged mode. More verification could be added later as needed.

stspdotname commented 1 year ago

Above force-push removes a new -s option from getopt() which was part of an earlier draft of this change.

smytht commented 1 year ago

Folks in response to Chris Feedabck and Stefans comments and discussion wiht Stefan at length with the challenges of runat with the reexec (enable privileged mode if run as root) and other issues discovered in working on same... Stefan is working on a different approach for the NSH runat command... and wants to improve other aspects of the NSH that will reduce risk associated with implementing this command... Thanks Closing the This PR not merging ...