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

Have a single ActivateVolumeOptions struct for the ActivateVolumeWith* family #116

Merged
merged 2 commits into from
Sep 25, 2020

Conversation

pedronis
Copy link
Collaborator

@pedronis pedronis commented Sep 25, 2020

Also rename PIN in its definition to Passphrase to move toward
better and also more abstract naming.

Same in the corresponding RecoveryKeyUsageReason code.

See also issue #113

…* funcs

Also rename PIN in its definition to UserPassprase to move toward
better and also more abstract naming.

Same in the corresponding RecoveryKeyUsageReason code.

Se also issue #113
Copy link
Contributor

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

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

LGTM. Some comment tweaks for further consideration.

r := pinReader
pinReader = nil
r := passphraseReader
passphraseReader = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to renames, is this a precaution that the reader wouldn't be used again by accident?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not quite sure what was the original intention here. It's meant to fall back to use systemd-ask-password after consuming one passphrase. But it's very specific behavior that's another reason to have some more control later via the Prompter if needed.

// If the TPM sealed key object has a PIN defined, then this function will use systemd-ask-password to request it. If pinReader is not
// nil, then an attempt to read the PIN from this will be made instead by reading all characters until the first newline. The PINTries
// field of options defines how many attempts should be made to obtain the correct PIN before failing.
// If the TPM sealed key object has a user passphrase/PIN defined, then this function will use systemd-ask-password to request it. If passphraseReader is not
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a long comment, but I see it's consistent with the rest of the comments in the package. Nevertheless, it does not fit into a file view in a github review page, making it a bit hard to follow. Could we unify the comments style with snapd at some point?

crypt.go Outdated
Comment on lines 468 to 470
// set. With a TPM attempts to unseal with a user passphrase
// will stop if the TPM enters dictionary attack lockout mode
// before this limit is reached.
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
// set. With a TPM attempts to unseal with a user passphrase
// will stop if the TPM enters dictionary attack lockout mode
// before this limit is reached.
// set. With a TPM, subsequent attempts to unseal with a user passphrase
// will be ceased if the TPM enters dictionary attack lockout mode
// before the tries limit is reached.

crypt.go Outdated
// will stop if the TPM enters dictionary attack lockout mode
// before this limit is reached.
// It is unused by ActivateWithRecoveryKey.
UserPassphraseTries int
Copy link
Contributor

Choose a reason for hiding this comment

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

UserPassphraseMaxTries?

// ActivateWithRecoveryKey and when falling in the other
// cases, for example failed TPM unsealing. Setting this to
// zero will disable attempts to activate with the fallback
// recovery key.
RecoveryKeyTries int
Copy link
Contributor

Choose a reason for hiding this comment

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

RecoveryKeyMaxTries?

crypt.go Outdated
Comment on lines 464 to 465
// with the recovery key if RecoveryKeyTries is greater than
// zero. Setting this to zero disables unsealing with a user
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
// with the recovery key if RecoveryKeyTries is greater than
// zero. Setting this to zero disables unsealing with a user
// with the recovery key (see RecoveryKeyTries).
// Setting this to zero disables unsealing with a user

crypt.go Outdated
// LockSealedKeyAccess controls whether LockAccessToSealedKeys should be called after unsealing the TPM sealed key. It is called if
// this is set to true, and not called if this is set to false.
LockSealedKeyAccess bool
// LockSealedKeys controls whether access to the keys locked
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
// LockSealedKeys controls whether access to the keys locked
// LockSealedKeys controls whether access to the keys is locked

Copy link

@anonymouse64 anonymouse64 left a comment

Choose a reason for hiding this comment

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

some suggestions/wonderings that are pretty nitpicky /o, but otherwise lgtm

crypt.go Outdated
Comment on lines 468 to 470
// set. With a TPM attempts to unseal with a user passphrase
// will stop if the TPM enters dictionary attack lockout mode
// before this limit is reached.

Choose a reason for hiding this comment

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

Suggested change
// set. With a TPM attempts to unseal with a user passphrase
// will stop if the TPM enters dictionary attack lockout mode
// before this limit is reached.
// set. With a TPM, attempts to unseal will stop if the TPM enters
// dictionary attack lockout mode before this limit is reached.

crypt.go Outdated
Comment on lines 476 to 478
// attempted. It is considered directly by
// ActivateWithRecoveryKey and when falling in the other
// cases, for example failed TPM unsealing. Setting this to

Choose a reason for hiding this comment

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

Suggested change
// attempted. It is considered directly by
// ActivateWithRecoveryKey and when falling in the other
// cases, for example failed TPM unsealing. Setting this to
// attempted. It is used to directly with
// ActivateWithRecoveryKey and indirectly with other
// methods upon failure, for example failed TPM
// unsealing. Setting this to

RecoveryKeyTries int

// ActivateOptions provides a mechanism to pass additional options to systemd-cryptsetup.
// ActivateOptions provides a mechanism to pass additional
// options to systemd-cryptsetup.
ActivateOptions []string

Choose a reason for hiding this comment

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

Suggested change
ActivateOptions []string
AdditionalActivateOptions []string

or maybe

Suggested change
ActivateOptions []string
AdditionalActivationOptions []string

or maybe even

Suggested change
ActivateOptions []string
AdditionalSystemdCryptSetupActivationOptions []string

(I'm not familiar enough with the pkg to know how specific we ought to be about using systemd-cryptsetup references)

crypt.go Outdated
Comment on lines 488 to 489
// after unsealing. That means calling LockAccessToSealedKeys
// in TPM case.

Choose a reason for hiding this comment

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

Suggested change
// after unsealing. That means calling LockAccessToSealedKeys
// in TPM case.
// after unsealing by calling LockAccessToSealedKeys in the TPM case
// for example

UserPassphrase is fairly long and it's unclear whether it always
be strictly from a user

thanks @bboozzoo, @anonymouse64
@pedronis pedronis merged commit 70fb38d into v1-wip Sep 25, 2020
@pedronis pedronis deleted the activate-volume-options branch May 25, 2021 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants