Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ceph.conf world-readable #227

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions microceph/ceph/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func Bootstrap(s common.StateInterface) error {
"monitors": s.ClusterState().Address().Hostname(),
"addr": s.ClusterState().Address().Hostname(),
},
0644,
)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions microceph/ceph/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func updateConfig(s common.StateInterface) error {
"ipv4": strings.Contains(address, "."),
"ipv6": strings.Contains(address, ":"),
},
0644,
)
if err != nil {
return fmt.Errorf("Couldn't render ceph.conf: %w", err)
Expand All @@ -228,6 +229,7 @@ func updateConfig(s common.StateInterface) error {
"name": "client.admin",
"key": config["keyring.client.admin"],
},
0640,
)
if err != nil {
return fmt.Errorf("Couldn't render ceph.client.admin.keyring: %w", err)
Expand Down
5 changes: 2 additions & 3 deletions microceph/ceph/configwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ func (c *Config) GetPath() string {
return filepath.Join(c.configDir, c.configFile)
}

// WriteConfig writes the configuration file given a data bag
func (c *Config) WriteConfig(data map[string]any) error {
mode := int(0640) // rw: user, r: group, others: none.
// WriteConfig writes the configuration file given a data bag and a filemode
func (c *Config) WriteConfig(data map[string]any, mode int) error {
fd, err := os.OpenFile(c.GetPath(), os.O_CREATE|os.O_TRUNC|os.O_RDWR, os.FileMode(mode))
if err != nil {
return fmt.Errorf("Couldn't write %s: %w", c.configFile, err)
Expand Down
3 changes: 3 additions & 0 deletions microceph/ceph/configwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (s *configWriterSuite) TestWriteCephConfig() {
"monitors": "foohost",
"addr": "foohost",
},
0644,
)
assert.Equal(s.T(), nil, err)
// Check that the file exists
Expand All @@ -49,6 +50,7 @@ func (s *configWriterSuite) TestWriteRadosGWConfig() {
map[string]any{
"monitors": "foohost",
},
0644,
)
assert.Equal(s.T(), nil, err)
// Check that the file exists
Expand All @@ -68,6 +70,7 @@ func (s *configWriterSuite) TestWriteCephKeyring() {
"name": "client.admin",
"key": "secretkey",
},
0644,
)
assert.Equal(s.T(), nil, err)
// Check that the file exists and has the right contents
Expand Down
1 change: 1 addition & 0 deletions microceph/ceph/rgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func EnableRGW(s common.StateInterface, port int) error {
"monitors": s.ClusterState().Address().Hostname(),
"rgwPort": port,
},
0644,
)
if err != nil {
return err
Expand Down
Loading