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

nixos/ldap: set proper User= and Group= for nslcd service #58419

Merged
merged 2 commits into from Mar 28, 2019

Conversation

flokli
Copy link
Contributor

@flokli flokli commented Mar 27, 2019

Motivation for this change

eb90d97 broke nslcd, as /run/nslcd was
created/chowned as root user, while nslcd wants to do parts as nslcd
user.

This commit changes the nslcd to run with the proper uid/gid from the
start (through User= and Group=), so the RuntimeDirectory has proper
permissions, too.

In some cases, secrets are baked into nslcd's config file during startup
(so we don't want to provide it from the store).

This config file is normally hard-wired to /etc/nslcd.conf, but we don't
want to use PermissionsStartOnly anymore (#56265), and activation
scripts are ugly, so redirect /etc/nslcd.conf to /run/nslcd/nslcd.conf,
which now gets provisioned inside ExecStartPre=.

This change requires the files referenced to in
users.ldap.bind.passwordFile and users.ldap.daemon.rootpwmodpwFile to be
readable by the nslcd user (in the non-nslcd case, this was already the
case for users.ldap.bind.passwordFile)

fixes #57783

In addition, this renames users.ldap.daemon.rootpwmodpw to users.ldap.daemon.rootpwmodpwFile and users.ldap.bind.password to users.ldap.bind.passwordFile (as it's really files). I added a mkRenamedOptionModule for users.ldap.bind.password, but users.ldap.daemon.rootpwmodpw wasn't yet part of a release.

Should be backported to 19.03. / cc @samueldr @lheckemann

cc @ju1m

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

users.ldap.daemon.rootpwmodpw -> users.ldap.daemon.rootpwmodpwFile
users.ldap.bind.password -> users.ldap.bind.passwordFile

as users.ldap.daemon.rootpwmodpw never was part of a release, no
mkRenamedOptionModule is introduced.
@flokli flokli requested review from Mic92 and srhb March 27, 2019 02:02
@flokli flokli requested a review from infinisil as a code owner March 27, 2019 02:02
@flokli
Copy link
Contributor Author

flokli commented Mar 27, 2019

@GrahamcOfBorg test ldap

@flokli
Copy link
Contributor Author

flokli commented Mar 28, 2019

@GrahamcOfBorg test ldap

eb90d97 broke nslcd, as /run/nslcd was
created/chowned as root user, while nslcd wants to do parts as nslcd
user.

This commit changes the nslcd to run with the proper uid/gid from the
start (through User= and Group=), so the RuntimeDirectory has proper
permissions, too.

In some cases, secrets are baked into nslcd's config file during startup
(so we don't want to provide it from the store).

This config file is normally hard-wired to /etc/nslcd.conf, but we don't
want to use PermissionsStartOnly anymore (NixOS#56265), and activation
scripts are ugly, so redirect /etc/nslcd.conf to /run/nslcd/nslcd.conf,
which now gets provisioned inside ExecStartPre=.

This change requires the files referenced to in
users.ldap.bind.passwordFile and users.ldap.daemon.rootpwmodpwFile to be
readable by the nslcd user (in the non-nslcd case, this was already the
case for users.ldap.bind.passwordFile)

fixes NixOS#57783
@flokli
Copy link
Contributor Author

flokli commented Mar 28, 2019

@GrahamcOfBorg test ldap

Copy link
Member

@lheckemann lheckemann left a comment

Choose a reason for hiding this comment

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

👍 also for backporting.

@flokli flokli merged commit 6670b4c into NixOS:master Mar 28, 2019
@flokli flokli deleted the ldap-nslcd-startup branch March 28, 2019 13:36
@flokli
Copy link
Contributor Author

flokli commented Mar 28, 2019

backported to 19.03 in 9eafdb4 and 8ae24ed.

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

Successfully merging this pull request may close these issues.

LDAP test is broken in master and 19.03
3 participants