Skip to content

Commit

Permalink
Fix user execute check
Browse files Browse the repository at this point in the history
  • Loading branch information
GeigerJ2 committed Nov 5, 2024
1 parent ece9185 commit a9cc3a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/aiida/orm/nodes/data/code/installed.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ def validate_filepath_executable(self):
file_exists = transport.isfile(str(self.filepath_executable))
if file_exists:
mode = transport.get_mode(str(self.filepath_executable))
# check if execute but is set
user_has_execute = format(mode, 'b')[6] == '1'
# `format(mode, 'b')` with default permissions
# gives 110110100, representing rw-rw-r--
# Check on index 2 if user has execute
user_has_execute = format(mode, 'b')[2] == '1'

except Exception as exception:
raise exceptions.ValidationError(
Expand Down
3 changes: 1 addition & 2 deletions tests/orm/data/code/test_installed.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ def test_validate_filepath_executable(ssh_key, computer, bash_path, tmp_path):
ValidationError,
match=r'The executable at the remote absolute path .* exists, but might not actually be executable\.',
):
# Didn't put this in the if-else and use transport.put, as we anyway only connect to localhost via SSH in this
# test
# Didn't put this in the if, using transport.put, as we anyway only connect to localhost via SSH in this test
dummy_code.validate_filepath_executable()

code.filepath_executable = str(bash_path.absolute())
Expand Down

0 comments on commit a9cc3a7

Please sign in to comment.