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

make sure ufw.log always exists for fail2ban #937

Merged
merged 3 commits into from
Aug 18, 2019

Conversation

dhiltonp
Copy link
Contributor

@dhiltonp dhiltonp commented Jul 5, 2019

Full discussion in #913
Not fully tested as I'm currently remote.

@nachoparker
Copy link
Member

Many thanks! You are right. This would be over-written by an update. I think that the correct place to introduce the touch command would be /etc/systemd/system/fail2ban.service.d, which is a system drop-in unit rule that I already use for fail2ban and does not get replaced during updates.

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Jul 5, 2019

Those are conf files, the don't seem executable?

@nachoparker
Copy link
Member

nachoparker commented Jul 5, 2019

They are unit files. You can try creating a file named /etc/systemd/system/fail2ban.service.d/touch-ufw-logfile.conf

with these contents

[Service]
ExecStartPre=/bin/touch /var/log/ufw.log

The logfile should always appear even if UFW is disabled, as long as fail2ban is enabled.

https://www.freedesktop.org/software/systemd/man/systemd.unit.html

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Jul 8, 2019

I'll be able to test that change in about a week.

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Aug 8, 2019

Updated. I've manually applied these changes and tested the result and it works fine.

There are still some things I don't quite understand:

UFW.sh has something to "disable logging to kernel":
grep -q maxsize /etc/logrotate.d/ufw || sed -i /weekly/amaxsize2M /etc/logrotate.d/ufw

Looking at things, maybe we should do sed -i 's/#\& stop/\& stop /' /etc/rsyslog.d/20-ufw.conf instead? It would log UFW messages to ufw.log only, removing UFW logs from /var/log/messages.

I also don't understand how /var/log.hdd/ fits in with all of this...

@nachoparker
Copy link
Member

Thanks! that comment does not explain what that line does. We are just limiting the size of the logfile.

/var/log.hdd is part of the ram2logs scheme

@nachoparker nachoparker changed the base branch from master to devel August 18, 2019 21:49
@nachoparker nachoparker merged commit 0abc00f into nextcloud:devel Aug 18, 2019
nachoparker pushed a commit that referenced this pull request Sep 5, 2019
* make sure ufw.log always exists for fail2ban
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants