Commit Graph

56 Commits

Author SHA1 Message Date
Anton Hvornum 15b1fb26ce
Added more debugging 2022-02-09 11:51:19 +01:00
Anton Hvornum f2750c8d21
Improved logging, and made MapperDev() representable 2022-02-09 11:47:46 +01:00
Anton Hvornum c2d765ff6d
Fixed flake8 complaint 2022-02-09 11:44:03 +01:00
Anton Hvornum 1cdd4313ae
Added some debugging 2022-02-09 11:43:18 +01:00
Anton Hvornum de974322f9
Added some debugging 2022-02-09 11:40:30 +01:00
Anton Hvornum 369daa43fc
luks2().unlock() now returns a MapperDev(). MapperDev() now have a .format() function, which relies on Partition.format() but with a custom path for now. It's not ideal, as it's a bit slow to resolve the Partition() object, but it works. 2022-02-09 11:33:51 +01:00
Anton Hvornum 32d6c1e635
Fixed issue with any() 2022-02-09 10:31:45 +01:00
Anton Hvornum 6f3a867fa3
Fixed flake8 complaint 2022-02-09 10:29:42 +01:00
Anton Hvornum 16dd6fe0cd
Forgot import of Union 2022-02-09 10:19:20 +01:00
Anton Hvornum d57f29757d
Added back key_file support for legacy reasons, but it now acts as an input instead. 2022-02-09 10:17:05 +01:00
Anton Hvornum 47dddfc497
Converting --key-file from /tmp/x to /dev/stdin. 2022-02-09 09:54:16 +01:00
Anton Hvornum 1515fb9fde
Calling Partition().partprobe() instead of general partprobe. This avoids read-only issues and lets Partition().partprobe() deal with the error checks. 2022-02-07 09:10:39 +01:00
Werner Llácer a8862e9b24
Define an standard locale for all the commands executed (#827)
* Define an standard locale for all the commands executed inside the application

* Allow LC_ALL to be overriden during call

* flake8 corrections
2022-01-06 23:26:49 +01:00
Anton Hvornum e32cf71ae7
Added type annotations to all functions (#845)
* Added type annotations for 1/5 of the files.

There's bound to be some issues with type miss-match, will sort that out later.

* Added type hints for 4/5 of the code

* Added type hints for 4.7/5 of the code

* Added type hints for 5/5 of the code base

* Split the linters into individual files

This should help with more clearly show which runner is breaking since they don't share a single common name any longer. Also moved mypy settings into pyproject.toml

* Fixed some of the last flake8 issues

* Missing parameter

* Fixed invalid lookahead types

* __future__ had to be at the top

* Fixed last flake8 issues
2022-01-06 22:01:15 +01:00
Werner Llácer 7f9b7991e9
Btrfs2 (#787)
* All the changes needed to make btrfs subvolumes work. It boils down to two points;
the handling of the addressing of subvolumes re. physical partitions, and the small changes at the bootloader level
* We added a new script only_hd for testing purposes. It only handles hadrd drive management
* restoring an escape hatch during subvolume processing
* hipercommented manage_btrfs_subvolumes
* Ready to be able to select and process options in subvolume mounting
* Separte nodatacow processing
* Solving a flake8 complain
* Use of bind names @ get_filesystem_type
* compress mount option bypass
* Preparations for encryption handling
* Compatibility to master version re. encrypted btrfs volumes
* Now we can create subvolumes and mountpoints inside an encrypted btrfs partition
* changes for entries file generation with systemd-bootctl
* flake8 corrections plus some comments

Co-authored-by: Anton Hvornum <anton@hvornum.se>
2021-12-31 13:47:41 +01:00
Anton Hvornum e729457b6c
Support encrypting multiple partitions (#759)
* Added support for storing disk encryption keyfiles and add them to a keyslot.
* Added a luks2().add_key() function in order to inject a keyfile into a keyslot on a encrypted volume.
* Simplified 'missing encryption password' logic in Filesystem(). Added a call to luks2().add_key() after the root-password is set on the volume, to add the keyfile in slot 2
* Adding in password handling in luks2().add_key(). It's required to enter a previous passphrase to unlock the volume and add a new keyslot. Also simplified the handling of partition in Installer().mount_ordered_layout()
* Adding in encryption on all partitions except /boot when encryption is opted in
* Removed setting size on Partition() as it's a read only value. No idea how Partition().size = size hasn't caused an issue before. Removed size=X argument to Partition()
* Added a uniqueness to the loopdevice name. This should ensure that multiple encrypted volumes can be opened at the same time, except for Partition().detect_inner_filesystem() operations which can only happen one at a time since they share namespace. This should never be an issue since archinstall is single threaded and no concurrent operations can/should happen.
* Added partprobe() as part of disk/helpers.py, added a /dev/ -> UUID mapper function called convert_device_to_uuid(path). Added a luks2().crypttab() function that sets up a /etc/crypttab entry.
* Moved the responsability for telling archinstall to generate a keyfile from Filesystem() to user_interaction.py. This should in the future be a user-input based value, and not something the Filesystem() automatically dictates.
* Added a retry mechanism to luks2().encrypt() to avoid having to re-start the installation when a device simply wasn't up yet.
* Swapping UUID= lookup from loopdev to physdev.
2021-11-24 00:09:33 +01:00
Anton Hvornum 91887bf0b3 Added more partprobe's 2021-11-11 15:14:06 +00:00
Anton Hvornum 2fcd8198b2
Cleaned up all flake8 issues/warnings. Did some code cleaning as well, mostly how we called things in guided.py but also some SysCommand calls 2021-11-05 16:27:01 +01:00
Anton Hvornum d76760b45f Removed old safety logics for partitions. Partitions will now always be formatted when .format() is called on them. The safety now lay in the code parsing the declerative partition layouts. Also added the encrypt/mount logic for encrypted partitions, which by default will be unencrypted unless a password is specified. 2021-06-13 14:25:07 +02:00
Anton Hvornum fb8bb98b83 Incorrect variable names being used from copy paste. 2021-05-18 09:21:18 +02:00
Dylan Taylor 1796bbb918 Perform refactoring to PEP 8 naming conventions 2021-05-15 17:50:28 -04:00
Dylan Taylor 126c7ebfca More formatting fixes to satisfy PEP 8 2021-05-15 15:04:39 -04:00
Dylan Taylor 69d675f4aa Many more manual changes 2021-05-15 12:29:57 -04:00
Anton Hvornum 090b98b830
Moving away from custom log levels, to something that's well defined. (#360)
* Moving away from custom log levels, to something that's well defined.

* Added backward compability to log() as well.

* Added an option to force log messages out on screen even if the level is below the log level threashold.

* Added force log messages when wrong notation is used.

* Added some more length to the deprecated message

* Swapped all log levels to use logging.<level> instead.

Co-authored-by: Anton Hvornum <anton.feeds@gmail.com>
2021-04-27 16:43:17 +02:00
Dylan M. Taylor 49ca264790
Change from argon2i to argon2id
Closes #269
2021-04-11 20:38:24 -04:00
NicoHood b9148f6d3b
fix typo 2021-04-10 10:55:49 +02:00
Alexander Seiler 437315669f
Fix typo that causes crash when creating encrypted LUKS partition (closes #248) 2021-04-09 05:00:43 +02:00
Anton Hvornum ae2da06075
Added a safety check to verify that the encrypted partition exists at least before trying to open it. 2021-04-08 19:56:29 +02:00
Anton Hvornum 2c73989da4
Removed a TODO comment 2021-04-05 11:38:17 +02:00
Anton Hvornum 7ae9696f13
This should correct #135. I'll have to investigate other places where this logic might be as well and correct those. 2021-04-03 14:04:18 +02:00
Pyfisch cf4745bbb6 Join cryptsetup args using shlex
Ensure that all arguments are properly quoted.
Improve readability by using long-form arguments only.
Use identical arguments for both cryptsetup calls,
to prevent them from accidentally diverging in future commits.
2021-04-02 18:19:25 +02:00
Anton Hvornum ef7f2f53b1
Missing variable
This should fix #135
2021-04-01 22:12:52 +02:00
Anton Hvornum 5e9c973d42
Added support for flushing a BlockDevice() cache after a partition has been formatted. This is to avoid internal confusion of which partitions are encrypted or not when going from Encrypted -> Un-encrypted setups. 2021-03-29 16:51:30 +02:00
Anton Hvornum c897421e1d
Using 'umount -R' rather than just 'umount' since we're going to wipe the partition, we need do unmount anything that's mounted beneeth it to continue. 2021-03-14 13:56:24 +01:00
Anton Hvornum 7ac68b2436
Removed redundant error handling as well as added some more debug logs. 2021-03-14 13:54:01 +01:00
Anton Hvornum 1c6d705714
Enhanced the error handling on crypt-devices. 2021-03-14 12:50:47 +01:00
Anton Hvornum e4514e8fc3
Some more error handling. 2021-03-14 12:27:48 +01:00
Anton Hvornum f589750a3c
Tweaked SysCallError() exception to include the exit code in a machine readable manner. Since it's useful as an indicator where calls might go wrong and for what reason. 2021-03-14 12:16:46 +01:00
Anton Hvornum 577428f1b2
Added a partition.umount() and a check when running cryptsetup if the disk is in use. 2021-03-14 12:13:08 +01:00
Anton Hvornum cf21b47764 Carried over the allow_formatting from the parent device of luks2() devices. 2021-03-09 14:00:30 +01:00
Anton Hvornum 3e9031821a Forgot to set a variable 2021-03-09 13:36:47 +01:00
Anton Hvornum 8f42a9f4ff Added option to skip autodetection of filesystem. This is so for instance luks2() can override any auto-detection that revers back to the parent device of the mapped device, which would be crypto_LUKS instead of None for the inner partition. 2021-03-09 12:16:40 +01:00
Anton Hvornum 585e0f4b86 Added some debugging. 2021-03-09 12:10:30 +01:00
Anton Hvornum 3bf8ba0819 Fixed luks2().close() to properly detect it's own mapped path 2021-03-09 12:00:40 +01:00
Anton Hvornum 251624734f Fixed luks2().close() to properly detect it's own path 2021-03-09 11:58:35 +01:00
Anton Hvornum 9f0d25bce3 Added functions to auto-detect filesystems inside encrypted partitions (given a password) 2021-03-09 11:48:40 +01:00
Anton Hvornum 7ee4815648
Adding encryption helpers to the Partition() class, that sets up and utilizes luks2.encrypt() in extension. 2021-03-09 00:12:03 +01:00
Anton Hvornum 6306de4bfe Reworked the guided partitioning logic to better match new expectations of flexability. Still some work to be done and features to be implemented, but the structure is taking place 2021-03-08 16:52:06 +01:00
Anton Hvornum e2cd617d05
Reworked the way partition formatting works. As well as added some flags to the partition if it's locked/unlocked for partitioning. By defaults partitions will now be in a locked state - prohibiting formatting unless set or overridden in the formatting call. This allows us to selectively format partitions individually later on. There's also a target_mountpoint that is the desired relative mount point inside a installation. This can be pre-pended with the installation base directory during mount. These changes also function as indicators for the installation (and guided installation) for which partitions to use and/or wipe. If an entire drive is selected for wiping, these changes will have no affect in the decision making as all partitions will be new and have formatable set to true. 2021-02-11 14:11:21 +01:00
Anton Hvornum a58331868e
Added debug output as well as corrected output formatting in log(). 2021-01-24 23:41:45 +01:00