Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Autoupdate: check uid before restart service.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesovsky committed May 5, 2021
1 parent 449f4c6 commit 19cf058
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/packaging/autoupdate/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ func updateBinary(sourceFile string, destFile string) error {

// restartSystemdService checks privileges and restarts pgscv service.
func restartSystemdService() error {
if os.Geteuid() != 0 {
return fmt.Errorf("root privileges required")
}

cmd := exec.Command("systemctl", "restart", "pgscv.service")
// after cmd.Start execution of this code could be interrupted, end even err might not be handled.
err := cmd.Start()
Expand Down

0 comments on commit 19cf058

Please sign in to comment.