Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable unprivileged containers #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SphtKr
Copy link

@SphtKr SphtKr commented Jan 18, 2024

This includes two features that make it possible to run unprivileged. 1. Setting the XID range with IDLOWER and IDUPPER (in order to fit within a container-remapped UID range of 0-65535) and 2. Setting ACLSTORAGE to userns which provides some options to the storage modules to record ACL data in a namespace where an unprivileged container can get at it. See changes in README.md for more info.

These changes are based on a significant amount of research and tinkering and may not be 100% correct but they seem to work in the home-lab environment I've tested with so far, feedback welcome.

This includes two features that make it possible to run unprivileged. 1. Setting the XID range with `IDLOWER` and `IDUPPER` (in order to fit within a container-remapped UID range of 0-65535) and 2. Setting `ACLSTORAGE` to `userns` which provides some options to the storage modules to record ACL data in a namespace where an unprivileged container can get at it. See changes in README.md for more info.
@SphtKr
Copy link
Author

SphtKr commented Jan 18, 2024

Some notes:

This change may "conflict" with my previous PRs but the resolution is straightforward.

The ACLSTORAGE option might have some bearing on #19. Also I thought there was at least one issue on unprivileged use but I can't find it now.

I have a few other changes in my current version that are not included here because I think they are out of scope, but could be relevant. The Samba Wiki actually states (in multiple places) that you should "Remove all idmap config parameters in the smb.conf file on DCs." Trying to understand this issue more throughly was difficult and gets into the complexities of Samba's idmap schemes... also version differences matter and it's possible the "bug" described there has since been resolved. However, it at least seems from my research that adding idmap config ${URDOMAIN} : backend = ad to a DC is incorrect and this directive is intended only for member servers and clients. In the Samba DC I am running at the moment, I have removed all the idmap options from init.sh... except for the idmap config * : range = ${IDLOWER}-${IDUPPER} one which I add in this PR...even that one may be incorrect and perhaps only the idmap_init.ldif edits are necessary/sufficient. Discussion welcome.

@SphtKr
Copy link
Author

SphtKr commented Jan 20, 2024

#20 was the ticket I was thinking of that touched on unprivileged use in Kubernetes.

@@ -12,6 +12,9 @@ A well documented, tried and tested Samba Active Directory Domain Controller tha
* `INSECURELDAP` defaults to `false`. When set to true, it removes the secure LDAP requirement. While this is not recommended for production it is required for some LDAP tools. You can remove it later from the smb.conf file stored in the config directory.
* `MULTISITE` defaults to `false` and tells the container to connect to an OpenVPN site via an ovpn file with no password. For instance, if you have two locations where you run your domain controllers, they need to be able to interact. The VPN allows them to do that.
* `NOCOMPLEXITY` defaults to `false`. When set to `true` it removes password complexity requirements including `complexity, history-length, min-pwd-age, max-pwd-age`
* `IDLOWER` The minimum ID to use for user and group IDs within the DC ("XID"s). Defaults to 3000000.
* `IDUPPER` The maximum ID to use for user and group IDs within the DC ("XID"s). Defaults to 3000000.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `IDUPPER` The maximum ID to use for user and group IDs within the DC ("XID"s). Defaults to 3000000.
* `IDUPPER` The maximum ID to use for user and group IDs within the DC ("XID"s). Defaults to 4000000.

@dersell
Copy link

dersell commented Jul 9, 2024

I tried running Samba as a Domain Controller with these patches and it just works - at least the pod spins up successfully. Further configuration and testing pending, I'm just getting started learning Samba and Active Directory.
👍 for getting this merged, so I don't have to build my own image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants