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

freeipa: init at 4.4.3 #22789

Closed
wants to merge 7 commits into from
Closed

Conversation

outergod
Copy link
Contributor

@outergod outergod commented Feb 14, 2017

libverto: init at 0.2.6
pythonPackages.nss: init at 1.0.0
pythonPackages.pki: init at 10.3.5
pythonPackages.lesscpy: init at 0.12.0
pythonPackages.python-yubico: init at 1.3.2

Changed bind to optionally build with Kerberos support.
Changed krb5 to build with system libverto by default.

Motivation for this change

This changeset contains all packages and other changes to turn NixOS into a fully capable, well-behaving FreeIPA client and domain member. While only the client portion of FreeIPA is fully implemented, some of the work for building the server component has also been done to actually make the client build succeed.

FreeIPA needs several packages to be build with MIT Kerberos, which in turn needs to use a newer version of libverto than the one bundled with krb5. Because of transitive dependencies, Samba 4 also needs to be build with that same version of MIT Kerberos. The changeset takes a stance that krb5 should much rather always be built with system libverto, which will trigger a mass-rebuild but save time and space in the long run because no duplicate versions of krb5 dependents are needed.
Building with libverto is explicitly switched off for fetchurl's curl derivation to prevent a circular dependency.

The usual way to join a host to IPA is via freeipa-client-install, which normally modifies and backs up many different files in /etc, which is not possible on NixOS, for obvious reasons. Therefore, I created a nix module that does the same job idiomatically. The only manual steps for a user is to prefetch the certificate from the server and specify the resulting hash in the configuration, as seen below. After activating the configuration, they need to join the domain and obtain the keytab file manually, for which multiple different methods exist, with the most common one presented in the build output.

A typical, a valid set of FreeIPA configuration looks like this:

{
  networking.hostName = "nixos.in.foo.com";

  ipa = {
    enable = true;
    domain = "in.foo.com";
    realm  = "IN.FOO.COM";
    server = "ipa.in.foo.com";
    basedn = "dc=in,dc=foo,dc=com";
    certificate = pkgs.fetchurl {
      url = http://ipa.in.foo.com/ipa/config/ca.crt;
      sha256 = "xxx";
    };
  };
  
  services.sssd.enable = true;
  services.ntp.enable = true;
  security.pam.services.login.makeHomeDir = true;  
  security.pam.services.su.makeHomeDir = true;
}

The easiest way to test this is to create and set up a FreeIPA instance in a Fedora VM or docker container and build a NixOS version via nixos-container, bind-mounting nixpkgs like so:

sudo nixos-container create ipa-test
sudo mkdir -p /nix/var/nix/profiles/per-container/ipa-test/per-user/root/channels/nixos
sudo mount --bind /path/to/nixpkgs /nix/var/nix/profiles/per-container/ipa-test/per-user/root/channels/nixos
sudo nixos-container start ipa-test
ln -s /path/to/nixpkgs /path/to/nixpkgs/nixpkgs # Yes, this is required!
sudo nixos-container root-login ipa-test
ipa-test> nix-prefetch-url http://ipa.in.foo.com/ipa/config/ca.crt
ipa-test> cat > /etc/nixos/configuration.nix <<'EOF'
{ config, lib, pkgs, ... }:

with lib;

{ boot.isContainer = true;
  networking.hostName = "ipa-test.in.foo.com";
  networking.useDHCP = false;

  ipa = {
    enable = true;
    domain = "in.foo.com";
    realm  = "IN.FOO.COM";
    server = "ipa.in.foo.com";
    basedn = "dc=in,dc=foo,dc=com";
    certificate = pkgs.fetchurl {
      url = http://ipa.in.foo.com/ipa/config/ca.crt;
      sha256 = "xxx";
    };
  };
  
  services.sssd.enable = true;
  services.ntp.enable = true;
  security.pam.services.login.makeHomeDir = true;  
  security.pam.services.su.makeHomeDir = true;
}
EOF

ipa-test> nixos-rebuild switch

I'm well aware this is not a trivial change but I believe the benefit makes up for it and I'm grateful for reviewers who feel like they could tackle this.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@e-user, thanks for your PR! By analyzing the history of the files in this pull request, we identified @dezgeg, @peti, @edolstra and @FRidh to be potential reviewers.

pkgs/os-specific/linux/freeipa/default.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/python-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/python-packages.nix Outdated Show resolved Hide resolved

preBuild = ''
cd base/common/python
unset SOURCE_DATE_EPOCH
Copy link
Member

Choose a reason for hiding this comment

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

why are you unsetting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised to see you actually need to unset it yourself.

pkgs/top-level/python-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/python-packages.nix Outdated Show resolved Hide resolved
@FRidh FRidh removed their assignment Feb 14, 2017
@FRidh
Copy link
Member

FRidh commented Feb 18, 2017

tests of nss and pki are not run

@outergod
Copy link
Contributor Author

I've addressed all of the issues you pointed out, @FRidh. pki-core doesn't have any tests for Python. All nss tests are now being run, but for one of them, an SSL server is started on port 1234, and I'm not sure what NixOS' policies are on tests like that.

@outergod
Copy link
Contributor Author

outergod commented Mar 4, 2017

Ping @FRidh

@fpletz
Copy link
Member

fpletz commented Mar 6, 2017

We have a local freeipa server. I hope I can get around to test this soon. Thanks for your work on this!

@fpletz fpletz self-requested a review March 6, 2017 22:03
@fpletz fpletz self-assigned this Mar 6, 2017
Copy link
Member

@FRidh FRidh left a comment

Choose a reason for hiding this comment

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

This has been open for a quite a while. My apologies for not replying any sooner.

@e-user If there's tests requiring network we disable those.

pkgs/os-specific/linux/freeipa/default.nix Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@CMCDragonkai
Copy link
Member

Will this lead to allowing NixOS being a freeipa server as well?

@bjornfor
Copy link
Contributor

I think not (from first post):

While only the client portion of FreeIPA is fully implemented, some of the work for building the server component has also been done to actually make the client build succeed.

@ts468
Copy link
Contributor

ts468 commented Nov 11, 2017

I'd be interested in getting FreeIPA integrated as well!
@e-user: How can I help? It would be a shame to loose all your hard work and effort!
@FRidh, @fpletz: What are your current thoughts and comment about it? Should we pick it up?

pkgs/development/python-modules/lesscpy/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/lesscpy/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/yubico/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/yubico/default.nix Outdated Show resolved Hide resolved
pkgs/os-specific/linux/freeipa/default.nix Outdated Show resolved Hide resolved
@FRidh
Copy link
Member

FRidh commented Nov 11, 2017

@ts468 I've only reviewed the Python expressions for which only minor changes are needed. Eventually separate commits are needed as well.

@Ekleog
Copy link
Member

Ekleog commented Oct 6, 2018

(triage) @e-user, are you still willing to push this forward? :)

@outergod
Copy link
Contributor Author

outergod commented Oct 8, 2018

Actually, I am interested again, @Ekleog. I'll look into this again over the next days.

@srhb
Copy link
Contributor

srhb commented Apr 10, 2019

I, too, am interested here. Anything I can assist with?

@outergod
Copy link
Contributor Author

I'm installing NixOS into a VM right now and will pick it up again, for real.

@outergod
Copy link
Contributor Author

So yeah, what's left to do? All issues had already been resolved before master moved on, again. I will happily resolve the conflicts, but I would appreciate if that could resolve in an actual merge. Alternatively, if anyone (@poelzi?) would prefer to run a real-life test against an actual server, I'll gladly provide guidance on how to do this, if so desired.

@mmahut
Copy link
Member

mmahut commented Jul 25, 2019

I'm open to test this if you resolve the conflicts.

@fpletz fpletz removed their assignment Nov 17, 2019
@Nepetalactone
Copy link

Nepetalactone commented Apr 10, 2020

Apart from the merge conflicts, is there anything that is keeping this from being merged @infinisil ?

@mmahut
Copy link
Member

mmahut commented May 3, 2020

ping ^^

@Nepetalactone
Copy link

@FRidh I hope I am not asking for too much, but since you seem to have merge rights and are already familiar with the pull request, would it be possible that you coordinate the inclusion of this package? There hasn't been any activity on this pull request since half a year and it seems as if there are no missing required changes, apart from the conflicts of course

Copy link
Contributor

@bhipple bhipple left a comment

Choose a reason for hiding this comment

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

Have a bunch of nit-picky review comments. Happy to test this further if you rebase/polish/upgrade it. If no one else objects once that's done I'll merge it in.

let
name = "libverto-${version}";
version = "0.2.6";
in
Copy link
Contributor

Choose a reason for hiding this comment

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

You can replace this whole thing by just using pname below.

async api which allows the library to expose asynchronous interfaces and
offload the choice of the main loop to the application.
'';
homepage = https://github.com/latchset/libverto/;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
homepage = https://github.com/latchset/libverto/;
homepage = "https://github.com/latchset/libverto/";

inherit (stdenv.lib) concatStringsSep replaceStrings;
in
buildPythonPackage rec {
name = "nss-${version}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name = "nss-${version}";
pname = "nss";


meta = with stdenv.lib; {
description = "Python binding for NSS";
homepage = https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Python_binding_for_NSS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
homepage = https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Python_binding_for_NSS;
homepage = "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Python_binding_for_NSS";

six }:

buildPythonPackage rec {
name = "pki-core-${version}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name = "pki-core-${version}";
pname = "pki-core";

This makes things much nicer for users pinning this to a different version in an overlay, and matches the general coding standards.

prefix = "/";

# Building and installing the server fails with silent Rhino errors, skipping
# for now. Need a newer Rhino version.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have this how, or still the case?

features for further integration with Linux based clients (SUDO, automount)
and integration with Active Directory based infrastructures (Trusts).
'';
homepage = https://www.freeipa.org/;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
homepage = https://www.freeipa.org/;
homepage = "https://www.freeipa.org/";

@@ -0,0 +1,5 @@
#!/bin/sh

echo "ipa-client-install is not available on NixOS. Please see services.ipa.client, instead."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
echo "ipa-client-install is not available on NixOS. Please see services.ipa.client, instead."
echo "ipa-client-install is not available on NixOS. Please see services.ipa.client instead."

@@ -3,10 +3,12 @@
, libcap, libtool, libxml2, openssl
, enablePython ? config.bind.enablePython or false, python3 ? null
, enableSeccomp ? false, libseccomp ? null, buildPackages
, enableGSSAPI ? true, kerberos ? null
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

dns_lookup_realm = false
dns_lookup_kdc = true
rdns = false
ticket_lifetime = 24h
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to make this one configurable.


meta = with stdenv.lib; {
description = "Python LESS Compiler";
homepage = https://github.com/lesscpy/lesscpy;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
homepage = https://github.com/lesscpy/lesscpy;
homepage = "https://github.com/lesscpy/lesscpy";

{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, glib, libev, libevent, tevent, talloc }:

let
name = "libverto-${version}";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
name = "libverto-${version}";
pname = "libverto";

@SuperSandro2000 SuperSandro2000 marked this pull request as draft November 27, 2020 22:00
@SuperSandro2000
Copy link
Member

Closing since author did not respond in the last months. If this is still important to you please reopen the discussion here.

@bjornfor
Copy link
Contributor

bjornfor commented Jan 2, 2021

Still important to me.

@bjornfor bjornfor reopened this Jan 2, 2021
@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Jan 10, 2021

@bjornfor yeah to you but not to @outergod because he did not respond in 18 months to this. Feel free to pick up the work.

@outergod
Copy link
Contributor Author

Yeah sorry guys. I don't even have a NixOS installation anymore, at all, so I can't really work on it. If anyone needs help finishing this, let me know.

@benley
Copy link
Member

benley commented Apr 12, 2022

I'm vaguely considering picking this up. Before I dive in, does anyone know if there has been other related work that would significantly affect this one?

@AndersonTorres
Copy link
Member

Almost two years. Just suppose that no one knows.

@s1341
Copy link
Contributor

s1341 commented Dec 12, 2022

I kinda need this, and it appears that @outergod did some impressive work... I may take this up and bump to the latest version of freeipa. Is there interest?

@AndersonTorres
Copy link
Member

This is a package database. It will always be interesting to include a package to it.

AndersonTorres added a commit to atorres1985-contrib/nixpkgs that referenced this pull request Dec 12, 2022
According to NixOS#22789 (comment),
the maintainer doesn't use NixOS anymore.
@s1341
Copy link
Contributor

s1341 commented Dec 20, 2022

I'm picking this up. I will open a new PR once I get things working...

@s1341 s1341 mentioned this pull request Dec 21, 2022
16 tasks
@s1341
Copy link
Contributor

s1341 commented Dec 21, 2022

Please see #207115 which supersedes this.

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.

None yet