Merge pull request #2793 from svanharmelen/b-chef-sudo
provisioner/chef: fix error when uploading `hints` when using `sudo`
This commit is contained in:
commit
a6183212db
|
@ -71,12 +71,29 @@ func (p *Provisioner) linuxCreateConfigFiles(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.deployOhaiHints(o, comm, hintsDir); err != nil {
|
// Make sure we have enough rights to upload the hints if using sudo
|
||||||
|
if p.useSudo {
|
||||||
|
if err := p.runCommand(o, comm, "chmod 777 "+hintsDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When done copying the files restore the rights and make sure root is owner
|
if err := p.deployOhaiHints(o, comm, hintsDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// When done copying the hints restore the rights and make sure root is owner
|
||||||
|
if p.useSudo {
|
||||||
|
if err := p.runCommand(o, comm, "chmod 755 "+hintsDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := p.runCommand(o, comm, "chown -R root.root "+hintsDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// When done copying all files restore the rights and make sure root is owner
|
||||||
if p.useSudo {
|
if p.useSudo {
|
||||||
if err := p.runCommand(o, comm, "chmod 755 "+linuxConfDir); err != nil {
|
if err := p.runCommand(o, comm, "chmod 755 "+linuxConfDir); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -166,6 +166,9 @@ func TestResourceProvider_linuxCreateConfigFiles(t *testing.T) {
|
||||||
"sudo mkdir -p " + linuxConfDir: true,
|
"sudo mkdir -p " + linuxConfDir: true,
|
||||||
"sudo chmod 777 " + linuxConfDir: true,
|
"sudo chmod 777 " + linuxConfDir: true,
|
||||||
"sudo mkdir -p " + path.Join(linuxConfDir, "ohai/hints"): true,
|
"sudo mkdir -p " + path.Join(linuxConfDir, "ohai/hints"): true,
|
||||||
|
"sudo chmod 777 " + path.Join(linuxConfDir, "ohai/hints"): true,
|
||||||
|
"sudo chmod 755 " + path.Join(linuxConfDir, "ohai/hints"): true,
|
||||||
|
"sudo chown -R root.root " + path.Join(linuxConfDir, "ohai/hints"): true,
|
||||||
"sudo chmod 755 " + linuxConfDir: true,
|
"sudo chmod 755 " + linuxConfDir: true,
|
||||||
"sudo chown -R root.root " + linuxConfDir: true,
|
"sudo chown -R root.root " + linuxConfDir: true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue