From dffb53268a59977227cb6321dac45e0a78fc3709 Mon Sep 17 00:00:00 2001 From: Phan Le Date: Wed, 6 Mar 2024 19:57:55 -0800 Subject: [PATCH] Automatically add Longhorn device to the group id 6 (disk group) by default More explanation is at https://github.com/longhorn/longhorn/issues/8088#issuecomment-1982300242 longhorn-8088 Signed-off-by: Phan Le --- util/util.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/util.go b/util/util.go index 220b120..ca4c96d 100644 --- a/util/util.go +++ b/util/util.go @@ -310,6 +310,11 @@ func DuplicateDevice(dev *KernelDevice, dest string) error { if err := os.Chmod(dest, 0660); err != nil { return errors.Wrapf(err, "cannot change permission of the device %s", dest) } + // We use the group 6 by default because this is common group for disks + // See more at https://github.com/longhorn/longhorn/issues/8088#issuecomment-1982300242 + if err := os.Chown(dest, 0, 6); err != nil { + return errors.Wrapf(err, "cannot change ownership of the device %s", dest) + } return nil }