Browse Source

Agent: check that passwd file is OK and readable

master
Pekka Helenius 4 years ago
parent
commit
53f1210a84
1 changed files with 9 additions and 5 deletions
  1. +9
    -5
      tools/pamusb-agent

+ 9
- 5
tools/pamusb-agent View File

@ -275,11 +275,15 @@ udisksObjectManager = udisks.get_object_manager()
sysUsers= [] sysUsers= []
validUsers = [] validUsers = []
with open('/etc/passwd', 'r') as f:
for line in f.readlines():
sysUser = re.sub(r'^(.*?):.*', '\\1', line[:-1])
sysUsers.append(sysUser)
f.close()
try:
with open('/etc/passwd', 'r') as f:
for line in f.readlines():
sysUser = re.sub(r'^(.*?):.*', '\\1', line[:-1])
sysUsers.append(sysUser)
f.close()
except:
logger.error('Couldn\'t read system user names from "/etc/passwd". Process can\'t continue.')
sys.exit(1)
logger.info('pamusb-agent up and running.') logger.info('pamusb-agent up and running.')


Loading…
Cancel
Save