aboutsummaryrefslogtreecommitdiff
#pragma once

#include <gcrypt.h>

#include "types.hh"
#include "serialise.hh"


namespace nix {


extern const string base32Chars;

typedef enum {
    htUnknown = 0,
    htMD5 = GCRY_MD_MD5,
    htSHA1 = GCRY_MD_SHA1,
    htSHA256 = GCRY_MD_SHA256,
    htSHA512 = GCRY_MD_SHA512,
    htSHA3_256 = GCRY_MD_SHA3_256,
    htSHA3_512 = GCRY_MD_SHA3_512,
    htBLAKE2s_256 = GCRY_MD_BLAKE2S_256
} HashType;

struct Hash
{
    static const unsigned int maxHashSize = 64;
    unsigned int hashSize;
    unsigned char hash[maxHashSize];

    HashType type;

    /* Create an unusable hash object. */
    Hash();

    /* Create a zero-filled hash object. */
    Hash(HashType type);

    /* Check whether two hash are equal. */
    bool operator == (const Hash & h2) const;

    /* Check whether two hash are not equal. */
    bool operator != (const Hash & h2) const;

    /* For sorting. */
    bool operator < (const Hash & h) const;
};


/* Convert a hash to a hexadecimal representation. */
string printHash(const Hash & hash);

/* Parse a hexadecimal representation of a hash code. */
Hash parseHash(HashType ht, const string & s);

/* Returns the length of a base-32 hash representation. */
unsigned int hashLength32(const Hash & hash);

/* Convert a hash to a base-32 representation. */
string printHash32(const Hash & hash);

/* Print a hash in base-16 if it's MD5, or base-32 otherwise. */
string printHash16or32(const Hash & hash);

/* Parse a base-32 representation of a hash code. */
Hash parseHash32(HashType ht, const string & s);

/* Parse a base-16 or base-32 representation of a hash code. */
Hash parseHash16or32(HashType ht, const string & s);

/* Verify that the given string is a valid hash code. */
bool isHash(const string & s);

/* Compute the hash of the given string. */
Hash hashString(HashType ht, const string & s);

/* Compute the hash of the given file. */
Hash hashFile(HashType ht, const Path & path);

/* Compute the hash of the given path.  The hash is defined as
   (essentially) hashString(ht, dumpPath(path)). */
struct PathFilter;
extern PathFilter defaultPathFilter;
typedef std::pair<Hash, unsigned long long> HashResult;
HashResult hashPath(HashType ht, const Path & path,
    PathFilter & filter = defaultPathFilter);

/* Compress a hash to the specified number of bytes by cyclically
   XORing bytes together. */
Hash compressHash(const Hash & hash, unsigned int newSize);

/* Parse a string representing a hash type. */
HashType parseHashType(const string & s);

/* And the reverse. */
string printHashType(HashType ht);


struct Ctx;

class HashSink : public BufferedSink
{
private:
    HashType ht;
    Ctx * ctx;
    unsigned long long bytes;

public:
    HashSink(HashType ht);
    HashSink(const HashSink & h);
    ~HashSink();
    void write(const unsigned char * data, size_t len);
    HashResult finish();
    HashResult currentHash();
};


}
ckages/audio.scm (supercollider)[description]: Likewise. * gnu/packages/curl.scm (curl): Likewise. * gnu/packages/emacs.scm (emacs): Likewise. * gnu/packages/gnome.scm (network-manager): Likewise. * gnu/packages/julia.scm (julia): Likewise. * gnu/packages/linux.scm (alsa-plugins): Likewise. (powertop, wireless-regdb): Likewise. * gnu/packages/package-management.scm (guix): Likewise. * gnu/packages/polkit.scm (polkit): Likewise. * gnu/packages/tex.scm (texlive-bin): Likewise. * gnu/services/base.scm (file-systems->fstab): Likewise. * gnu/services/cups.scm (%cups-activation): Likewise. * gnu/services/mail.scm (%dovecot-activation): Likewise. * gnu/services/messaging.scm (prosody-configuration)[log]: Likewise. * gnu/system/examples/vm-image.tmpl (vm-image-motd): Likewise. * gnu/system/install.scm (installation-os)[file-systems]: Change root file system label to "Guix_image". * gnu/system/mapped-devices.scm (check-device-initrd-modules): Remove "GuixSD". * gnu/system/vm.scm (system-docker-image): Likewise. (system-disk-image)[root-label]: Change to "Guix_image". * gnu/tests/install.scm (run-install): Remove "GuixSD". * guix/modules.scm (guix-module-name?): Likewise. * nix/libstore/optimise-store.cc: Likewise. 2019-02-18gnu: Remove unused TIMEZONE-LISTBOX-HEIGTH.Tobias Geerinckx-Rice * gnu/installer/newt/timezone.scm (timezone-listbox-heigth): Delete variable. 2019-02-18gnu: Fix some typos in the installer.Tobias Geerinckx-Rice * gnu/installer/connman.scm (connman-connect-with-auth): Fix typo in documentation. * gnu/installer/newt/keymap.scm (sort-variants): Likewise. * gnu/installer/newt/page.scm (run-listbox-selection-page): Likewise. * gnu/installer/parted.scm (mkpart): Likewise. * gnu/installer/newt/utils.scm (destroy-form-and-pop): Likewise. * gnu/installer/newt/wifi.scm (run-unknown-error-page): Fix typo. (wifi-listbox-heigth): Rename to… (wifi-listbox-height): …this, and adjust caller. * gnu/installer/timezone.scm (locate-childrens): Rename to… (locate-children): …this. Adjust all callers. 2019-01-17installer: Fix manual partitioning.Ludovic Courtès * gnu/installer/newt/partition.scm (run-partioning-page): When METHOD is 'manual, use 'filter-map' on DEVICES, not 'map', since 'disk-new' can return #f. 2019-01-17installer: "formating" → "formatting".Ludovic Courtès * gnu/installer/newt/partition.scm, gnu/installer/parted.scm: Replace "formating" with "formatting". 2019-01-17installer: Adjust messages on the final page.Ludovic Courtès * gnu/installer/newt/final.scm (run-config-display-page) (run-install-success-page, run-install-failed-page): Adjust messages. 2019-01-17installer: partition: Add encryption password confirmation.Mathieu Othacehe * gnu/installer/newt/partition.scm (prompt-luks-passwords): Add password confirmation page. 2019-01-17installer: keymap: Put English layout and international variant ahead.Mathieu Othacehe * gnu/installer/newt/keymap.scm (sort-layouts): New procedure, (sort-variants): new procedure, (run-keymap-page): use the two procedures above to sort layouts and variants. 2019-01-17installer: Remove debug popup.Mathieu Othacehe * gnu/installer/newt/partition.scm (run-partioning-page): Remove debug partition popup. 2019-01-17installer: welcome: Put "Graphical installer" ahead.Mathieu Othacehe * gnu/installer/newt/welcome.scm (run-welcome-page): Propose "Graphical install" before shell based install. 2019-01-17installer: Rename "Ok" buttons to "OK".Mathieu Othacehe * gnu/installer/newt/page.scm: s/Ok/OK/. * gnu/installer/newt/partition.scm: Ditto. * gnu/installer/newt/user.scm: Ditto. 2019-01-17installer: Various renamins follow-up.Mathieu Othacehe s/path/file and s/crypt/encrypt. * gnu/installer/newt/partition.scm: Apply renamings. * gnu/installer/parted.scm: Ditto. 2019-01-17installer: Various renamings.Mathieu Othacehe 1. s/partitionment/partitioning/ 2. s/crypted/encrypted/ * gnu/installer.scm (installer-steps): Apply renamings. * gnu/installer/newt/partition.scm (run-disk-page): ditto, * gnu/installer/parted.scm (auto-partition): ditto, (luks-format-and-open): ditto, (luks-close): ditto, (user-partitions->configuration): ditto. 2019-01-17installer: partionment: Add encryption support.Mathieu Othacehe * gnu/installer.scm (set-installer-path): Add cryptsetup. * gnu/installer/newt/partition.scm (prompt-luks-passwords): New procedure, (run-partioning-page): Add the possibility to set encryption to "On" on a partition and choose a label, add a new partition scheme: "Guided - using the entire disk with encryption", prompt for encryption passwords before proceeding to formating. * gnu/installer/parted.scm (<user-partition>)[crypt-label], [crypt-password]: New fields, (partition-description): add the encryption label, (user-partition-description): add an encryption field, (auto-partition): add two partitioning schemes: entire-crypted-root and entire-crypted-root-home, (call-with-luks-key-file): new procedure, (user-partition-upper-path): new procedure, (luks-format-and-open): new procedure, (luks-close): new procedure, (format-user-partitions): format and open luks partitions before creating file-system. (mount-user-partitions): use the path returned by user-partition-upper-path, (umount-user-partitions): close the luks partitions, (user-partition->file-system): set device field to label for luks partitions and to uuid for the rest, (user-partition->mapped-device): new procedure, (user-partitions->configuration): add mapped-devices field. 2019-01-17installer: partition: Fix typo.Mathieu Othacehe * gnu/installer/newt/partition.scm (run-disk-page): Fix typo. 2019-01-17installer: menu: Fix typo.Mathieu Othacehe * gnu/installer/newt/menu.scm (run-menu-page): Fix typo. 2019-01-17installer: partition: Precise when using Manual/Guided partionment.Mathieu Othacehe * gnu/installer/newt/partition.scm (run-disk-page)[guided?]: New argument. Use guided? to determine if we are proceeding to a guided or a manuel partitioning and precise it the title and info-text. 2019-01-17installer: Make exit button optional for run-file-textbox-page.Mathieu Othacehe * gnu/installer/newt/page.scm (run-file-textbox-page)[exit-button?]: New argument. 2019-01-17installer: Make sure every sentence is dot terminated.Mathieu Othacehe gnu/installer/newt/hostname.scm: Finish sentences by a dot. gnu/installer/newt/network.scm: Ditto. gnu/installer/newt/page.scm: Ditto. gnu/installer/newt/partition.scm: Ditto. gnu/installer/newt/user.scm: Ditto. gnu/installer/newt/wifi.scm: Ditto. 2019-01-17installer: partition: Differenciate Back button from Exit button.Mathieu Othacehe * gnu/installer/newt/partition.scm (run-label-page): Pass the button text as an argument, (run-disk-page): Call run-label-page with the appropriate button text. 2019-01-17installer: network: Do not show an empty technology list.Mathieu Othacehe If no technology is detected, ask the user if he prefers to continue or to exit the installer. * gnu/installer/newt/network.scm (run-technology-page): Run a choice-window if technology-items procedure returns an empty list. 2019-01-17installer: keymap: Fix keymap selection of layouts with not variant.Mathieu Othacehe * gnu/installer/newt/keymap.scm (run-keymap-page): Test if the layout has no variant at 'variant step, instead of raising a condition at 'layout step. 2019-01-17installer: Turn "Cancel" buttons into "Exit" buttons.Mathieu Othacehe This change and previous ones were, Suggested-by: Thorsten Wilms <t_w_@freenet.de> here: https://lists.gnu.org/archive/html/guix-devel/2018-11/msg00330.html gnu/installer/newt/ethernet.scm: Turn cancel into exit. gnu/installer/newt/final.scm: Ditto. gnu/installer/newt/keymap.scm: Ditto. gnu/installer/newt/locale.scm: Ditto. gnu/installer/newt/network.scm: Ditto. gnu/installer/newt/page.scm: Ditto. gnu/installer/newt/partition.scm: Ditto. gnu/installer/newt/services.scm: Ditto. gnu/installer/newt/timezone.scm: Ditto. gnu/installer/newt/user.scm: Ditto. gnu/installer/newt/wifi.scm: Ditto. 2019-01-17installer: locale: Set English as the default language.Mathieu Othacehe * gnu/installer/newt/locale.scm (sort-languages): New procedure ... (run-locale-page)[locale-steps]: ... used here to make english the default language. 2019-01-17installer: locale: Make clear that the point is to select a glibc locale.Mathieu Othacehe * gnu/installer/newt/locale.scm (run-language-page): Be more specific about what is a locale and what are the different steps involved in the info messages. 2019-01-17installer: Fix compute calls.Mathieu Othacehe * gnu/installer/newt/keymap.scm (run-keymap-page): Add missing argument to compute procedure. * gnu/installer/newt/network.scm (run-network-page): Ditto. 2019-01-17installer: Remove group selection in user page.Mathieu Othacehe Assume that the user's group is always "users". * gnu/installer/newt/user.scm (run-user-add-page): Remove group fields, (run-user-page): ditto. 2019-01-17installer: Add partitioning support.Mathieu Othacehe * gnu/installer.scm (installer-steps): Add partitioning step. * gnu/installer/newt.scm (newt-installer): Add partition-page field. * gnu/installer/newt/partition.scm: New file. * gnu/installer/parted.scm: New file. * gnu/installer/record (installer): New partition-page field. * gnu/local.mk (GNU_SYSTEM_MODULES): Add new files. * po/guix/POTFILES.in: Add new files. 2019-01-17installer: Fix ethernet connection.Mathieu Othacehe * gnu/installer/newt/ethernet.scm (connect-ethernet-service): Return the service passed as parameter. 2019-01-17installer: Redirect to TTY3 root shell for unguided install.Mathieu Othacehe * gnu/installer/newt/welcome.scm (run-welcome-page): Switch to TTY3 for unguided shell based install. 2019-01-17installer: Add new pages.Mathieu Othacehe * gnu/installer/newt/page.scm (run-scale-page): New exported procedure, (run-checkbox-tree-page): ditto, (run-file-textbox-page): ditto. 2019-01-17installer: Add services page.Mathieu Othacehe Add a page to select services, for now only desktop environments choice is available. * gnu/installer.scm (steps): Add services step. * gnu/installer/newt.scm (newt-installer): Add services-page field. * gnu/installer/newt/services.scm: New file. * gnu/installer/record.scm (installer): Add services-page field. * gnu/installer/services.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add new files. * po/guix/POTFILES.in: Add new files. 2019-01-17installer: Do not ask for keyboard model.Mathieu Othacehe Suppose that the keyboard model is "pc105". * gnu/installer.scm (apply-keymap): Remove model ... * gnu/installer/newt/keymap.scm (run-keymap-page): passed here. (run-model-page): remove procedure * gnu/installer/record.scm (installer): Edit keymap-page prototype in comment. * gnu/installer/keymap.scm (default-keyboard-model): New exported parameter. 2019-01-17installer: Add configuration formatter.Mathieu Othacehe * gnu/installer.scm (installer-steps): Add configuration-formatter procedures. * gnu/installer/final.scm: New file. * gnu/installer/locale.scm (locale->configuration): New exported procedure. * gnu/installer/newt.scm (newt-installer): Add final page. * gnu/installer/newt/final.scm: New file. * gnu/installer/record.scm (installer): Add final-page field. * gnu/installer/timezone.scm (posix-tz->configuration): New exported procedure. * gnu/installer/steps.scm (installer-step): Rename configuration-proc field to configuration-formatter. (%installer-configuration-file): New exported parameter, (%installer-target-dir): ditto, (%configuration-file-width): ditto, (format-configuration): new exported procedure, (configuration->file): new exported procedure. 2019-01-17installer: Remove "selection" from all titles.Mathieu Othacehe * gnu/installer/newt/hostname.scm (run-hostname-page): Remove selection from page title, (run-variant-page): ditto. * gnu/installer/newt/keymap.scm (run-layout-page): Ditto. * gnu/installer/newt/locale.scm (run-layout-page): Ditto, (run-territory-page): ditto, (run-codeset-page): ditto, (run-modifier-page): ditto * gnu/installer/newt/network.scm (run-territory-page): Ditto. * gnu/installer/newt/timezone.scm (run-timezone-page): Ditto. * gnu/installer/newt/wifi.scm (run-wifi-page): Ditto. 2019-01-17installer: Rewrite welcome page.Mathieu Othacehe The welcome page is the only page using absolute positioning for the newt components, so that the page occupies all the screen space. This is becoming too hard to manage, so switch to grid management like elsewhere, even if the result is less appealing. Also add an info text to the page with a mention on how to switch back to the original installer. * gnu/installer/newt/welcome.scm (run-menu-page): Use a vertically stacked grid instead of hard window placement. 2019-01-17gnu: Add graphical installer support.Mathieu Othacehe * configure.ac: Require that guile-newt is available. * gnu/installer.scm: New file. * gnu/installer/aux-files/logo.txt: New file. * gnu/installer/build-installer.scm: New file. * gnu/installer/connman.scm: New file. * gnu/installer/keymap.scm: New file. * gnu/installer/locale.scm: New file. * gnu/installer/newt.scm: New file. * gnu/installer/newt/ethernet.scm: New file. * gnu/installer/newt/hostname.scm: New file. * gnu/installer/newt/keymap.scm: New file. * gnu/installer/newt/locale.scm: New file. * gnu/installer/newt/menu.scm: New file. * gnu/installer/newt/network.scm: New file. * gnu/installer/newt/page.scm: New file. * gnu/installer/newt/timezone.scm: New file. * gnu/installer/newt/user.scm: New file. * gnu/installer/newt/utils.scm: New file. * gnu/installer/newt/welcome.scm: New file. * gnu/installer/newt/wifi.scm: New file. * gnu/installer/steps.scm: New file. * gnu/installer/timezone.scm: New file. * gnu/installer/utils.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add previous files. * gnu/system.scm: Export %root-account. * gnu/system/install.scm (%installation-services): Use kmscon instead of linux VT for all tty. (installation-os)[users]: Add the graphical installer as shell of the root account. [packages]: Add font related packages. * po/guix/POTFILES.in: Add installer files.