Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
Fix incorrect privileges when upgrading as root
Browse files Browse the repository at this point in the history
  • Loading branch information
datacharmer committed Jun 7, 2020
1 parent 78cffc6 commit b677be9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .build/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.50.1
1.50.2
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.50.2 07-Jun-2020

### BUGS FIXED

* Fix incorrect privileges when updating dbdeployer as root

## 1.50.1 06-Jun-2020

### BUGS FIXED
Expand Down
10 changes: 9 additions & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func updateDbDeployer(cmd *cobra.Command, args []string) {
targetDirectory := newPath
programName := common.BaseName(os.Args[0])

fullProgramName := common.Which(programName)
fileInfo, err := os.Stat(fullProgramName)
if err != nil {
common.Exitf(1, "error retrieving file info for %s", fullProgramName)
}
filePermissions := fileInfo.Mode().Perm()
dbdeployerPath := common.DirName(common.Which(programName))
if targetDirectory == "" {
targetDirectory = dbdeployerPath
Expand Down Expand Up @@ -197,7 +203,9 @@ func updateDbDeployer(cmd *cobra.Command, args []string) {
if verbose {
fmt.Printf("File %s removed\n", tarballName)
}
err = os.Chmod(fileName, globals.ExecutableFileAttr)

// Give the new file the same attributes of the existing dbdeployer executable
err = os.Chmod(fileName, filePermissions)
common.ErrCheckExitf(err, 1, "error changing attributes of %s", fileName)
if currentOS != OS && targetDirectory == dbdeployerPath {
fmt.Printf("OS of the remote file (%s) different from current OS (%s)\n", OS, currentOS)
Expand Down
4 changes: 2 additions & 2 deletions common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package common

// This file was generated during build. Do not edit.
// Build time: 2020-06-06 05:33
// Build time: 2020-06-06 15:16

var VersionDef string = "1.50.1" // 2020-06-06
var VersionDef string = "1.50.2" // 2020-06-06

// Compatible version is the version used to mark compatible archives (templates, configuration).
// It is usually major.minor.0, except when we are at version 0.x, when
Expand Down

0 comments on commit b677be9

Please sign in to comment.