ban 0.1.0.pre0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGFmMWY5Y2IzODBjODkzMTk5OTc5NTU5NzRlYjIyM2QzMTgxMTYwZQ==
4
+ YTYwYWYzMTU4ODVhMGU0MDY0NDY5MTQ1YjBiZmQ3MzM3YWI3ZGE5MA==
5
5
  data.tar.gz: !binary |-
6
- ZWZkMWMyZWI0OWZkNDk1YzBmMWRmMjQyMjZmZWEwZDUzNDdiY2FkYw==
6
+ ZDZlMzQwMTQ4ZTIxYjU3MmU5YTliYjdjYzZkYjZlY2QwMTY1Y2Y4MQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjE2OTM4NzNjYWJhYzI3NTg0YWE5ZWQzYjgzMmJlODgyMDlhMGEzM2ExODNh
10
- MTg2OTdiMTZkY2M3NzIxMzQ5OTJhNTUxNTExMTA1NjRhZGFmODI2MjYyNDEz
11
- MDI2ZGRhNjA0YjgxMGM4MTY0N2MyZWY1MzYxMTZlNDk1ODljNWI=
9
+ OTRmYTQ0OTIyNzk0ZjI3NWY1NDljNzYyNTIyMDc0YjA5NWM5OGRlYTgyOTk2
10
+ YmU0Y2Y1Yzk5ZWVhOTE4MWIyN2YxMGYwNzZmNzY2NWI5NGI5MTMxN2JlNDQ3
11
+ YmViZmJiY2U5NzM4ZGE3NjhhMGVlMzdmOTlhMGJjY2M3ODAzNDU=
12
12
  data.tar.gz: !binary |-
13
- Yjk0ODcyZDYwMWJmMWU1OGYyZTQyMjA5ZmE3NTM3OTgzNTE0ZDNkMDAxOTI1
14
- YTEwNTEzZWJlMzRmMzNkNjExYzljYzc5NTQ5YzBhMzcyNjQyYzA0OTViOWIy
15
- MWNmZDEyN2M4MDdhZTNjNmMyNDY4YmE3YTFiMmYzYzY5ZTE5ZDM=
13
+ MTA0NDcyYzdkNTgzNGM1YTE1NmQ2OWMxOGVhNzI5M2JmOGZiYjRjNjQ4NWQx
14
+ OWE2NGUwMzc4MzZiYWNiNDUyY2JiZWM3NmJiZGYwMmExMmRiMmJjZjc1YjI1
15
+ OGEwNTJmZDEzOGE3OTljODY4ZGU1NjMzZmVjY2FlMzBmN2Q3ZjU=
@@ -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: 'dialout'
7
- option :group, type: :string, default: 'nobody'
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: 4
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]
@@ -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
- gid = Etc.getgrnam(@user).gid
42
- uid = Etc.getpwnam(@group).uid
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 proviledges didn't work: #{ex}"
50
+ Ban::Logger.warn "Dropping the priviledges didn't work: #{ex}"
48
51
  end
49
52
  end
50
53
  end
@@ -1,3 +1,3 @@
1
1
  module Ban
2
- VERSION = "0.1.0.pre0"
2
+ VERSION = "0.1.0"
3
3
  end
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.pre0
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: 1.3.1
181
+ version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
184
  rubygems_version: 2.0.6