Skip to content

Commit

Permalink
Fix permissions of created setup files (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
meyerj authored and mikepurvis committed Nov 26, 2019
1 parent a5dfdfe commit 74e9d2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 6 additions & 1 deletion catkin_tools/jobs/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,14 @@ def generate_env_file(logger, event_queue, context, install_target):
os.write(tmp_dst_handle, data.encode('utf-8'))
os.close(tmp_dst_handle)

# Make the file executable without overwriting the permissions for
# the group and others (copy r flags to x)
mode = os.stat(tmp_dst_path).st_mode
mode |= (mode & 0o444) >> 2
os.chmod(tmp_dst_path, mode)

# Do an atomic rename with os.rename
os.rename(tmp_dst_path, env_file_path)
os.chmod(env_file_path, 0o755)

return 0

Expand Down
4 changes: 0 additions & 4 deletions catkin_tools/verbs/catkin_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import os
import pkg_resources
import stat
import sys
import time
import traceback
Expand Down Expand Up @@ -647,19 +646,16 @@ def _create_unmerged_devel_setup(context, unbuilt):
)
with open(setup_sh_path, 'w') as f:
f.write(env_file)
os.chmod(setup_sh_path, stat.S_IXUSR | stat.S_IWUSR | stat.S_IRUSR)

# Create setup.bash file
setup_bash_path = os.path.join(context.devel_space_abs, 'setup.bash')
with open(setup_bash_path, 'w') as f:
f.write(SETUP_BASH_TEMPLATE)
os.chmod(setup_bash_path, stat.S_IXUSR | stat.S_IWUSR | stat.S_IRUSR)

# Create setup.zsh file
setup_zsh_path = os.path.join(context.devel_space_abs, 'setup.zsh')
with open(setup_zsh_path, 'w') as f:
f.write(SETUP_ZSH_TEMPLATE)
os.chmod(setup_zsh_path, stat.S_IXUSR | stat.S_IWUSR | stat.S_IRUSR)


def _create_unmerged_devel_setup_for_install(context):
Expand Down

0 comments on commit 74e9d2b

Please sign in to comment.