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

special case permissions when creating /opt #4244

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/cask.rb
Expand Up @@ -55,9 +55,19 @@ def self.init
if caskroom.parent.writable?
system '/bin/mkdir', caskroom
else
toplevel_dir = caskroom
toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root?
unless toplevel_dir.directory?
# If a toplevel dir such as '/opt' must be created, enforce standard permissions.
# sudo in system is rude.
system '/usr/bin/sudo', '--', '/bin/mkdir', '--', toplevel_dir
system '/usr/bin/sudo', '--', '/bin/chmod', '--', '0775', toplevel_dir
end
# sudo in system is rude.
system '/usr/bin/sudo', '--', '/bin/mkdir', '-p', '--', caskroom
system '/usr/bin/sudo', '--', '/usr/sbin/chown', '-R', '--', "#{current_user}:staff", caskroom.parent
unless caskroom.parent == toplevel_dir
system '/usr/bin/sudo', '--', '/usr/sbin/chown', '-R', '--', "#{current_user}:staff", caskroom.parent
end
end
end
end
Expand Down