aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2022 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2017, 2018, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2021, 2024 Timotej Lazar <timotej.lazar@araneo.si>
;;; Copyright © 2021, 2022 Remco van 't Veer <remco@remworks.net>
;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages sssd)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module (guix modules)
  #:use-module (guix utils)
  #:use-module (guix build utils)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system python)
  #:use-module (gnu packages)
  #:use-module (gnu packages)
  #:use-module (gnu packages adns)
  #:use-module (gnu packages algebra)
  #:use-module (gnu packages augeas)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages crypto)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages cyrus-sasl)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages dns)
  #:use-module (gnu packages docbook)
  #:use-module (gnu packages documentation)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages jose)
  #:use-module (gnu packages kerberos)
  #:use-module (gnu packages libunistring)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages nss)
  #:use-module (gnu packages openldap)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages popt)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages samba)
  #:use-module (gnu packages security-token)
  #:use-module (gnu packages selinux)
  #:use-module (gnu packages ssh)
  #:use-module (gnu packages web)
  #:use-module (gnu packages xml))

(define-public adcli
  (package
    (name "adcli")
    (version "0.9.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://gitlab.freedesktop.org/realmd/adcli.git")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1lg181hpv07zcdybpykjq6h4v6f5sjc60gxqbklm0wqxa8m4sakn"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       ;; The net tool is used to update the stored machine key for samba.
       (list (string-append "--with-samba-data-tool="
                            (search-input-file %build-inputs "bin/net")))))
    (native-inputs
     (list autoconf
           automake
           docbook-xml-4.3
           docbook-xsl
           libtool
           libxslt
           util-linux                   ;For `rev` command used in tests.
           xmlto))
    (inputs (list cyrus-sasl mit-krb5 samba openldap zlib))
    (home-page "https://gitlab.freedesktop.org/realmd/adcli/")
    (synopsis "Helper library and tools for Active Directory client operations")
    (description "@command{adcli} is a command‐line tool to join a computer to
an Active Directory domain.  It can also update the machine password and
manage user, group and computer accounts for a domain.")
    (license license:lgpl2.1+)))

(define-public ding-libs
  (package
    (name "ding-libs")
    (version "0.6.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/SSSD/ding-libs")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "17x3gj2yrjb6h7ml97xlim310x8s54n238p3ns2bj3mxifqkx0mf"))))
    (build-system gnu-build-system)
    (arguments
     (list #:configure-flags
           '(list "--disable-static")))
    (native-inputs (list autoconf automake gettext-minimal libtool pkg-config))
    (home-page "https://pagure.io/SSSD/ding-libs/")
    (synopsis "Libraries for SSSD")
    (description
     "DING-LIBS (DING Is Not Glib) are a set of small, useful libraries that
the @dfn{System Security Services Daemon} (SSSD) uses and makes available to
other projects.  They include: libdhash, an implementation of a dynamic hash
table which will dynamically resize to achieve optimal storage and access time
properties; ini_config, a library for parsing and managing @code{INI} files;
path_utils, a library to manage UNIX paths and subsets of paths; collection, a
generic, hierarchical grouping mechanism for complex data sets; ref_array, a
dynamically-growing, reference-counted array; libbasicobjects, a set of
fundamental object types for C.")
    (license license:lgpl3+)))

(define-public sssd
  (package
    (name "sssd")
    (version "2.9.4")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/SSSD/sssd")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "11qchs59f8y8w5ns9mqg16nrv1kglfavzvqway0aj2z6ssfxk5al"))
       (patches (search-patches "sssd-system-directories.patch"))))
    (build-system gnu-build-system)
    (arguments
     (list
      #:imported-modules (source-module-closure
                          '((guix build python-build-system)))
      #:make-flags
      #~(list (string-append "CFLAGS=-DRENEWAL_PROG_PATH=\\\""
                             #$(this-package-input "adcli") "/sbin/adcli"
                             "\\\"")
              (string-append "DOCBOOK_XSLT="
                             #$(this-package-native-input "docbook-xsl")
                             "/xml/xsl/docbook-xsl-"
                             #$(package-version (this-package-native-input "docbook-xsl"))
                             "/manpages/docbook.xsl"))
      #:configure-flags
      #~(list "--localstatedir=/var" ; for /var/lib/sss, /var/run/sssd.pid, etc.
              "--sysconfdir=/etc"    ; /etc/sssd

              "--disable-cifs-idmap-plugin"
              "--without-nfsv4-idmapd-plugin"
              (string-append "--with-plugin-path="
                             #$output "/lib/sssd")
              (string-append "--with-krb5-plugin-path="
                             #$output "/lib/krb5/plugins/libkrb5")
              (string-append "--with-cifs-plugin-path="
                             #$output "/lib/cifs-utils")
              (string-append "--with-init-dir="
                             #$output "/etc/init.d")
              (string-append "--with-ldb-lib-dir="
                             #$output "/lib/ldb/modules/ldb")
              (string-append "--with-xml-catalog-path="
                             #$(this-package-native-input "docbook-xml")
                             "/xml/dtd/docbook/catalog.xml"))
      #:modules '((guix build gnu-build-system)
                  (guix build utils)
                  ((guix build python-build-system)
                   #:select (ensure-no-mtimes-pre-1980)))
      #:imported-modules (append %default-gnu-imported-modules
                                 %python-build-system-modules)
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'ensure-no-mtimes-pre-1980
                     ensure-no-mtimes-pre-1980)
          (add-after 'patch-source-shebangs 'patch-more-shebangs
            (lambda _
              (substitute* '("src/tools/analyzer/sss_analyze"
                             "src/tools/sss_obfuscate")
                (("#!/usr/bin/.*python")
                 (string-append "#!" #$(this-package-input "python") "/bin/python3")))))
          (add-before 'bootstrap 'fix-configure-macros
            (lambda _
              ;; A configure test for nsupdate realm support fails without this.
              (substitute* "src/external/nsupdate.m4"
                (("\\$NSUPDATE ") "$NSUPDATE -i "))
              ;; Let tests find softhsm lib.
              (substitute* "src/external/test_ca.m4"
                (("/usr/lib/softhsm")
                 (string-append #$(this-package-native-input "softhsm")
                                "/lib/softhsm")))))
          (add-before 'configure 'disable-failing-tests
            (lambda _
              ;; Disable tests that needs /etc/passwd.
              (substitute* "Makefile.am"
                (("pam-srv-tests") "")
                (("test-negcache") ""))
              ;; This test fails for unknown reason.
              (substitute* "src/tests/responder_socket_access-tests.c"
                (("tcase_add_test\\(tc_utils, resp_str_to_array_test\\);") ""))))
          (add-before 'check 'set-libpython-path
            (lambda _
              (setenv "LD_LIBRARY_PATH"
                      (string-append #$(this-package-input "python") "/lib"))))
          (add-after 'install 'remove-static-libs
            (lambda _
              ;; Remove a static library that produces a (harmless) warning
              ;; when starting a program that uses sssd’s LDB modules.
              (delete-file
               (string-append #$output "/lib/ldb/modules/ldb/memberof.la"))))
          (add-after 'install 'wrap-binaries
            (lambda _
              (with-directory-excursion #$output
                ;; Set path to LDB modules for sssd and utilities.
                (for-each (lambda (bin)
                            (wrap-program (string-append "sbin/" bin)
                              `("LDB_MODULES_PATH" ":" prefix
                                (,(string-append #$output "/lib/ldb/modules/ldb")))))
                          '("sssd" "sssctl" "sss_cache" "sss_override" "sss_seed"))
                ;; Set path to sssd’s site-packages for scripts.
                (for-each (lambda (script)
                            (wrap-program script
                              `("GUIX_PYTHONPATH" ":" prefix
                                (,(string-append #$output "/lib/python"
                                                 #$(version-major+minor
                                                    (package-version
                                                     (this-package-input "python")))
                                                 "/site-packages")))))
                          '("libexec/sssd/sss_analyze" "sbin/sss_obfuscate"))))))))
    (inputs
     (list adcli
           bash-minimal
           c-ares
           curl ; for OpenID Connect support
           cyrus-sasl
           dbus
           ding-libs
           glib
           gnutls
           http-parser
           `(,isc-bind "utils")
           jansson
           jose ; for OpenID Connect support
           keyutils
           ldb
           libnl
           libselinux
           libsemanage
           libunistring
           linux-pam
           mit-krb5
           nss
           openldap
           openssl
           p11-kit ; for PKCS#11 support
           pcre2
           popt
           python ; for wrap-program phase
           samba/pinned
           talloc
           tdb
           tevent))
    (native-inputs
     (list autoconf
           automake
           bc ; for tests
           check ; for tests
           cmocka ; for tests
           docbook-xml-4.4
           docbook-xsl
           doxygen
           gettext-minimal
           libfaketime ; for tests
           libtool
           libxml2 ; for xmllint
           libxslt
           openssh ; for tests
           pkg-config
           python-toolchain
           po4a
           softhsm ; for tests
           `(,util-linux "lib"))) ; for uuid.h, reqired for KCM
    (home-page "https://pagure.io/SSSD/sssd/")
    (synopsis "System security services daemon")
    (description "SSSD is a system daemon.  Its primary function is to provide
access to identity and authentication remote resource through a common
framework that can provide caching and offline support to the system.  It
provides PAM and NSS modules, and in the future will support D-BUS based
interfaces for extended user information.  It also provides a better database
to store local users as well as extended user data.")
    (license license:gpl3+)))
ide"); radio_components_window.classList.add("hide"); for (let li of chbx_components_ul.children) { let chbx = li.firstElementChild.firstElementChild; chbx.checked = false; } } function commit_bag_components() { let selected = []; for (let li of chbx_components_ul.children) { let chbx = li.firstElementChild.firstElementChild; if (!chbx.checked) continue; selected.push([li.getAttribute("data-prefix"), li.getAttribute("data-name")]); } add_bag_components(selected); cancel_components(); } const radio_components_window = by_id("radio_components_window"); var radio_component_none_input = by_id("radio_component_none_input"); function page_components() { radio_components_window.classList.remove("hide"); chbx_components_window.classList.add("hide"); radio_component_none_input.checked = true; let components = work_page_li_components(); if (components === undefined) return; let [prefix, item] = components; let li = by_id(radio_li_id(prefix, item)); if (li === null) radio_component_none_input.checked = false; else li.firstElementChild.firstElementChild.checked = true; } function commit_page_components() { let components = null; for (let li of radio_components_ul.children) { let radio = li.firstElementChild.firstElementChild; if (!radio.checked) continue; components = [li.getAttribute("data-prefix"), li.getAttribute("data-name")]; if (radio.id === "radio_component_none_input") components = undefined; break; } if (components !== null) set_page_components(components); cancel_components(); } function cancel_components() { chbx_components_window.classList.add("hide"); radio_components_window.classList.add("hide"); } const UL_STATE = { EDITING_ENTRY : 0, ADDING_ENTRY : 1, IDLE : 2 }; const ul_by_prefix = { [TYPE_PREFIX.REPO] : { ul : by_id("repos_ul"), work_li : by_id("work_repo_li"), work_name_input : by_id("repo_url_field"), reset_work_li : reset_work_repo_li, get_work_li_data : work_repo_li_data, state : UL_STATE.IDLE, edited_item : undefined, }, [TYPE_PREFIX.PAGE] : { ul : by_id("pages_ul"), work_li : by_id("work_page_li"), work_name_input : by_id("page_url_field"), reset_work_li : reset_work_page_li, get_work_li_data : work_page_li_data, select_components : page_components, commit_components : commit_page_components, state : UL_STATE.IDLE, edited_item : undefined, }, [TYPE_PREFIX.BAG] : { ul : by_id("bags_ul"), work_li : by_id("work_bag_li"), work_name_input : by_id("bag_name_field"), reset_work_li : reset_work_bag_li, get_work_li_data : work_bag_li_data, select_components : bag_components, commit_components : commit_bag_components, state : UL_STATE.IDLE, edited_item : undefined, }, [TYPE_PREFIX.SCRIPT] : { ul : by_id("scripts_ul"), work_li : by_id("work_script_li"), work_name_input : by_id("script_name_field"), reset_work_li : reset_work_script_li, get_work_li_data : work_script_li_data, state : UL_STATE.IDLE, edited_item : undefined, } } /* * Newer browsers could utilise `text' method of File objects. * Older ones require FileReader. */ function _read_file(file, resolve, reject) { let reader = new FileReader(); reader.onload = () => resolve(reader.result); reader.onerror = () => reject(reader.error); reader.readAsText(file); } function read_file(file) { return new Promise((resolve, reject) => _read_file(file, resolve, reject)); } const url_regex = /^[a-z0-9]+:\/\/[^/]+\.[^/]{2,}(\/[^?#]*)?$/; const empty_regex = /^$/; const settings_schema = [ [{}, "matchentry", "minentries", 1, new RegExp(`^${TYPE_PREFIX.SCRIPT}`), { /* script data */ "url": ["optional", url_regex, "or", empty_regex], "sha256": ["optional", matchers.sha256, "or", empty_regex], "text": ["optional", "string"] }, new RegExp(`^${TYPE_PREFIX.BAG}`), [ "optional", [matchers.component, "repeat"], "default", undefined ], new RegExp(`^${TYPE_PREFIX.PAGE}`), { /* page data */ "components": ["optional", matchers.component] }], "repeat" ]; const import_window = by_id("import_window"); let import_frame; async function import_from_file(event) { let files = event.target.files; if (files.length < 1) return; import_window.classList.remove("hide"); import_frame.show_loading(); try { const file = await read_file(files[0]); var result = parse_json_with_schema(settings_schema, file); } catch(e) { import_frame.show_error("Bad file :(", "" + e); return; } import_frame.show_selection(result); } const file_opener_form = by_id("file_opener_form"); function hide_import_window() { import_window.classList.add("hide"); /* * Reset file <input>. Without this, a second attempt to import the same * file would result in "change" event not happening on <input> element. */ file_opener_form.reset(); } async function initialize_import_facility() { let import_but = by_id("import_but"); let file_opener = by_id("file_opener"); import_but.addEventListener("click", () => file_opener.click()); file_opener.addEventListener("change", import_from_file); import_frame = await get_import_frame(); import_frame.onclose = hide_import_window; import_frame.style_table("has_bottom_line", "always_scrollbar", "has_upper_line", "tight_table"); } /* * If url has a target appended, e.g. * chrome-extension://hnhmbnpohhlmhehionjgongbnfdnabdl/html/options.html#smyhax * that target will be split into prefix and item name (e.g. "s" and "myhax") * and editing of that respective item will be started. * * We don't need to worry about the state of the page (e.g. some editing being * in progress) in jump_to_item() - this function is called at the beginning, * together with callbacks being assigned to buttons, so it is safe to assume * lists are initialized with items and page is in its virgin state with regard * to everything else. */ function jump_to_item(url_with_item) { const [dummy1, base_url, dummy2, target] = /^([^#]*)(#(.*))?$/i.exec(url_with_item); if (target === undefined) return; const prefix = target.substring(0, 1); if (!list_prefixes.includes(prefix)) { history.replaceState(null, "", base_url); return; } by_id(`show_${TYPE_NAME[prefix]}s`).checked = true; edit_item(prefix, decodeURIComponent(target.substring(1))); } async function main() { init_default_policy_dialog(); storage = await get_remote_storage(); for (let prefix of list_prefixes) { for (let item of storage.get_all_names(prefix).sort()) { add_li(prefix, item, true); add_chbx_li(prefix, item); add_radio_li(prefix, item); } let name = TYPE_NAME[prefix]; let add_but = by_id(`add_${name}_but`); let discard_but = by_id(`discard_${name}_but`); let save_but = by_id(`save_${name}_but`); add_but.addEventListener("click", () => add_new_item(prefix)); discard_but.addEventListener("click", () => cancel_work(prefix)); save_but.addEventListener("click", () => save_work(prefix)); if ([TYPE_PREFIX.REPO, TYPE_PREFIX.SCRIPT].includes(prefix)) continue; let ul = ul_by_prefix[prefix]; let commit_components_but = by_id(`commit_${name}_components_but`); let cancel_components_but = by_id(`cancel_${name}_components_but`); let select_components_but = by_id(`select_${name}_components_but`); commit_components_but .addEventListener("click", ul.commit_components); select_components_but .addEventListener("click", ul.select_components); cancel_components_but.addEventListener("click", cancel_components); } jump_to_item(document.URL); storage.add_change_listener(handle_change); await initialize_import_facility(); } function handle_change(change) { if (change.old_val === undefined) { add_li(change.prefix, change.item); add_chbx_li(change.prefix, change.item); add_radio_li(change.prefix, change.item); return; } if (change.new_val !== undefined) return; let ul = ul_by_prefix[change.prefix]; if (ul.state === UL_STATE.EDITING_ENTRY && ul.edited_item === change.item) { ul.state = UL_STATE.ADDING_ENTRY; return; } let uls_creators = [[ul.ul, item_li_id]]; if ([TYPE_PREFIX.BAG, TYPE_PREFIX.SCRIPT].includes(change.prefix)) { uls_creators.push([chbx_components_ul, chbx_li_id]); uls_creators.push([radio_components_ul, radio_li_id]); } for (let [components_ul, id_creator] of uls_creators) { let li = by_id(id_creator(change.prefix, change.item)); components_ul.removeChild(li); list_set_scrollbar(components_ul); } } main();