dns_one 0.4.31 → 0.4.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86b8305fbb1e6d4c2eec401c5b67ace08e282c2b
4
- data.tar.gz: 4cf1e386c035351ba310619da3221df4ba7bd212
3
+ metadata.gz: 900d8755b12840905147de4a017db2cc231029a2
4
+ data.tar.gz: 98d9df6846a22c4a25b0c251c81dfed25bc9c222
5
5
  SHA512:
6
- metadata.gz: 536fb7c338ac4ea364a86601c5c9292e20150306b733b7d7992172a252b5cd84079828d42c755a420fa724cdf22249f7465df1eb73923ed14803feddeec6dce3
7
- data.tar.gz: 8c15909797901a1ac9e88482faeca08e70d6d57ea25334d07aaab878011f0bf0776f207492a310927886c229bb57212facfcb2294ac521b1c7cbf1955ea35cfb
6
+ metadata.gz: 38d134a6dc61b371657dec056001fd0858585da70b83a6e5b8c63c2aa28e870f9bda1468663852ea3aa4c3ae82111e5f35b081c7f3379e654d91892b63f36a75
7
+ data.tar.gz: 189ff251f98d724fd94416e12ef87f74156af648644a275336f6f1fd2e84b44a78f605f6b1b9986a1764d65cc6e4306f7f940d041d18e023f59c7f75e7fe177c
@@ -15,22 +15,24 @@ module DnsOne; class Server
15
15
  def initialize conf, conf_zone_search
16
16
  @conf = conf
17
17
  @zone_search = ZoneSearch.instance.setup conf_zone_search
18
- @stat = Stat.new
19
18
  end
20
19
 
21
20
  def run
22
21
  zone_search = @zone_search
23
22
  conf = @conf
24
- stat = @stat
23
+ stat = nil
25
24
 
26
25
  RubyDNS::run_server(listen: dns_daemon_interfaces, logger: Log.logger) do
27
26
  on(:start) do
28
27
  if RExec.current_user == 'root'
29
28
  run_as = conf[:run_as] || DEFAULT_RUN_AS
29
+ stat = Stat.new user: run_as if !stat
30
30
  RExec.change_user run_as
31
+ user = run_as
32
+ else
33
+ stat = Stat.new if !stat
31
34
  end
32
35
  Log.i "Running as #{RExec.current_user}"
33
- File.chown DnsOne::DnsOne::STAT_DB, RExec.current_user
34
36
  end
35
37
 
36
38
  match(/(.+)/) do |t| # transaction
@@ -63,8 +63,10 @@ module DnsOne; class Setup
63
63
 
64
64
  def mkdirs
65
65
  FileUtils.mkdir_p DnsOne::CONF_DIR
66
+
66
67
  FileUtils.mkdir_p DnsOne::WORK_DIR
67
68
  File.chmod 0755, DnsOne::WORK_DIR
69
+ File.chmod `id -u #{Server::DEFAULT_RUN_AS}`, nil, DnsOne::WORK_DIR
68
70
  end
69
71
 
70
72
  def setup_finished_msg
@@ -3,14 +3,15 @@ module DnsOne; class Stat
3
3
 
4
4
  def initialize conf = {}
5
5
  @conf = conf
6
-
6
+
7
7
  # Setup logger and current working dir
8
- DnsOne.new
8
+ DnsOne.new if @conf[:from_outside]
9
9
 
10
10
  ensure_db
11
11
  end
12
12
 
13
13
  def save rcode, req_resource, cache
14
+ Log.i "saving stat (user: #{ `id -un #{Process.uid}` })"
14
15
  @db.execute(
15
16
  "INSERT INTO responses (time, rcode, req_resource, cache) VALUES (?, ?, ?, ?)",
16
17
  [
@@ -48,7 +49,7 @@ module DnsOne; class Stat
48
49
  end
49
50
 
50
51
  def self.print
51
- stat = new(db_file: DnsOne::DnsOne::STAT_DB, readonly: true)
52
+ stat = new(from_outside: true, readonly: true)
52
53
  %w(rcode req_resource cache).each do |key|
53
54
  puts "--- #{key} ---"
54
55
  stat.get_counts(key.to_sym).each_pair do |k, v|
@@ -116,10 +117,12 @@ module DnsOne; class Stat
116
117
  opts = {}
117
118
  opts[:readonly] = true if @conf[:readonly]
118
119
 
120
+ Log.i "Opening stat db #{db_file} (cwd: #{Dir.pwd})."
119
121
  @db = SQLite3::Database.new db_file, opts
120
122
 
121
123
  if new_db
122
124
  File.chmod 0644, db_file
125
+ File.chown `id -u #{@conf[:user]}`.to_i, nil, db_file if @conf[:user]
123
126
  create_tables
124
127
  end
125
128
  end
@@ -1,3 +1,3 @@
1
1
  module DnsOne
2
- VERSION = "0.4.31"
2
+ VERSION = "0.4.32"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.31
4
+ version: 0.4.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lobato