Skip to content

Commit

Permalink
Make sure that LUKS.has_key always returns a boolean value
Browse files Browse the repository at this point in the history
We don't want to return 'None' here.

Related: rhinstaller/anaconda#4873
  • Loading branch information
vojtechtrefny committed Jul 12, 2023
1 parent 60ac8a4 commit 86a2848
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions blivet/devices/stratis.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def _set_passphrase(self, passphrase):

@property
def has_key(self):
return ((self.__passphrase not in ["", None]) or
(self._key_file and os.access(self._key_file, os.R_OK)))
return bool((self.__passphrase not in ["", None]) or
(self._key_file and os.access(self._key_file, os.R_OK)))

def _pre_create(self):
super(StratisPoolDevice, self)._pre_create()
Expand Down
4 changes: 2 additions & 2 deletions blivet/formats/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def _set_passphrase(self, passphrase):

@property
def has_key(self):
return ((self.__passphrase not in ["", None]) or
(self._key_file and os.access(self._key_file, os.R_OK)))
return bool((self.__passphrase not in ["", None]) or
(self._key_file and os.access(self._key_file, os.R_OK)))

@property
def formattable(self):
Expand Down
4 changes: 2 additions & 2 deletions blivet/formats/stratis.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def _set_passphrase(self, passphrase):

@property
def has_key(self):
return ((self.__passphrase not in ["", None]) or
(self._key_file and os.access(self._key_file, os.R_OK)))
return bool((self.__passphrase not in ["", None]) or
(self._key_file and os.access(self._key_file, os.R_OK)))

def unlock_pool(self):
if not self.locked_pool:
Expand Down

0 comments on commit 86a2848

Please sign in to comment.