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 +4 -4
- data/lib/dns_one/server.rb +5 -3
- data/lib/dns_one/setup.rb +2 -0
- data/lib/dns_one/stat.rb +6 -3
- data/lib/dns_one/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 900d8755b12840905147de4a017db2cc231029a2
|
4
|
+
data.tar.gz: 98d9df6846a22c4a25b0c251c81dfed25bc9c222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38d134a6dc61b371657dec056001fd0858585da70b83a6e5b8c63c2aa28e870f9bda1468663852ea3aa4c3ae82111e5f35b081c7f3379e654d91892b63f36a75
|
7
|
+
data.tar.gz: 189ff251f98d724fd94416e12ef87f74156af648644a275336f6f1fd2e84b44a78f605f6b1b9986a1764d65cc6e4306f7f940d041d18e023f59c7f75e7fe177c
|
data/lib/dns_one/server.rb
CHANGED
@@ -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 =
|
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
|
data/lib/dns_one/setup.rb
CHANGED
@@ -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
|
data/lib/dns_one/stat.rb
CHANGED
@@ -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(
|
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
|
data/lib/dns_one/version.rb
CHANGED