mirror of
https://github.com/cmur2/dyndnsd.git
synced 2024-12-21 14:54:22 +01:00
dyndnsd: handle potential nil cases detected by sorbet
- including review suggestions from @jgraichen
This commit is contained in:
parent
0317189057
commit
af5e4ca3e0
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.1.1
|
||||||
|
|
||||||
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
- Fix potential `nil` cases detected by [Sorbet](https://sorbet.org) including refactorings
|
||||||
|
|
||||||
## 2.1.0 (March 1, 2020)
|
## 2.1.0 (March 1, 2020)
|
||||||
|
|
||||||
IMPROVEMENTS:
|
IMPROVEMENTS:
|
||||||
|
@ -112,8 +112,14 @@ module Dyndnsd
|
|||||||
|
|
||||||
# drop priviliges as soon as possible
|
# drop priviliges as soon as possible
|
||||||
# NOTE: first change group than user
|
# NOTE: first change group than user
|
||||||
Process::Sys.setgid(Etc.getgrnam(config['group']).gid) if config['group']
|
if config['group']
|
||||||
Process::Sys.setuid(Etc.getpwnam(config['user']).uid) if config['user']
|
group = Etc.getgrnam(config['group'])
|
||||||
|
Process::Sys.setgid(group.gid) if group
|
||||||
|
end
|
||||||
|
if config['user']
|
||||||
|
user = Etc.getpwnam(config['user'])
|
||||||
|
Process::Sys.setuid(user.uid) if user
|
||||||
|
end
|
||||||
|
|
||||||
setup_traps
|
setup_traps
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ module Dyndnsd
|
|||||||
# @return [void]
|
# @return [void]
|
||||||
def load
|
def load
|
||||||
if File.file?(@db_file)
|
if File.file?(@db_file)
|
||||||
@db = JSON.parse(File.open(@db_file, 'r', &:read))
|
@db = JSON.parse(File.read(@db_file, mode: 'r'))
|
||||||
else
|
else
|
||||||
@db = {}
|
@db = {}
|
||||||
end
|
end
|
||||||
|
@ -57,7 +57,7 @@ module Dyndnsd
|
|||||||
'error.kind': e.class.to_s,
|
'error.kind': e.class.to_s,
|
||||||
'error.object': e,
|
'error.object': e,
|
||||||
message: e.message,
|
message: e.message,
|
||||||
stack: e.backtrace.join("\n")
|
stack: e.backtrace&.join("\n") || ''
|
||||||
)
|
)
|
||||||
raise
|
raise
|
||||||
ensure
|
ensure
|
||||||
|
@ -14,7 +14,7 @@ module Dyndnsd
|
|||||||
# @return [void]
|
# @return [void]
|
||||||
def update(db)
|
def update(db)
|
||||||
Helper.span('updater_update') do |span|
|
Helper.span('updater_update') do |span|
|
||||||
span.set_tag('dyndnsd.updater.name', self.class.name.split('::').last)
|
span.set_tag('dyndnsd.updater.name', self.class.name&.split('::')&.last || 'None')
|
||||||
|
|
||||||
# write zone file in bind syntax
|
# write zone file in bind syntax
|
||||||
File.open(@zone_file, 'w') { |f| f.write(@generator.generate(db)) }
|
File.open(@zone_file, 'w') { |f| f.write(@generator.generate(db)) }
|
||||||
@ -24,7 +24,7 @@ module Dyndnsd
|
|||||||
end
|
end
|
||||||
|
|
||||||
# detach so children don't become zombies
|
# detach so children don't become zombies
|
||||||
Process.detach(pid)
|
Process.detach(pid) if pid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user