From 011f6d161ba5f62b756a6f18a0104742fd0f73b8 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Wed, 27 Jun 2018 19:28:03 -0700 Subject: [PATCH] #3: hkexshd: server should output error on startup if not run w/sufficient privileges Signed-off-by: Russ Magee --- hkexshd/hkexshd.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hkexshd/hkexshd.go b/hkexshd/hkexshd.go index bae163e..5fbb77e 100644 --- a/hkexshd/hkexshd.go +++ b/hkexshd/hkexshd.go @@ -200,6 +200,13 @@ func main() { 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 // anycast IP addresses of the local system. l, err := hkexsh.Listen("tcp", laddr)