From 75215f0d28f0a7ba2dba3863381e8c9c63930faf Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 14 Nov 2010 13:41:30 -0500 Subject: [PATCH] * Properly expand the tilde in paths, as well as other shell variables. * Do not start the server on an invalid port. --- src/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.go b/src/main.go index 2671e13..2a90f12 100644 --- a/src/main.go +++ b/src/main.go @@ -12,6 +12,8 @@ package main import ( "flag" "fmt" + "os" + "strings" "./config" "./paths" "./server" @@ -28,6 +30,8 @@ func main() { var configuration = new(config.Configuration) fmt.Printf("Reading configuration from %v\n", *configPath) if len(*configPath) > 0 { + *configPath = strings.Replace(*configPath, "~", "$HOME", 1) + *configPath = os.ShellExpand(*configPath) error := config.ReadFromFile(*configPath, configuration) if error != nil { fmt.Printf("Error while reading configuration: %v\n", error) @@ -42,6 +46,11 @@ func main() { configuration.Port = *port } + if configuration.Port == 0 { + fmt.Printf("Failed to start server (invalid port)\n") + os.Exit(1) + } + // Run the server. fmt.Printf("Starting Armadillo on port %d with root:\n %v\n", configuration.Port, configuration.JailRoot) -- 2.43.5