Directory Permissions with Local Users #181
Replies: 3 comments 4 replies
-
This is a good point, thanks for bringing it up. Currently, the operator and the samba instance pods don't really do anything to ensure that the permissions on the pvc are usable, they just take whatever is available. I think but I have not double checked that the default permissions vary depending on what provisioned the PVC. I usually test with ceph based volumes using rook,etc and I think that the permissions I get by default are permissive. But IIRC when I used a cloud provider's volume provisioner directly once I had to tweak the permissions first. We haven't invested much time into permissions yet because we've been pushing for enhancements to samba to permit the use of NT-style ACLs without the use of the security xattr namespace because we don't want to require the containers to run with the CAP_SYS_ADMIN capability. But I'd be open to improving sambacc and the operator to improve permissions support in the near-term. I'd be very welcome to contributions in the area too! :-) |
Beta Was this translation helpful? Give feedback.
-
Understanding that this issue wasn't cockpit error I have dug in a bit more on what should be the desired behavior. At the heart of the issue is that permissions need to be set on the CSI mounted point as the pod is getting started. The question is who (or what role) should set what GID? Starting with 'who' I don't think AD or DC is the best path through sambacc since the pod isn't running. We could give temporary ownership to a GID that then gets update when the container starts and has AD access. Then Active Directory is the who with some schema for associating mount GIDs to shares. This feels like adding unwanted complexity for limited security gains. Without AD we are left with the node's LDAP local user management or Kubernetes security context. Banking on LDAP seems like it could limit some deployments. My logic thus far then is to have the 'who' be the K8s orchestrator for the mount permission and then AD or local user definitions can manage all file level permissions below. Since we don't want the fsgroup to be set recursively, wiping out user permissions, then I think we should plan on using the set fsgroup enhancement: https://github.com/gnufied/enhancements/blob/master/keps/sig-storage/2317-fsgroup-on-mount/README.md Now to what GID? Are GID collisions of shared pools of storage a multitenancy issue or attack surface? Not sure yet. If we let the human pick any a GID like 1234 then I believe the PVC definition needs to have fsgroup=1234 and the pod started by the operator needs the runAsGroup=1234. Then I thing the change to SIK is adding a runasgroup parameter to the smbShare CRD. Does this sound close to right? |
Beta Was this translation helpful? Give feedback.
-
I've hit the same problem using minikube and rook. The permission of the mount point was set to 0755. This change seems to be recent. Earlier versions of my cluster had the mount point set to 0777. Setting the mode to 0777 allowed me to write to the share as expected. |
Beta Was this translation helpful? Give feedback.
-
When configuring security to use local users, I see the two users I defined get created as local users to the pod created by the operator for the SmbShare CRD. What seems to be missing, or a mistake in my configuration, is updating file system permissions for the PVC mounted in under /mnt. After applying the yaml below I can connect to the share using either user but can not write to it because neither of my users have write permissions. I can exec in and chown or chmod to grant write access but this seems like I'm missing something. What is the intended method? It seems like the group of local users should be created by the operator and set for write access when the share is creates for the CRD.
apiVersion: v1
kind: Secret
metadata:
name: labsambausersWhen configuring security to use local users, I see the two users I defined get created as local users to the pod created by the operator for the SmbShare CRD. What seems to be missing, or a mistake in my configuration, is updating file system permissions for the PVC mounted in under /mnt. After applying the yaml below I can connect to the share using either user but can not write to it because neither of my users have write permissions. I can exec in and chown or chmod to grant write access but this seems like I'm missing something. What is the intended method? It seems like the group of local users should be created by the operator and set for write access when the share is creates for the CRD.
apiVersion: v1
kind: Secret
metadata:
name: labsambausers
type: Opaque
stringData:
demousers: |
{
"samba-container-config": "v0",
"users": {
"all_entries": [
{
"name": "demo",
"password": "demo"
},
{
"name": "webber",
"password": "webber"
}
]
}
}
apiVersion: samba-operator.samba.org/v1alpha1
kind: SmbSecurityConfig
metadata:
name: myusers
spec:
mode: user
users:
secret: labsambausers
key: demousers
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: sambainlab
spec:
accessModes:
volumeMode: Filesystem
storageClassName: simpleclass
resources:
requests:
storage: 7Gi
apiVersion: samba-operator.samba.org/v1alpha1
kind: SmbShare
metadata:
name: labshare
spec:
securityConfig: myusers
storage:
pvc:
name: "sambainlab"
readOnly: false
type: Opaque
stringData:
demousers: |
{
"samba-container-config": "v0",
"users": {
"all_entries": [
{
"name": "demo",
"password": "demo"
},
{
"name": "webber",
"password": "webber"
}
]
}
}
apiVersion: samba-operator.samba.org/v1alpha1
kind: SmbSecurityConfig
metadata:
name: myusers
spec:
mode: user
users:
secret: labsambausers
key: demousers
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: sambainlab
spec:
accessModes:
volumeMode: Filesystem
storageClassName: simpleclass
resources:
requests:
storage: 7Gi
apiVersion: samba-operator.samba.org/v1alpha1
kind: SmbShare
metadata:
name: labshare
spec:
securityConfig: myusers
storage:
pvc:
name: "sambainlab"
readOnly: false
Beta Was this translation helpful? Give feedback.
All reactions