Fix sticky bit handling in default mode
This commit is contained in:
parent
a861bb5e7c
commit
3e28d45a41
|
|
@ -295,7 +295,7 @@ spec:
|
|||
|
||||
**Step 8: Controlling the permissions and ownership of subdirs**
|
||||
|
||||
By default new directories will be created with `root:root` ownership, and `0777` permissions in most environments. If you have a need to control this, you can do so by providing the `NFS_DEFAULT_MODE`, `NFS_DEFAULT_UID` and `NFS_DEFAULT_GID` environment variables (or the appropriate configuration in the Helm chart values). The mode must be an octal representation of a file mode, for example `777`, `0755` etc. The uid and gid must be the numeric ids of your desired user and group, so `1000` not `my_user`.
|
||||
By default new directories will be created with `root:root` ownership, and `0777` permissions in most environments. If you have a need to control this, you can do so by providing the `NFS_DEFAULT_MODE`, `NFS_DEFAULT_UID` and `NFS_DEFAULT_GID` environment variables (or the appropriate configuration in the Helm chart values). The mode must be an octal representation of a file mode, for example `777`, `0755`, `2750` etc. The uid and gid must be the numeric ids of your desired user and group, so `1000` not `my_user`.
|
||||
|
||||
If your usecase requires per-PVC ownership and/or mode, this can be done via annotations on your PVC:
|
||||
|
||||
|
|
|
|||
|
|
@ -258,10 +258,20 @@ func getModeFromString(mode string) (os.FileMode, error) {
|
|||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid mode %s: %v", mode, err)
|
||||
}
|
||||
if modeInt < 0 || modeInt > 0o777 {
|
||||
return 0, fmt.Errorf("mode must be between 0 and 0777, got %s", mode)
|
||||
if modeInt < 0 || modeInt > 0o7777 {
|
||||
return 0, fmt.Errorf("mode must be between 0 and 07777, got %s", mode)
|
||||
}
|
||||
return os.FileMode(modeInt), nil
|
||||
fileMode := os.FileMode(modeInt & 0o777)
|
||||
if modeInt&0o4000 != 0 {
|
||||
fileMode |= os.ModeSetuid
|
||||
}
|
||||
if modeInt&0o2000 != 0 {
|
||||
fileMode |= os.ModeSetgid
|
||||
}
|
||||
if modeInt&0o1000 != 0 {
|
||||
fileMode |= os.ModeSticky
|
||||
}
|
||||
return fileMode, nil
|
||||
}
|
||||
|
||||
func getIdFromString(id string) (int, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue