Skip to content

Adds SysLogHandler to log everything on rsyslog #692

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

Merged
merged 1 commit into from
Jan 16, 2020
Merged

Conversation

kushaldas
Copy link
Contributor

@kushaldas kushaldas commented Jan 10, 2020

Now all log lines will go to /var/log/syslog file.
Also black reformatted the file.

Test Plan

  • Run the application
  • Try to Login as a journalist account (name or password is incorrect)
  • login with a proper account

You should be able to see the log entries in /var/log/syslog file.

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

@kushaldas kushaldas force-pushed the use_rsyslog branch 4 times, most recently from a6ff478 to 9748eb2 Compare January 10, 2020 12:41
Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we put the black change in another PR? (since it will need similar changes as https://github.com/freedomofpress/securedrop-proxy/issues/57)

@kushaldas
Copy link
Contributor Author

can we put the black change in another PR? (since it will need similar changes as freedomofpress/securedrop-proxy#144)

Yes, I will remove my autoformat tool from VS Code first :) I will repush this PR with only the code change.

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also log to a separate client.log file like we currently do? This makes it difficult to develop or repro an issue and provide logs if there are bunch of kernel and other logs mixed in with client logs.

As far as the black formatter changes, I think we should agree on what the standard should be for the client that black will enforce before committing changes. Perhaps we could have a separate PR that introduces black formatting changes across all files?

@rmol
Copy link
Contributor

rmol commented Jan 10, 2020

With rsyslog it's possible to route log messages to an application-specific destination. We could put securedrop-client: at the beginning of our log format template and add an rsyslog conf snippet containing:

if $programname == "securedrop-client" then /var/log/securedrop-client.log
& stop

If we further change /etc/rsyslog.conf so that user facility messages are not written to /var/log/syslog, by adding user.none here:

*.*;auth,authpriv,user.none		-/var/log/syslog

then our logging would only go to that dedicated file.

This could be done locally, in the centralized logging VM, or both. If having the file under /var/log/ is sufficient, no more changes need to be made to the securedrop-client code, but if we want to preserve the old behavior of logging under SDC_HOME we'll need to add back the old handler.

Personally, I think I'd find a single log file in the central VM containing all workstation-related logging -- from client, proxy, everything -- the most useful.

@kushaldas
Copy link
Contributor Author

Found the discussion on black #23 it was for securedrop-client itself :)

@kushaldas
Copy link
Contributor Author

Personally, I think I'd find a single log file in the central VM containing all workstation-related logging -- from client, proxy, everything -- the most useful.

I think that was the idea to have rsyslog enabled. This way we can monitor the status of the VM and also our application in the same place.

To see only the client related logs, one can do tail -f /var/log/syslog | grep client to grep out the required lines.

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we no longer allow logs to be written to {sdc-home}/logs then docs will need to be updated with this change here to explain where to look for logs and how to find specific logs, e.g. tail -f /var/log/syslog | grep client (we might want to change this to tail -f /var/log/syslog | grep securedrop-client to make it less likely to capture extra logs we don't want and hopefully other applications don't mention "securedrop-client" anywhere in their logs but if they do i guess we can mentally sort it out later... :/)

personally i think it would be very nice to be able to continue to use sdc-home for capturing application-level logs in the specified directory as well as using SysLogHandler so that we can collect all the logs in the central vm, but since you have a solution for getting client logs (tail -f /var/log/syslog | grep client) i don't think this needs to hold up your PR

so the request for changes is just for the docs and maybe adding back logging to {sdc-home}/logs if you can do it in an straight-forward simple way

backupCount=5, delay=False,
encoding=ENCODING)
# define log handlers using system's rsyslog
handler = SysLogHandler(address="/dev/log")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll also want to add a check for the platform here as we do in prevent_second_instance, since this won't work on non-Linux platforms (recall that right now this project can be developed by contributors on other platforms, this is something we want to preserve)

@kushaldas kushaldas force-pushed the use_rsyslog branch 2 times, most recently from c735859 to ba99840 Compare January 15, 2020 15:50
The existing logging system stays the same, this just adds
extra logging ot rsyslog too.
@sssoleileraaa
Copy link
Contributor

I moved this from "Ready to Review" to "In Development" because there are requested changes.

@sssoleileraaa
Copy link
Contributor

It looks like now you are no longer logging to rsyslog and switched back to {sdc-home}/logs, is that right @kushaldas? Maybe I don't understand your solution, but is this supposed to be logging to both locations?

@sssoleileraaa sssoleileraaa self-requested a review January 16, 2020 17:55
Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, when I switched to my Qubes workstation and ran the client, I could see that this does log to /var/log/syslog AND {sdc-home}/logs so lgtm!

@redshiftzero redshiftzero merged commit 61f68d2 into master Jan 16, 2020
@redshiftzero redshiftzero deleted the use_rsyslog branch January 16, 2020 18:04
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.

4 participants