#3: hkexshd: server should output error on startup if not run w/sufficient privileges

Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
Russ Magee 2018-06-27 19:28:03 -07:00
parent dac467c1e6
commit 011f6d161b
1 changed files with 7 additions and 0 deletions

View File

@ -200,6 +200,13 @@ func main() {
log.SetOutput(ioutil.Discard) log.SetOutput(ioutil.Discard)
} }
{
me, e := user.Current()
if e != nil || me.Uid != "0" {
log.Fatal("Must run as root.")
}
}
// Listen on TCP port 2000 on all available unicast and // Listen on TCP port 2000 on all available unicast and
// anycast IP addresses of the local system. // anycast IP addresses of the local system.
l, err := hkexsh.Listen("tcp", laddr) l, err := hkexsh.Listen("tcp", laddr)