ban 0.1.0 → 0.1.1

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
- YTYwYWYzMTU4ODVhMGU0MDY0NDY5MTQ1YjBiZmQ3MzM3YWI3ZGE5MA==
4
+ ODJiZmEzYjU0YjRiN2QzOGI4NzYzN2IwNjY2ZDhjZjgzMjU1MGU5Nw==
5
5
  data.tar.gz: !binary |-
6
- ZDZlMzQwMTQ4ZTIxYjU3MmU5YTliYjdjYzZkYjZlY2QwMTY1Y2Y4MQ==
6
+ YTJhNzlhOWUzMzQzYzgyODg0YTJmODMxODVlZDY5NTAzYTE0ZTVkYg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTRmYTQ0OTIyNzk0ZjI3NWY1NDljNzYyNTIyMDc0YjA5NWM5OGRlYTgyOTk2
10
- YmU0Y2Y1Yzk5ZWVhOTE4MWIyN2YxMGYwNzZmNzY2NWI5NGI5MTMxN2JlNDQ3
11
- YmViZmJiY2U5NzM4ZGE3NjhhMGVlMzdmOTlhMGJjY2M3ODAzNDU=
9
+ MTY5Yjc3YWM2YzBiMWI3YzM4OWYyMjFkNzY1MmE4YTdlMzcyMTI2NzJlNjFi
10
+ YmFjMDA3ZTM4MGU1YzdiZjdjYzE1NGFhODM1YzAwMzM5ODg4OWRjNDg1NmVj
11
+ OTU5NDJmMGMyYjU0OTM0ZWZmOThlMDMyYzNkNjFjZmFiNDJkNjk=
12
12
  data.tar.gz: !binary |-
13
- MTA0NDcyYzdkNTgzNGM1YTE1NmQ2OWMxOGVhNzI5M2JmOGZiYjRjNjQ4NWQx
14
- OWE2NGUwMzc4MzZiYWNiNDUyY2JiZWM3NmJiZGYwMmExMmRiMmJjZjc1YjI1
15
- OGEwNTJmZDEzOGE3OTljODY4ZGU1NjMzZmVjY2FlMzBmN2Q3ZjU=
13
+ MzU4YTlkYWQyZDQ2MDMyNzljYmVjMjUzYmRjMzZmNTJjZDQzOWZmMDRiZGY2
14
+ NDEzN2VkYjFmODcyYjhlZjVmOTQ4Njk1YjIzODJlNGEzMDBjZTk3OGVjNzUx
15
+ ZmU2ZDM2NzNlZjc2ZWYxZjI5MGU1N2QwODdjMTZiNzk3MmU4M2I=
data/lib/ban.rb CHANGED
@@ -2,6 +2,7 @@ require 'ban/version'
2
2
  require 'logger'
3
3
  require 'json'
4
4
  require 'etc'
5
+ require 'tmpdir'
5
6
 
6
7
  # used gems
7
8
  require 'eventmachine'
@@ -4,20 +4,21 @@ module Ban
4
4
  option :port, type: :numeric, default: 8080
5
5
  option :interface, type: :string, default: '0.0.0.0'
6
6
  option :user, type: :string, default: 'nobody'
7
- option :group, type: :string, default: 'dialout'
8
- option :chroot, type: :string, default: Dir.getwd
7
+ option :group, type: :string, default: 'nogroup'
8
+ option :chroot, type: :string, default: nil
9
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]
13
13
  interface = options[:interface]
14
14
  port = options[:port]
15
+ chroot = options[:chroot] || Dir.mktmpdir
15
16
 
16
17
  EM.epoll
17
18
  EM.threadpool_size = options[:em_threads]
18
19
  EM.run do
19
20
  board = Board.new
20
- server = Server.new(options[:user], options[:group], options[:chroot])
21
+ server = Server.new(options[:user], options[:group], chroot)
21
22
 
22
23
  board.on :event do |event|
23
24
  if event.valid?
@@ -43,6 +43,7 @@ module Ban
43
43
  Ban::Logger.info "Switching to #{@user}:#{@group} into #{@chroot}"
44
44
  uid = Etc.getpwnam(@user).uid
45
45
  gid = Etc.getgrnam(@group).gid
46
+ Dir.chdir(@chroot)
46
47
  Dir.chroot(@chroot)
47
48
  Process::Sys.setgid(gid)
48
49
  Process::Sys.setuid(uid)
@@ -1,3 +1,3 @@
1
1
  module Ban
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Landgraf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-08 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler