Commit 130e9f64 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Don't throw exceptions when collecting metadata

Make sure to check all the file paths before opening files to collect
metadata. The metadata collecting process takes place in the beginning
and the user cannot control it. Warn if something is missing but do not
throw exceptions
parent cd54eace
......@@ -101,6 +101,12 @@ class Bsd(Unix):
def _get_passworded_users(self):
"""Returns a list of non-locked user accounts"""
if not self.g.is_file('/etc/master.passwd'):
self.out.warn("Unable to collect user info. "
"File: `/etc/master.passwd' is missing!")
return []
users = []
regexp = re.compile(
'^([^:]+):((?:![^:]+)|(?:[^!*][^:]+)|):(?:[^:]*:){7}(?:[^:]*)'
......
......@@ -569,6 +569,12 @@ class Linux(Unix):
def _get_passworded_users(self):
"""Returns a list of non-locked user accounts"""
if not self.image.g.is_file('/etc/shadow'):
self.out.warn(
"Unable to collect user info. File: `/etc/shadow' is missing!")
return []
users = []
regexp = re.compile(r'(\S+):((?:!\S+)|(?:[^!*]\S+)|):(?:\S*:){6}')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment