Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TACACS+] Add audisp-tacplus for per-command accounting. #8750

Merged
merged 75 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
00e9867
[TACACS+]: Add TACACS support library and fix memory leak issue.
liuh-80 Aug 31, 2021
7dcf307
Add Bash TACACS+ plugin.
liuh-80 Sep 9, 2021
fff5f0c
Improve code.
liuh-80 Sep 9, 2021
b614455
Integrate audisp-tacplus to SONiC for per-command accounting.
liuh-80 Sep 10, 2021
dcc782b
Fix code according to discussion and PR comments.
liuh-80 Sep 10, 2021
d90e0c8
Fix PR comments
liuh-80 Sep 10, 2021
2f636c5
Improve PR.
liuh-80 Sep 10, 2021
fe7d54a
Fix build issue.
liuh-80 Sep 14, 2021
b53c4f8
Improve code by PR comments.
liuh-80 Sep 16, 2021
22cfd79
Fix make file
Sep 16, 2021
2648dcd
Merge remote-tracking branch 'origin/master' into dev/liuh/tac_suppor…
liuh-80 Sep 17, 2021
8d70ebb
Merge remote-tracking branch 'origin/master' into dev/liuh/bash_tacplus
liuh-80 Sep 17, 2021
660da58
Merge remote-tracking branch 'origin/master' into dev/liuh/tacacs_acc…
liuh-80 Sep 17, 2021
db26d95
Build package with dpkg-buildpackage
liuh-80 Sep 18, 2021
abe81f2
Remove user secret from accounting log.
liuh-80 Sep 29, 2021
bb9fec3
Add setting flag for authorization and accounting.
liuh-80 Sep 29, 2021
6b97d25
Add local accounting support.
liuh-80 Sep 29, 2021
85db4dc
Merge remote-tracking branch 'origin/dev/liuh/tac_support_lib' into d…
liuh-80 Sep 29, 2021
7022bb3
Fix source address code issue..
liuh-80 Oct 1, 2021
19f27fa
Fix trailing whitespace.
liuh-80 Oct 1, 2021
8e3d88f
Fix apply patch issue.
liuh-80 Oct 1, 2021
b30ace5
Fix secret key issue.
liuh-80 Oct 2, 2021
761c1cf
Improve patch file.
liuh-80 Oct 3, 2021
14ea9aa
Fix PR comments.
liuh-80 Oct 8, 2021
ebe5d3d
Merge branch 'dev/liuh/tac_support_lib' into dev/liuh/tacacs_accounting
liuh-80 Oct 8, 2021
24d16a3
Fix PR comments.
liuh-80 Oct 8, 2021
8408454
Merge remote-tracking branch 'origin' into dev/liuh/tacacs_accounting
liuh-80 Oct 14, 2021
829b0df
Merge remote-tracking branch 'origin' into dev/liuh/bash_tacplus
liuh-80 Oct 29, 2021
cc496f4
Improve bash plugin code.
liuh-80 Oct 29, 2021
a729bb6
Fix parse /etc/tacplus_nss.conf issue. also fix server list not clean…
liuh-80 Oct 29, 2021
3bcd3c4
Fix some missing change caused by git history cleanup for PR review.
liuh-80 Oct 29, 2021
00be3e2
Fix PR comments.
liuh-80 Nov 4, 2021
6a89731
Improve patch file.
liuh-80 Nov 4, 2021
60d70b2
Add post-install script to update bash config file.
liuh-80 Nov 5, 2021
36af0f9
Merge remote-tracking branch 'origin' into dev/liuh/bash_tacplus
liuh-80 Nov 5, 2021
0c681ad
Merge remote-tracking branch 'origin' into dev/liuh/tacacs_accounting
liuh-80 Nov 5, 2021
88f6d73
Fix build break issue caused by wrong patch name.
liuh-80 Nov 5, 2021
bb64632
Merge branch 'dev/liuh/bash_tacplus' into dev/liuh/tacacs_accounting
liuh-80 Nov 8, 2021
146392b
Install auditd and plugin to sonic image.
liuh-80 Nov 9, 2021
01876e9
Fix audisp-tacplus build issue.
liuh-80 Nov 9, 2021
a63cdee
Fix make file build error.
liuh-80 Nov 9, 2021
1e24fe8
Fix the bash plugin not installed issue.
liuh-80 Nov 10, 2021
8ecffd4
Merge branch 'dev/liuh/bash_tacplus' into dev/liuh/tacacs_accounting
liuh-80 Nov 10, 2021
6646275
Fix the auditd plugin not installed issue.
liuh-80 Nov 10, 2021
5376bb1
Fix bash tacacs plugin build rule.
liuh-80 Nov 10, 2021
7e5dc6e
Merge branch 'dev/liuh/bash_tacplus' into dev/liuh/tacacs_accounting
liuh-80 Nov 10, 2021
29bef8d
Fix make file issue.
liuh-80 Nov 10, 2021
714de5a
Merge branch 'dev/liuh/bash_tacplus' into dev/liuh/tacacs_accounting
liuh-80 Nov 10, 2021
5c9cd95
Change bash_tacplus build rule to SONIC_DPKG_DEBS because no need to …
liuh-80 Nov 10, 2021
7f3366b
Update patch file according PR comments.
liuh-80 Nov 10, 2021
98f4c3d
Merge branch 'dev/liuh/bash_tacplus' into dev/liuh/tacacs_accounting
liuh-80 Nov 11, 2021
aec6e53
Merge remote-tracking branch 'origin' into dev/liuh/tacacs_accounting
liuh-80 Nov 11, 2021
d4e9e0c
Fix patched version of bash not installed issue.
liuh-80 Nov 11, 2021
ad978e0
Merge branch 'dev/liuh/bash_tacplus' into dev/liuh/tacacs_accounting
liuh-80 Nov 11, 2021
9b7a5d5
Fix build error.
liuh-80 Nov 11, 2021
9cba880
Fix parse debug flag in config file issue.
liuh-80 Nov 12, 2021
02121d0
Merge branch 'dev/liuh/bash_tacplus' into dev/liuh/tacacs_accounting
liuh-80 Nov 13, 2021
e195225
Merge remote-tracking branch 'origin' into dev/liuh/tacacs_accounting
liuh-80 Nov 13, 2021
f1e25fe
Improve code.
liuh-80 Nov 16, 2021
6fec902
Fix PR comments.
liuh-80 Nov 16, 2021
3263cf6
Fix PR comments.
liuh-80 Nov 17, 2021
d8ca1b2
Fix build warning
liuh-80 Nov 17, 2021
4f255b0
Fix patch files by PR comments.
liuh-80 Nov 18, 2021
c37d6dd
Fix auditd plugin not reload config after change tacacs setting issue.
liuh-80 Nov 18, 2021
7227c20
Fix PR comments.
liuh-80 Nov 18, 2021
1d6d6cd
Fix patch description.
liuh-80 Nov 18, 2021
d124e15
Fix PR comments, and send SIGHUP to tacacs plugin for config reload.
liuh-80 Nov 19, 2021
d6c56c4
Improve code with handle exception.
liuh-80 Nov 19, 2021
266fd2b
Improve code by comments.
liuh-80 Nov 23, 2021
278d9d7
Update patch by PR comments
liuh-80 Nov 23, 2021
50d4e25
Improve code by PR comments
liuh-80 Nov 24, 2021
19f3e02
Improve code by load sudoers file into memory.
liuh-80 Nov 24, 2021
792c209
Merge remote-tracking branch 'origin' into dev/liuh/tacacs_accounting
liuh-80 Nov 25, 2021
d1e1c9a
Reset submodule to master branch version.
liuh-80 Nov 25, 2021
e80dd6b
Fix sonic build image failed issue.
liuh-80 Nov 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
haveged \
fdisk \
gpg \
jq
jq \
auditd

if [[ $CONFIGURED_ARCH == amd64 ]]; then
## Pre-install the fundamental packages for amd64 (x86)
Expand Down
3 changes: 3 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/libnss-tacplus_*.deb || \
# Install bash-tacplus
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/bash-tacplus_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
# Install audisp-tacplus
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/audisp-tacplus_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
# Disable tacplus by default
sudo LANG=C chroot $FILESYSTEM_ROOT pam-auth-update --remove tacplus
sudo sed -i -e '/^passwd/s/ tacplus//' $FILESYSTEM_ROOT/etc/nsswitch.conf
Expand Down
13 changes: 10 additions & 3 deletions rules/tacacs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ LIBTAC_DEV = libtac-dev_$(PAM_TACPLUS_VERSION)_$(CONFIGURED_ARCH).deb
$(LIBTAC_DEV)_DEPENDS += $(LIBTAC2)
$(eval $(call add_derived_package,$(LIBTAC2),$(LIBTAC_DEV)))



# libnss-tacplus packages
NSS_TACPLUS_VERSION = 1.0.4-1

Expand All @@ -29,6 +27,16 @@ $(LIBNSS_TACPLUS)_RDEPENDS += $(LIBTAC2)
$(LIBNSS_TACPLUS)_SRC_PATH = $(SRC_PATH)/tacacs/nss
SONIC_MAKE_DEBS += $(LIBNSS_TACPLUS)

# audisp-tacplus packages
AUDISP_TACPLUS_VERSION = 1.0.2

export AUDISP_TACPLUS_VERSION

AUDISP_TACPLUS = audisp-tacplus_$(AUDISP_TACPLUS_VERSION)_$(CONFIGURED_ARCH).deb
$(AUDISP_TACPLUS)_DEPENDS += $(LIBTAC_DEV)
$(AUDISP_TACPLUS)_RDEPENDS += $(LIBTAC2)
$(AUDISP_TACPLUS)_SRC_PATH = $(SRC_PATH)/tacacs/audisp
SONIC_MAKE_DEBS += $(AUDISP_TACPLUS)

# bash-tacplus packages
BASH_TACPLUS_VERSION = 1.0.0
Expand All @@ -41,7 +49,6 @@ $(BASH_TACPLUS)_RDEPENDS += $(LIBTAC2)
$(BASH_TACPLUS)_SRC_PATH = $(SRC_PATH)/tacacs/bash_tacplus
SONIC_DPKG_DEBS += $(BASH_TACPLUS)


# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list}
# are archived into debug one image to facilitate debugging.
#
Expand Down
3 changes: 2 additions & 1 deletion slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
$(SONIC_UTILITIES_DATA) \
$(SONIC_HOST_SERVICES_DATA) \
$(BASH) \
$(BASH_TACPLUS)) \
$(BASH_TACPLUS) \
$(AUDISP_TACPLUS)) \
$$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS)) \
$$(addprefix $(TARGET_PATH)/,$$(SONIC_PACKAGES_LOCAL)) \
$$(addprefix $(FILES_PATH)/,$$($$*_FILES)) \
Expand Down
5 changes: 4 additions & 1 deletion sonic-slave-bullseye/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ RUN apt-get update && apt-get install -y \
libdbus-1-dev \
libgirepository1.0-dev \
libsystemd-dev \
pkg-config
pkg-config \
# For audisp-tacplus
libauparse-dev \
auditd

RUN apt-get -y build-dep openssh

Expand Down
5 changes: 4 additions & 1 deletion sonic-slave-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,10 @@ RUN apt-get update && apt-get install -y \
libdbus-1-dev \
libgirepository1.0-dev \
libsystemd-dev \
pkg-config
pkg-config \
# For audisp-tacplus
libauparse-dev \
auditd

RUN apt-get -y build-dep openssh

Expand Down
3 changes: 3 additions & 0 deletions sonic-slave-jessie/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ RUN apt-get update && apt-get install -y \
libcunit1-dev \
# For initramfs
bash-completion \
# For audisp-tacplus
libauparse-dev \
auditd \
{% if CONFIGURED_ARCH == "amd64" -%}
# For sonic vs image build
dosfstools \
Expand Down
5 changes: 4 additions & 1 deletion sonic-slave-stretch/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ RUN apt-get update && apt-get install -y \
libxml2-utils \
xsltproc \
python-lxml \
libexpat1-dev
libexpat1-dev \
# For audisp-tacplus
libauparse-dev \
auditd

# Install dependencies for dhcp relay test
RUN pip3 install parameterized==0.8.1
Expand Down
27 changes: 27 additions & 0 deletions src/sonic-host-services/scripts/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ def obfuscate(data):
else:
return data

def get_pid(procname):
for dirname in os.listdir('/proc'):
if dirname == 'curproc':
continue
try:
with open('/proc/{}/cmdline'.format(dirname), mode='r') as fd:
content = fd.read()
except Exception as ex:
continue
if procname in content:
return dirname
return ""

class Feature(object):
""" Represents a feature configuration from CONFIG_DB data. """
Expand Down Expand Up @@ -534,6 +546,18 @@ class AaaCfg(object):
if modify_conf:
self.modify_conf_file()

def notify_audisp_tacplus_reload_config(self):
pid = get_pid("/sbin/audisp-tacplus")
syslog.syslog(syslog.LOG_INFO, "Found audisp-tacplus PID: {}".format(pid))
if pid == "":
return

# audisp-tacplus will reload TACACS+ config when receive SIGHUP
try:
os.kill(int(pid), signal.SIGHUP)
except Exception as ex:
syslog.syslog(syslog.LOG_WARNING, "Send SIGHUP to audisp-tacplus failed with exception: {}".format(ex))

def handle_radius_source_intf_ip_chg(self, key):
modify_conf=False
if 'src_intf' in self.radius_global:
Expand Down Expand Up @@ -769,6 +793,9 @@ class AaaCfg(object):
with open(NSS_TACPLUS_CONF, 'w') as f:
f.write(nss_tacplus_conf)

# Notify auditd plugin to reload tacacs config.
self.notify_audisp_tacplus_reload_config()

# Set debug in nss-radius conf
template_file = os.path.abspath(NSS_RADIUS_CONF_TEMPLATE)
template = env.get_template(template_file)
Expand Down
3 changes: 3 additions & 0 deletions src/tacacs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*
!.gitignore
audisp/*
!audisp/Makefile
!audisp/*.patch
!bash_tacplus/*
nsm/*
!nsm/Makefile
Expand Down
30 changes: 30 additions & 0 deletions src/tacacs/audisp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e

MAIN_TARGET = audisp-tacplus_$(AUDISP_TACPLUS_VERSION)_$(CONFIGURED_ARCH).deb

$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Obtain audisp-tacplus
rm -rf ./audisp-tacplus

git clone https://github.com/daveolson53/audisp-tacplus.git

# checkout by sha1
pushd ./audisp-tacplus
git checkout 559c9f22edd4f2dea0ecedffb3ad9502b12a75b6
liuh-80 marked this conversation as resolved.
Show resolved Hide resolved

# Apply patches
cp -r ../patches patches
quilt push -a

# fix aclocal depency issue by run auto.sh
./auto.sh

# build package
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR)
popd

mv $(DERIVED_TARGETS) $* $(DEST)/

$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET)
Loading