This commit is contained in:
parent
9ef9429511
commit
ff98adf1a6
@ -5,4 +5,5 @@ RUN go build .
|
|||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=builder /source/timetable-mgr /bin/timetable-mgr
|
COPY --from=builder /source/timetable-mgr /bin/timetable-mgr
|
||||||
|
USER nobody
|
||||||
CMD [ "/bin/timetable-mgr" ]
|
CMD [ "/bin/timetable-mgr" ]
|
25
main.go
25
main.go
@ -19,9 +19,19 @@ import (
|
|||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
bold = "\033[1m"
|
||||||
|
redB = "\033[1;31m"
|
||||||
|
blue = "\033[32m" //Actually green!
|
||||||
|
cyan = "\033[36m"
|
||||||
|
reset = "\033[0m"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
printStartupBanner()
|
printStartupBanner()
|
||||||
fmt.Printf("Version %s \n\n", helpers.Version)
|
fmt.Printf("%sVersion %s \n\n%s", bold+blue, helpers.Version, reset)
|
||||||
|
|
||||||
|
checkRunAsRoot()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -110,5 +120,16 @@ func printStartupBanner() {
|
|||||||
|___/
|
|___/
|
||||||
`
|
`
|
||||||
|
|
||||||
fmt.Println(art)
|
fmt.Println(cyan + art + reset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkRunAsRoot() {
|
||||||
|
uid := os.Getuid()
|
||||||
|
if uid != 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(redB + "This program must not be run as the root user" + reset)
|
||||||
|
fmt.Println("")
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user