mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-10-24 15:08:10 +02:00
These accounts existed only for container UID mapping and filesystem ownership, but user.present omitted shell:, so Salt fell through to the platform useradd default and every one of them got /bin/bash. Pin them to /sbin/nologin so none can be used as an interactive login or `su -` target. socore keeps /bin/bash: `su socore -c '/usr/sbin/so-repo-sync'` in soup and so-kernel-upgrade execs the account's passwd shell, and operator docs tell users to su to socore. soqemussh keeps /bin/bash as an SSH login account. elastic-agent, elastic-agent-pr and kafka are included alongside the accounts named in the issue, being the same class with the same unset shell, so the default is uniform. Cron is unaffected: cronie runs jobs via the crontab SHELL (default /bin/sh), not the passwd shell. suricata is the only account changed here that owns a crontab, and somon has shipped as nologin with a working cron job already. The zeek `runuser -l zeek` calls all run inside so-zeek via docker.run/exec, so they resolve the shell from the image, not the host. Verified on a 3.4.0 managersearch + sensor grid: highstate converges with the shell as the only change and no failures, is idempotent on a second run, all containers stay up, SOC still issues a Kratos login flow, and the suricata surilogcompress cron job runs post-change ((suricata) CMD/CMDEND in /var/log/cron) while `su - suricata` is now refused. Closes #16256
110 lines
2.7 KiB
YAML+Jinja
110 lines
2.7 KiB
YAML+Jinja
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
|
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
|
# Elastic License 2.0.
|
|
|
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
|
{% if sls.split('.')[0] in allowed_states %}
|
|
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
|
{% set KAFKA_EXTERNAL_ACCESS = salt['pillar.get']('kafka:config:external_access:enabled', default=False) %}
|
|
{% set KAFKA_EXTERNAL_USERS = salt['pillar.get']('kafka:config:external_access:remote_users', default=None) %}
|
|
|
|
kafka_group:
|
|
group.present:
|
|
- name: kafka
|
|
- gid: 960
|
|
|
|
kafka_user:
|
|
user.present:
|
|
- name: kafka
|
|
- uid: 960
|
|
- gid: 960
|
|
- home: /opt/so/conf/kafka
|
|
- createhome: False
|
|
- shell: /sbin/nologin
|
|
|
|
kafka_home_dir:
|
|
file.absent:
|
|
- name: /home/kafka
|
|
|
|
kafka_sbin_tools:
|
|
file.recurse:
|
|
- name: /usr/sbin
|
|
- source: salt://kafka/tools/sbin
|
|
- user: root
|
|
- group: root
|
|
- file_mode: 755
|
|
|
|
kafka_sbin_jinja_tools:
|
|
file.recurse:
|
|
- name: /usr/sbin
|
|
- source: salt://kafka/tools/sbin_jinja
|
|
- user: root
|
|
- group: root
|
|
- file_mode: 755
|
|
- template: jinja
|
|
- defaults:
|
|
GLOBALS: {{ GLOBALS }}
|
|
|
|
kafka_log_dir:
|
|
file.directory:
|
|
- name: /opt/so/log/kafka
|
|
- user: 960
|
|
- group: 960
|
|
- makedirs: True
|
|
|
|
kafka_data_dir:
|
|
file.directory:
|
|
- name: /nsm/kafka/data
|
|
- user: 960
|
|
- group: 960
|
|
- makedirs: True
|
|
|
|
{% for sc in ['server', 'client'] %}
|
|
kafka_kraft_{{sc}}_properties:
|
|
file.managed:
|
|
- source: salt://kafka/etc/{{sc}}.properties.jinja
|
|
- name: /opt/so/conf/kafka/{{sc}}.properties
|
|
- template: jinja
|
|
- user: 960
|
|
- group: 960
|
|
- makedirs: True
|
|
- show_changes: False
|
|
{% endfor %}
|
|
|
|
{% if KAFKA_EXTERNAL_ACCESS and KAFKA_EXTERNAL_USERS != None %}
|
|
kafka_server_jaas_properties:
|
|
file.managed:
|
|
- source: salt://kafka/etc/jaas.conf.jinja
|
|
- name: /opt/so/conf/kafka/kafka_server_jaas.conf
|
|
- template: jinja
|
|
- user: 960
|
|
- group: 960
|
|
- show_changes: False
|
|
{% else %}
|
|
remove_kafka_server_jaas_properties:
|
|
file.absent:
|
|
- name: /opt/so/conf/kafka/kafka_server_jaas.conf
|
|
{% endif %}
|
|
|
|
kafka_log4j_properties:
|
|
file.managed:
|
|
- source: salt://kafka/etc/log4j.properties
|
|
- name: /opt/so/conf/kafka/log4j.properties
|
|
- user: 960
|
|
- group: 960
|
|
- show_changes: False
|
|
|
|
reset_quorum_on_changes:
|
|
cmd.run:
|
|
- name: rm -f /nsm/kafka/data/__cluster_metadata-0/quorum-state
|
|
- onchanges:
|
|
- file: /opt/so/conf/kafka/server.properties
|
|
|
|
{% else %}
|
|
|
|
{{sls}}_state_not_allowed:
|
|
test.fail_without_changes:
|
|
- name: {{sls}}_state_not_allowed
|
|
|
|
{% endif %} |