sys_watchdog 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f39f191011aaf4a69db5a28cde3f2e6e9450bce
4
- data.tar.gz: 4687705af6759a0c840555d41bbadb0a25d254bf
3
+ metadata.gz: 8b5d8ce60452d7cb903a2697529859053766ef00
4
+ data.tar.gz: 5d15318e73ca47fd19b474cf16f05c3b1f907f03
5
5
  SHA512:
6
- metadata.gz: 0139b5c79facdbddf24e6fb3a371e127155bd2f2221e716a439754f3f427ec270b2b66966a157956b19ced950b54b93f360c937e1be4baf2d163de0c48c6da05
7
- data.tar.gz: dc172e792d5ab7167b32342c1b5069f3b30ed30ec6d12c052037beece9fb742f64ca7b8857ba67102927247c19e15ece026d44bea24817904ddbd82f2335dd3f
6
+ metadata.gz: 659d67ced91f0baa02dd6fec9eb55d4230d4e5ec1ccbec723436f015a68d6d57c53c42850db0b81a3a626678cdbf30657b69b8301eeb55c7aa6e7d3b9726f6c4
7
+ data.tar.gz: dfa89933f40756dc2f58f612e59a29092453e69e86eba8534bb182bae3ea5cacccae000a49e8a72b7857afc89781716440fa7b84722c4403b1c0edf6f63a4f4c
data/README.md CHANGED
@@ -13,8 +13,6 @@ Take 20min to install and start to think what you\`ll make with your spare time
13
13
  [Rio de Janeiro](https://www.google.com/search?q=rio+de+janeiro&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi10v2Z8sjUAhXCcRQKHYvFBpMQ_AUIDCgD&biw=1440&bih=799)?
14
14
  It\`s up to you ;)
15
15
 
16
- ![](images/dev_on_the_beach.jpg)
17
-
18
16
  ## Install
19
17
 
20
18
  **Perform this and following steps logged as root user.**
@@ -3,7 +3,7 @@ class SysWatchdog
3
3
  DEFAULT_LOG_FILE = '/var/log/sys_watchdog.log'
4
4
 
5
5
  def initialize conf_file: nil, log_file: nil
6
- log_file ||= DEFAULT_LOG_FILE
6
+ log_file ||= DEFAULT_LOG_FILE
7
7
  conf_file ||= DEFAULT_CONF_FILE
8
8
 
9
9
  @logger = WdLogger.new log_file
@@ -37,7 +37,7 @@ class SysWatchdog
37
37
  end
38
38
 
39
39
  def parse_conf conf_file
40
- raise "Conf file #{conf_file} not found." unless File.exist? conf_file
40
+ check_conf_file conf_file
41
41
 
42
42
  conf = YAML.load_file conf_file
43
43
  conf.deep_symbolize_keys!
@@ -49,6 +49,23 @@ class SysWatchdog
49
49
  }
50
50
  end
51
51
 
52
+ def check_conf_file conf_file
53
+ unless File.readable? conf_file
54
+ raise "Conf file #{conf_file} not found or unreadable. Aborting."
55
+ end
56
+
57
+ conf_stat = File.stat conf_file
58
+
59
+ unless conf_stat.mode.to_s(8) =~ /0600$/
60
+ raise "Conf file #{conf_file} must have mode 0600. Aborting."
61
+ end
62
+
63
+ unless (conf_stat.uid == 0 and conf_stat.gid == 0) or
64
+ (conf_stat.uid == Process.uid and conf_stat.gid == Process.gid)
65
+ raise "Conf file #{conf_file} must have uid/gid set to root or to current running uid/gid. Aborting."
66
+ end
67
+ end
68
+
52
69
  def run_test test, after_restore: false
53
70
  new_status, exitstatus, output = test.run
54
71
 
@@ -56,9 +56,10 @@ class Setup
56
56
  SysWatchdog::DEFAULT_CONF_FILE
57
57
  end
58
58
 
59
- def copy from, to
59
+ def copy from, to, mod = 0600
60
60
  puts "Copying #{from} to #{to}..."
61
61
  FileUtils.cp from, to
62
+ FileUtils.chmod mod, to
62
63
  end
63
64
 
64
65
  def run cmd
data/sys_watchdog.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "sys_watchdog"
3
- s.version = "0.1.1"
3
+ s.version = "0.1.2"
4
4
  s.authors = ["Tom Lobato"]
5
5
  s.email = "lobato@bettercall.io"
6
6
  s.homepage = "http://sys-watchdog.bettercall.io/"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys_watchdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lobato
@@ -54,7 +54,6 @@ files:
54
54
  - _config.yml
55
55
  - bin/sys_watchdog
56
56
  - gempush
57
- - images/dev_on_the_beach.jpg
58
57
  - images/register-bot.png
59
58
  - lib/sys_watchdog.rb
60
59
  - lib/sys_watchdog/core_extensions.rb
Binary file