Skip to content

Commit df909ca

Browse files
author
Sander van Harmelen
committed
Fix an issue with sudo and hints
Fixes issue hashicorp#2781
1 parent 009dba1 commit df909ca

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

builtin/provisioners/chef/linux_provisioner.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,29 @@ func (p *Provisioner) linuxCreateConfigFiles(
7171
return err
7272
}
7373

74+
// Make sure we have enough rights to upload the hints if using sudo
75+
if p.useSudo {
76+
if err := p.runCommand(o, comm, "chmod 777 "+hintsDir); err != nil {
77+
return err
78+
}
79+
}
80+
7481
if err := p.deployOhaiHints(o, comm, hintsDir); err != nil {
7582
return err
7683
}
84+
85+
// When done copying the hints restore the rights and make sure root is owner
86+
if p.useSudo {
87+
if err := p.runCommand(o, comm, "chmod 755 "+hintsDir); err != nil {
88+
return err
89+
}
90+
if err := p.runCommand(o, comm, "chown -R root.root "+hintsDir); err != nil {
91+
return err
92+
}
93+
}
7794
}
7895

79-
// When done copying the files restore the rights and make sure root is owner
96+
// When done copying all files restore the rights and make sure root is owner
8097
if p.useSudo {
8198
if err := p.runCommand(o, comm, "chmod 755 "+linuxConfDir); err != nil {
8299
return err

0 commit comments

Comments
 (0)