Skip to content

Commit 6d85519

Browse files
whotwagnerWolfgang Hotwagner
andcommitted
aminer.py: resolved hardcoded username and gropname where user_id and… (#614)
* aminer.py: resolved hardcoded username and gropname where user_id and group_id was expected * aminer.py: fixed bug in getgrnam(). username was taken instead of groupname Co-authored-by: Wolfgang Hotwagner <wolfgang.hotwagner@ait.ac.at>
1 parent 0acdac1 commit 6d85519

File tree

1 file changed

+15
-2
lines changed
  • source/root/usr/lib/logdata-anomaly-miner

1 file changed

+15
-2
lines changed

source/root/usr/lib/logdata-anomaly-miner/aminer.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def main():
281281
if child_user_name is not None:
282282
child_user_id = getpwnam(child_user_name).pw_uid
283283
if child_group_name is not None:
284-
child_group_id = getgrnam(child_user_name).gr_gid
284+
child_group_id = getgrnam(child_group_name).gr_gid
285285
except: # skipcq: FLK-E722
286286
print('Failed to resolve %s or %s' % (AminerConfig.KEY_AMINER_USER, AminerConfig.KEY_AMINER_GROUP), file=sys.stderr)
287287
sys.exit(1)
@@ -520,7 +520,20 @@ def graceful_shutdown_handler(_signo, _stackFrame):
520520
else:
521521
msg = 'INFO: No privilege separation when started as unprivileged user'
522522
print(msg, file=sys.stderr)
523-
initialize_loggers(aminer_config, 'aminer', 'aminer')
523+
tmp_username = aminer_config.config_properties.get(AminerConfig.KEY_AMINER_USER)
524+
tmp_group = aminer_config.config_properties.get(AminerConfig.KEY_AMINER_GROUP)
525+
aminer_user_id = -1
526+
aminer_group_id = -1
527+
try:
528+
if tmp_username is not None:
529+
aminer_user_id = getpwnam(tmp_username).pw_uid
530+
if tmp_group is not None:
531+
aminer_group_id = getgrnam(tmp_group).gr_gid
532+
except: # skipcq: FLK-E722
533+
print('Failed to resolve %s or %s' % (AminerConfig.KEY_AMINER_USER, AminerConfig.KEY_AMINER_GROUP), file=sys.stderr)
534+
sys.exit(1)
535+
536+
initialize_loggers(aminer_config, aminer_user_id, aminer_group_id)
524537
logging.getLogger(AminerConfig.DEBUG_LOG_NAME).info(msg)
525538

526539
# Now resolve the specific analysis configuration file (if any).

0 commit comments

Comments
 (0)