capistrano-secure-permissions 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/capistrano-secure-permissions.gemspec +3 -3
- data/lib/capistrano/tasks/secure-permissions.rake +20 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45ea618cd36aac2f5a319755d586eda7c8ce1dec
|
4
|
+
data.tar.gz: f219c49087ce0654a45e12d81a61a133f8dc5ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21d27428483c309d431505c734c8285dc004e31c7800d00892ec20419c41eaa0bdca262e965bb61a2325013745fe51d88bdfa496c53724b1eed20e67de6c3320
|
7
|
+
data.tar.gz: e6fa904533cd9cad5f4dc8d285bbc4e3a86cc9307e98f39949b7f87365d9015f4b6605e20af591928456970e1f6d47c010b786fb5d8a07f139da492bed205bf4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: capistrano-secure-permissions
|
5
|
+
# stub: capistrano-secure-permissions 2.0.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "capistrano-secure-permissions"
|
9
|
-
s.version = "
|
9
|
+
s.version = "2.0.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Rune Schjellerup Philosof"]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-11-29"
|
15
15
|
s.description = "This gem makes it easy to run your app with a user that only has write permissions to the public folder"
|
16
16
|
s.email = "rune.capistrano-secure-permissions@philosof.dk"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -4,24 +4,15 @@ namespace :deploy do
|
|
4
4
|
on roles(:app) do |server|
|
5
5
|
web_user = fetch(:web_user)
|
6
6
|
app_user = fetch(:app_user)
|
7
|
-
deploy_user = server.user
|
8
|
-
linked_dirs = fetch(:linked_dirs)
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
]
|
15
|
-
parent_folders << "#{shared_path}/public" if linked_dirs.any? { |d| d.start_with?('public') }
|
16
|
-
execute :setfacl, "-m", "u:#{web_user}:x,u:#{deploy_user}:rx", *parent_folders
|
17
|
-
# Set all except public, tmp, and log readable by app_user.
|
18
|
-
execute :find, release_path, '-regex', '\./\(public\|tmp\|log\)', '-prune', '-o', '-user', deploy_user, '-print0', '|', 'xargs', '-0', '--no-run-if-empty', 'setfacl', '-m', "u:#{app_user}:rX"
|
19
|
-
# Set log and tmp writable by app_user.
|
20
|
-
execute :find, '-L', "#{release_path}/log", "#{release_path}/tmp", '-user', deploy_user, '-print0', '|', 'xargs', '-0', '--no-run-if-empty', 'setfacl', '-m', "u:#{app_user}:rwX"
|
8
|
+
execute :setfacl, '-m', "u:#{web_user}:x", release_path
|
9
|
+
# This is before symlinking, so we can do this recursively.
|
10
|
+
execute :setfacl, '-R', '-m', "u:#{web_user}:rx", release_path.join('public')
|
11
|
+
execute :setfacl, '-R', '-m', "u:#{app_user}:rx,d:u:#{app_user}:rx", release_path
|
21
12
|
end
|
22
13
|
end
|
23
14
|
|
24
|
-
|
15
|
+
before 'deploy:symlink:shared', 'deploy:secure_permissions'
|
25
16
|
end
|
26
17
|
|
27
18
|
namespace :secure_permissions do
|
@@ -34,17 +25,28 @@ namespace :secure_permissions do
|
|
34
25
|
end
|
35
26
|
end
|
36
27
|
|
37
|
-
desc 'Sets permissions on the
|
28
|
+
desc 'Sets permissions on the shared folders, only needs to be done once, not on every deploy. And there might be a lot of files, so it might take a while.'
|
38
29
|
task :setup do
|
39
30
|
on roles(:app) do |server|
|
40
31
|
web_user = fetch(:web_user)
|
41
32
|
app_user = fetch(:app_user)
|
42
33
|
deploy_user = server.user
|
34
|
+
# Public is writable by app_user by default, so exclude that one.
|
35
|
+
# To avoid going through the files twice.
|
36
|
+
writable_dirs = fetch(:writable_dirs, fetch(:linked_dirs)).
|
37
|
+
map { |dir| shared_path.join(dir) }.
|
38
|
+
delete_if { |dir| dir.start_with?('public/') }
|
39
|
+
# All of shared readable by app_user.
|
40
|
+
readable_dirs = shared_path.children().map(&:basename) - writable_dirs
|
43
41
|
|
42
|
+
execute :setfacl, '-m', "u:#{web_user}:x,d:u:#{web_user}:x,u:#{app_user}:rx,d:u:#{app_user}:rx", shared_path
|
43
|
+
execute :setfacl, '-R', '-m', "u:#{app_user}:rx,d:u:#{app_user}:rx", *readable_dirs
|
44
44
|
# Set permissions for files in public, readable by web_user and writable by app_user.
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
# Also make sure that deploy_user retains access, to the files that app_user creates.
|
46
|
+
execute :setfacl, '-R', '-m', "u:#{web_user}:rx,u:#{app_user}:rwx,u:#{deploy_user}:rwx,d:u:#{deploy_user}:rwx,d:u:#{web_user}:rx,d:u:#{app_user}:rwx", shared_path.join('public')
|
47
|
+
# Allow app_user access to writable_dirs in shared
|
48
|
+
# Also make sure that deploy_user retains access, to the files that app_user creates.
|
49
|
+
execute :setfacl, '-R', '-m', "u:#{app_user}:rwx,d:u:#{app_user}:rwx", *writable_dirs
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-secure-permissions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rune Schjellerup Philosof
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|