Commit Briefs

f20a053a00 Stefan Sperling

prevent leading spaces in rdomain-specific daemon config files (conf-indent)

Rules for rdomain-specific daemons have double-indentation in nshrc. When generating configuration files for daemons strip double-indentation instead of stripping only one level of indentation.


d601300890 Stefan Sperling

convert all command handlers to variadic functions (varargs)

Resolves dozens of: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x In traditional C the empty argument list () indicates that a function accepts an arbitrary amount of arguments of arbitary types. A function which takes no arguments must be declared with a (void) prototype instead. nsh has been making elaborate use of this feature by defining command handlers with () and passing arbitrary arguments to handlers depending on the use case. This coding style is not future-proof. In C++, () means "no arguments", the same as (void), and clang is now warning about this C feature going away in C2x, aligning C with C++. Make nsh future-proof by using variadic function prototypes (...) instead of () prototypes. Every handler now uses (int argc, char **argv, ...) as prototype: the argument count, an argument vector, followed by arbitrary arguments which can be extracted using the va_arg(3) function from stdarg.h. The variadic part of the argument list can be used to pass arguments of types other than char * without needing to convert them to strings and back. Using () as function prototype defeats type-checking done by the compiler, and the same is true for variadic arguments. We still need to manually make sure that the correct amount and types of arguments are passed in the variadic part of the handler's argument list. Many handlers already use the argument count + argument vector approach and do not need internal changes, just a new prototype. Some handlers now require use of va_start/va_arg/va_end to access additional arguments. For example, the interfaces handlers were passing an interface name and file descriptor before the argument count/vector. The order of arguments is now swapped, such that interface name and file descriptor get passed as part of the variable argument list.


b96221e6b0 Stefan Sperling

update K&R-C-style prototypes in kroute.c to modern C

Fixes warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x


d3156eb934 Stefan Sperling

implement 'clear' command in interface/bridge mode

resolves warning: unused function 'int_clear' [-Wunused-function]




0b2616cd90 Stefan Sperling

remove struct ctl2 and struct daemons2; convert everything to new format

test + ok Tom


4a206fc917 Stefan Sperling

fix whitespace in systatcs definition in commands.c


809a0cb537 Stefan Sperling

fix initialization of systatcs sentinel in commands.c

Repairs the following compile-time warning: nsh/commands.c:403:17: warning: suggest braces around initialization of subobject [-Wmissing-braces] { 0, 0, 0, 0 } ^~~~ { }



Branches
































Tags

Tree

.gitignorecommits | blame
COPYRIGHTcommits | blame
Makefilecommits | blame
README.mdcommits | blame
arp.ccommits | blame
bgpcommands.ccommits | blame
bgpnsh/
bridge.ccommits | blame
bridge.hcommits | blame
carp.ccommits | blame
cmdargs.ccommits | blame
commands.ccommits | blame
commands.hcommits | blame
compile.shcommits | blame
complete.ccommits | blame
conf.ccommits | blame
ctl.ccommits | blame
ctl.hcommits | blame
ctlargs.ccommits | blame
editing.hcommits | blame
externs.hcommits | blame
genget.ccommits | blame
hashtable.ccommits | blame
helpcommands.ccommits | blame
ieee80211.ccommits | blame
if.ccommits | blame
ip.hcommits | blame
kroute.ccommits | blame
main.ccommits | blame
makeargv.ccommits | blame
mantab.sh*commits | blame
media.ccommits | blame
more.ccommits | blame
nameserver.ccommits | blame
ndp.ccommits | blame
nopt.ccommits | blame
nsh-dist.txtcommits | blame
nsh-version.mkcommits | blame
nsh.8commits | blame
nsh.rccommits | blame
nshdoas/
passwd.ccommits | blame
pflow.ccommits | blame
pfsync.ccommits | blame
ppp.ccommits | blame
prompt.ccommits | blame
route.ccommits | blame
save-ro.sh*commits | blame
save-rw.sh*commits | blame
scripts/
show.ccommits | blame
sqlite3.ccommits | blame
stats.ccommits | blame
stringlist.ccommits | blame
stringlist.hcommits | blame
sysctl.ccommits | blame
sysctl.hcommits | blame
trunk.ccommits | blame
tunnel.ccommits | blame
umb.ccommits | blame
utf8.ccommits | blame
utils.ccommits | blame
version.ccommits | blame
wg.ccommits | blame
who.ccommits | blame

README.md

# nsh 

## network shell

---
Author and Founder of the project: Chris Cappuccio <chris@nmedia.net>

NSH is a CLI intended for OpenBSD-based network appliances. It replaces
ifconfig, sysctl and route with its own simple command language, and
encapsulates configuration for other daemons into one place, effectively
replacing /etc/netstart and parts of /etc/rc for appliance-style usage.

## Daemons and services encapsulated by nsh:

bgpd, dhcpd, dhcpleased, dhcrelay, dvmrpd, eigrpd, ftp-proxy, ifstated, inetd, 
iked, ipsecctl, ldapd, ldpd, npppd, ntpd, ospfd, ospf6d, pf, rad, relayd, 
resolvd, ripd, sasyncd, slaacd, smtpd, snmpd, sshd, tftpd, tftp-proxy.

---

## License 

NSH is freely licensed, in the BSD style.

In conjunction with the OpenBSD kernel and the daemons you wish to control,
you have a fully functioning network appliance type of system.

---

## NSH Manual

See [https://github.com/yellowman/nsh/wiki/NSH-Manual-page](https://github.com/yellowman/nsh/wiki/NSH-1.2.x-Manual-Page) 
or nsh.8 manual for detailed installation instructions and command set.

nsh manual is available on your system shell by simply typing the command:

```shell
 man nsh
```

---

## Manual pages from within NSH

For your convenience we have included handy manual page search  for commonly 
used network functionality. 

this feature is available in nsh by simply typing the command:

```shell
manual [searchterm]
```
E.g. searching vlan functionality 

```shell
manual vlan
```

The system also gives a list of searchable terms through double tab completion.

---

## Other Relevant NSH Documentation
See the to-do list on https://github.com/users/yellowman/projects/1 for 
details on implementation status and future ideas.

See http://github.com/yellowman/nsh/ for current source code repository.
See http://www.nmedia.net/nsh/ for example configurations and mailing
list.

See https://www.youtube.com/watch?v=9T9-v5NLjXk for a BSDCAN 2024 
Presentation on Supporting Business IT and network needs with OpenBSD and NSH By: Tom Smyth

See https://www.youtube.com/watch?v=WMKxIHaWaG0 for an EurobsdCon 2022 
Presentation on NSH for network administrators By: Tom Smyth 

---

## Quickstart Guide for installing and building **nsh** on an OpenBSD system

1. Install OpenBSD on your system  by running the following commands in your system shell

2. Install the OpenBSD port of nsh on your system (this will install the latest nsh release version)
```shell
pkg_add nsh  
```

3. Install git on your system to allow fetching more recent versions of nsh from github
```shell
pkg_add git
```

4. To download the latest development of nsh use git to download the latest nsh repository
```shell
git clone https://github.com/yellowman/nsh
```

5. Change directory to the downloaded nsh directory
```shell
cd nsh
```

6. Run make to build / compile the sources
```shell
make
```

7. Install the compiled nsh binaries and supporting files (you will need root privileges to do this).
```shell
make install
```

8. To have nsh take over the configuration of a system a number of steps that need to be carried out such as

9. Backup configuration of system, daemons and network in /etc 

10. Copy the configuration files to /var/run/example-configfilename.0  (the .0 file extension) implies running in the default rdomain / rtable (rdomain 0)

11. save the running config to /etc/nshrc

12. secure the /etc/nshrc file so that world cannot read, write or execute it . 

13. configure the system to run nsh -i /etc/nshrc  either adding a line to /etc/rc.local or using an rccctl script for nsh.

  For the users convenience, the above steps (9-13) can be largely automated by running  the **rc.local-nsh-openbsd-integrate.sh** script  in your system shell
  and following on screen instructions.

- If you have downloaded nsh via git you can run the integration script as follows 
```shell
cd nsh
cd scripts/shell
sh ./rc.local-nsh-openbsd-integrate.sh
```

- If you have installed nsh via the OpenBSD ports package you can run the integration script as follows
```shell
cd /usr/local/share/exampes/nsh
cd scripts/shell
sh ./rc.local-nsh-openbsd-integrate.sh
```

14. once configuration has been imported, restart the system and verify nsh config is running as expected.

15. Setting NSH as the default shell for a user

- Login as the user
- locate nsh binary, it is usually in /usr/local/bin/nsh
- at the command prompt run chsh -s command to set the shell to path to the nsh binary
by running the following command in your system shell
```shell
chsh -s /usr/local/bin/nsh
```

16. please provide feedback , bug repots and suggestions to the developers on	our mailing list  <nsh@lists.deschutesdigital.com> .