Skip to content

Commit 21f845b

Browse files
author
mx
committed
fixed filesystem permissions for image library
1 parent b2ec38a commit 21f845b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/libvirtclient/client.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"os"
1111
"strings"
12+
"syscall"
1213
)
1314

1415
// Constants for the managed image library
@@ -456,6 +457,20 @@ func copyFile(src, dst string) error {
456457
return fmt.Errorf("failed to sync destination file: %w", err)
457458
}
458459

460+
// Fix ownership for libvirt access - inherit from parent directory
461+
if parentInfo, err := os.Stat(flintImagePoolPath); err == nil {
462+
if stat, ok := parentInfo.Sys().(*syscall.Stat_t); ok {
463+
if err := os.Chown(dst, int(stat.Uid), int(stat.Gid)); err != nil {
464+
return fmt.Errorf("failed to set file ownership: %w", err)
465+
}
466+
}
467+
}
468+
469+
// Set proper permissions for libvirt access
470+
if err := os.Chmod(dst, 0644); err != nil {
471+
return fmt.Errorf("failed to set file permissions: %w", err)
472+
}
473+
459474
return nil
460475
}
461476

0 commit comments

Comments
 (0)