Skip to content

Commit 324b529

Browse files
authored
Fixing double sync issue file permission issue (#118)
1 parent 2f0f21c commit 324b529

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

internal/flypg/pg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func (c *PGConfig) initialize() error {
249249
}
250250

251251
func (c *PGConfig) writePGConfigEntries(entries []string) error {
252-
file, err := os.Create(c.configFilePath)
252+
file, err := os.OpenFile(c.configFilePath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
253253
if err != nil {
254254
return err
255255
}

internal/flypg/repmgr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (r *RepMgr) initialize() error {
124124
return fmt.Errorf("failed to set repmgr.conf ownership: %s", err)
125125
}
126126

127-
return file.Sync()
127+
return nil
128128
}
129129

130130
func (r *RepMgr) setup(ctx context.Context, conn *pgx.Conn) error {
@@ -236,7 +236,7 @@ func (r *RepMgr) clonePrimary(ipStr string) error {
236236

237237
func (r *RepMgr) writePasswdConf() error {
238238
path := "/data/.pgpass"
239-
file, err := os.Create(path)
239+
file, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0600)
240240
if err != nil {
241241
return fmt.Errorf("failed to open repmgr password file: %s", err)
242242
}

internal/flypg/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func restoreHBAFile() error {
160160
}
161161

162162
func setRestoreLock() error {
163-
file, err := os.Create(restoreLockFile)
163+
file, err := os.OpenFile(restoreLockFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
164164
if err != nil {
165165
return err
166166
}

0 commit comments

Comments
 (0)