mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-10-24 23:18:16 +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
252 lines
6.5 KiB
YAML+Jinja
252 lines
6.5 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 %}
|
|
{% from 'elasticsearch/config.map.jinja' import ELASTICSEARCHMERGED %}
|
|
|
|
vm.max_map_count:
|
|
sysctl.present:
|
|
- value: {{ ELASTICSEARCHMERGED.vm.max_map_count }}
|
|
|
|
# Add ES Group
|
|
elasticsearchgroup:
|
|
group.present:
|
|
- name: elasticsearch
|
|
- gid: 930
|
|
|
|
esconfdir:
|
|
file.directory:
|
|
- name: /opt/so/conf/elasticsearch
|
|
- user: 930
|
|
- group: 939
|
|
- makedirs: True
|
|
|
|
# Add ES user
|
|
elasticsearch:
|
|
user.present:
|
|
- uid: 930
|
|
- gid: 930
|
|
- home: /opt/so/conf/elasticsearch
|
|
- createhome: False
|
|
- shell: /sbin/nologin
|
|
|
|
elasticsearch_sbin:
|
|
file.recurse:
|
|
- name: /usr/sbin
|
|
- source: salt://elasticsearch/tools/sbin
|
|
- user: root
|
|
- group: root
|
|
- file_mode: 755
|
|
- exclude_pat:
|
|
- so-elasticsearch-pipelines # exclude this because we need to watch it for changes, we sync it in another state
|
|
- so-elasticsearch-system-indices-patch
|
|
- show_changes: False
|
|
|
|
so-elasticsearch-system-indices-patch-script:
|
|
file.managed:
|
|
- name: /usr/sbin/so-elasticsearch-system-indices-patch
|
|
- source: salt://elasticsearch/tools/sbin/so-elasticsearch-system-indices-patch
|
|
- user: root
|
|
- group: root
|
|
- mode: 755
|
|
- show_changes: False
|
|
|
|
elasticsearch_sbin_jinja:
|
|
file.recurse:
|
|
- name: /usr/sbin
|
|
- source: salt://elasticsearch/tools/sbin_jinja
|
|
- user: root
|
|
- group: root
|
|
- file_mode: 755
|
|
- template: jinja
|
|
- exclude_pat:
|
|
- so-elasticsearch-ilm-policy-load # exclude this because we need to watch it for changes, we sync it in another state
|
|
- defaults:
|
|
GLOBALS: {{ GLOBALS }}
|
|
- show_changes: False
|
|
|
|
so-elasticsearch-ilm-policy-load-script:
|
|
file.managed:
|
|
- name: /usr/sbin/so-elasticsearch-ilm-policy-load
|
|
- source: salt://elasticsearch/tools/sbin_jinja/so-elasticsearch-ilm-policy-load
|
|
- user: root
|
|
- group: root
|
|
- mode: 754
|
|
- template: jinja
|
|
- defaults:
|
|
GLOBALS: {{ GLOBALS }}
|
|
- show_changes: False
|
|
|
|
so-elasticsearch-pipelines-script:
|
|
file.managed:
|
|
- name: /usr/sbin/so-elasticsearch-pipelines
|
|
- source: salt://elasticsearch/tools/sbin/so-elasticsearch-pipelines
|
|
- user: root
|
|
- group: root
|
|
- mode: 754
|
|
- show_changes: False
|
|
|
|
esingestdir:
|
|
file.directory:
|
|
- name: /opt/so/conf/elasticsearch/ingest
|
|
- user: 930
|
|
- group: 939
|
|
- makedirs: True
|
|
|
|
estemplatedir:
|
|
file.directory:
|
|
- name: /opt/so/conf/elasticsearch/templates/index
|
|
- user: 930
|
|
- group: 939
|
|
- makedirs: True
|
|
|
|
esaddontemplatedir:
|
|
file.directory:
|
|
- name: /opt/so/conf/elasticsearch/templates/addon-index
|
|
- user: 930
|
|
- group: 939
|
|
- makedirs: True
|
|
|
|
esrolesdir:
|
|
file.directory:
|
|
- name: /opt/so/conf/elasticsearch/roles
|
|
- user: 930
|
|
- group: 939
|
|
- makedirs: True
|
|
|
|
esingestdynamicconf:
|
|
file.recurse:
|
|
- name: /opt/so/conf/elasticsearch/ingest
|
|
- source: salt://elasticsearch/files/ingest-dynamic
|
|
- user: 930
|
|
- group: 939
|
|
- template: jinja
|
|
- show_changes: False
|
|
|
|
esingestconf:
|
|
file.recurse:
|
|
- name: /opt/so/conf/elasticsearch/ingest
|
|
- source: salt://elasticsearch/files/ingest
|
|
- user: 930
|
|
- group: 939
|
|
- show_changes: False
|
|
|
|
# Auto-generate Elasticsearch ingest node pipelines from pillar
|
|
{% for pipeline, config in ELASTICSEARCHMERGED.pipelines.items() %}
|
|
es_ingest_conf_{{pipeline}}:
|
|
file.managed:
|
|
- name: /opt/so/conf/elasticsearch/ingest/{{ pipeline }}
|
|
- source: salt://elasticsearch/base-template.json.jinja
|
|
- defaults:
|
|
TEMPLATE_CONFIG: {{ config }}
|
|
- template: jinja
|
|
- onchanges_in:
|
|
- file: so-pipelines-reload
|
|
{% endfor %}
|
|
|
|
eslog4jfile:
|
|
file.managed:
|
|
- name: /opt/so/conf/elasticsearch/log4j2.properties
|
|
- source: salt://elasticsearch/files/log4j2.properties
|
|
- user: 930
|
|
- group: 939
|
|
- template: jinja
|
|
|
|
esyml:
|
|
file.managed:
|
|
- name: /opt/so/conf/elasticsearch/elasticsearch.yml
|
|
- source: salt://elasticsearch/files/elasticsearch.yaml.jinja
|
|
- user: 930
|
|
- group: 939
|
|
- defaults:
|
|
ESCONFIG: {{ ELASTICSEARCHMERGED.config }}
|
|
- template: jinja
|
|
- show_changes: False
|
|
|
|
esroles:
|
|
file.recurse:
|
|
- source: salt://elasticsearch/roles/
|
|
- name: /opt/so/conf/elasticsearch/roles/
|
|
- clean: True
|
|
- template: jinja
|
|
- user: 930
|
|
- group: 939
|
|
- show_changes: False
|
|
|
|
nsmesdir:
|
|
file.directory:
|
|
- name: /nsm/elasticsearch
|
|
- user: 930
|
|
- group: 939
|
|
- makedirs: True
|
|
|
|
eslogdir:
|
|
file.directory:
|
|
- name: /opt/so/log/elasticsearch
|
|
- user: 930
|
|
- group: 939
|
|
- makedirs: True
|
|
|
|
es_repo_dir:
|
|
file.directory:
|
|
- name: /nsm/elasticsearch/repo/
|
|
- user: 930
|
|
- group: 930
|
|
- require:
|
|
- file: nsmesdir
|
|
|
|
so-pipelines-reload:
|
|
file.absent:
|
|
- name: /opt/so/state/espipelines.txt
|
|
- onchanges:
|
|
- file: esingestconf
|
|
- file: esingestdynamicconf
|
|
- file: esyml
|
|
- file: so-elasticsearch-pipelines-script
|
|
|
|
auth_users:
|
|
file.managed:
|
|
- name: /opt/so/conf/elasticsearch/users.tmp
|
|
- source: salt://elasticsearch/files/users
|
|
- user: 930
|
|
- group: 930
|
|
- mode: 600
|
|
- show_changes: False
|
|
|
|
auth_users_roles:
|
|
file.managed:
|
|
- name: /opt/so/conf/elasticsearch/users_roles.tmp
|
|
- source: salt://elasticsearch/files/users_roles
|
|
- user: 930
|
|
- group: 930
|
|
- mode: 600
|
|
- show_changes: False
|
|
|
|
auth_users_inode:
|
|
require:
|
|
- file: auth_users
|
|
cmd.run:
|
|
- name: cat /opt/so/conf/elasticsearch/users.tmp > /opt/so/conf/elasticsearch/users && chown 930:939 /opt/so/conf/elasticsearch/users && chmod 660 /opt/so/conf/elasticsearch/users
|
|
- onchanges:
|
|
- file: /opt/so/conf/elasticsearch/users.tmp
|
|
|
|
auth_users_roles_inode:
|
|
require:
|
|
- file: auth_users_roles
|
|
cmd.run:
|
|
- name: cat /opt/so/conf/elasticsearch/users_roles.tmp > /opt/so/conf/elasticsearch/users_roles && chown 930:939 /opt/so/conf/elasticsearch/users_roles && chmod 660 /opt/so/conf/elasticsearch/users_roles
|
|
- onchanges:
|
|
- file: /opt/so/conf/elasticsearch/users_roles.tmp
|
|
|
|
{% else %}
|
|
|
|
{{sls}}_state_not_allowed:
|
|
test.fail_without_changes:
|
|
- name: {{sls}}_state_not_allowed
|
|
|
|
{% endif %}
|