Skip to content

Commit

Permalink
Merge: * auto-upgrade: don't show Upgrade button on UNIX if running u…
Browse files Browse the repository at this point in the history
…nder non-root user

Close #1193

* commit '58f183103248d3efd7e94551ffaebc5df3689ac0':
  * auto-upgrade: don't show Upgrade button on UNIX if running under non-root user
  • Loading branch information
szolin committed Mar 18, 2020
2 parents 3303d77 + 58f1831 commit 7ff743a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion home/control_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,23 @@ func getVersionResp(data []byte) []byte {
}
_, ok := versionJSON[dloadName]
if ok && ret["new_version"] != versionString && versionString >= selfUpdateMinVersion {
ret["can_autoupdate"] = true
canUpdate := true

tlsConf := tlsConfigSettings{}
Context.tls.WriteDiskConfig(&tlsConf)

if runtime.GOOS != "windows" &&
((tlsConf.Enabled && (tlsConf.PortHTTPS < 1024 || tlsConf.PortDNSOverTLS < 1024)) ||
config.BindPort < 1024 ||
config.DNS.Port < 1024) {
// On UNIX, if we're running under a regular user,
// but with CAP_NET_BIND_SERVICE set on a binary file,
// and we're listening on ports <1024,
// we won't be able to restart after we replace the binary file,
// because we'll lose CAP_NET_BIND_SERVICE capability.
canUpdate, _ = util.HaveAdminRights()
}
ret["can_autoupdate"] = canUpdate
}

d, _ := json.Marshal(ret)
Expand Down

0 comments on commit 7ff743a

Please sign in to comment.