ban 0.1.0.pre0 → 0.1.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 +8 -8
- data/lib/ban/cli.rb +3 -3
- data/lib/ban/server.rb +9 -6
- data/lib/ban/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTYwYWYzMTU4ODVhMGU0MDY0NDY5MTQ1YjBiZmQ3MzM3YWI3ZGE5MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDZlMzQwMTQ4ZTIxYjU3MmU5YTliYjdjYzZkYjZlY2QwMTY1Y2Y4MQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTRmYTQ0OTIyNzk0ZjI3NWY1NDljNzYyNTIyMDc0YjA5NWM5OGRlYTgyOTk2
|
10
|
+
YmU0Y2Y1Yzk5ZWVhOTE4MWIyN2YxMGYwNzZmNzY2NWI5NGI5MTMxN2JlNDQ3
|
11
|
+
YmViZmJiY2U5NzM4ZGE3NjhhMGVlMzdmOTlhMGJjY2M3ODAzNDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTA0NDcyYzdkNTgzNGM1YTE1NmQ2OWMxOGVhNzI5M2JmOGZiYjRjNjQ4NWQx
|
14
|
+
OWE2NGUwMzc4MzZiYWNiNDUyY2JiZWM3NmJiZGYwMmExMmRiMmJjZjc1YjI1
|
15
|
+
OGEwNTJmZDEzOGE3OTljODY4ZGU1NjMzZmVjY2FlMzBmN2Q3ZjU=
|
data/lib/ban/cli.rb
CHANGED
@@ -3,10 +3,10 @@ module Ban
|
|
3
3
|
option :device, default: nil
|
4
4
|
option :port, type: :numeric, default: 8080
|
5
5
|
option :interface, type: :string, default: '0.0.0.0'
|
6
|
-
option :user, type: :string, default: '
|
7
|
-
option :group, type: :string, default: '
|
6
|
+
option :user, type: :string, default: 'nobody'
|
7
|
+
option :group, type: :string, default: 'dialout'
|
8
8
|
option :chroot, type: :string, default: Dir.getwd
|
9
|
-
option :em_threads, type: :numeric, default:
|
9
|
+
option :em_threads, type: :numeric, default: 2
|
10
10
|
desc "server", "starts the ban server"
|
11
11
|
def server
|
12
12
|
device = options[:device]
|
data/lib/ban/server.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Ban
|
2
2
|
class Server
|
3
3
|
include EventEmitter
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(user, group, chroot)
|
6
6
|
@clients = []
|
7
7
|
@user, @group, @chroot = user, group, chroot
|
@@ -15,7 +15,6 @@ module Ban
|
|
15
15
|
|
16
16
|
def start(interface, port)
|
17
17
|
@server = EM::WebSocket.run(host: interface, port: port) do |ws|
|
18
|
-
drop_priviledges!
|
19
18
|
ws.onopen do |handshake|
|
20
19
|
Ban::Logger.debug "WebSocket connection open"
|
21
20
|
@clients << ws
|
@@ -35,16 +34,20 @@ module Ban
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
37
|
+
|
38
|
+
# server port has been started
|
39
|
+
drop_priviledges!
|
38
40
|
end
|
39
|
-
|
41
|
+
|
40
42
|
def drop_priviledges!
|
41
|
-
|
42
|
-
uid = Etc.getpwnam(@
|
43
|
+
Ban::Logger.info "Switching to #{@user}:#{@group} into #{@chroot}"
|
44
|
+
uid = Etc.getpwnam(@user).uid
|
45
|
+
gid = Etc.getgrnam(@group).gid
|
43
46
|
Dir.chroot(@chroot)
|
44
47
|
Process::Sys.setgid(gid)
|
45
48
|
Process::Sys.setuid(uid)
|
46
49
|
rescue => ex
|
47
|
-
Ban::Logger.warn "Dropping the
|
50
|
+
Ban::Logger.warn "Dropping the priviledges didn't work: #{ex}"
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
data/lib/ban/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Landgraf
|
@@ -176,9 +176,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
|
-
- - ! '
|
179
|
+
- - ! '>='
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
181
|
+
version: '0'
|
182
182
|
requirements: []
|
183
183
|
rubyforge_project:
|
184
184
|
rubygems_version: 2.0.6
|