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

thread 'thread_write_report' panic when run not as root. additionally, it'd be nice to save report file in a fixed location independently from running directory. #51

Closed
burjui opened this issue Jan 5, 2023 · 6 comments
Labels
bug Something isn't working enhancement New feature, request, or improvement
Milestone

Comments

@burjui
Copy link

burjui commented Jan 5, 2023

Describe the bug
When run not as root, sniffnet panics even with the capabilities set:

thread 'thread_write_report' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', /home/burjui/.cargo/registry/src/github.com-1ecc6299db9ec823/sniffnet-1.0.1/src/thread_write_report.rs:36:49

Runs just fine under kdesu.

To Reproduce

$ sudo setcap cap_net_raw,cap_net_admin=eip ~/.cargo/bin/sniffnet
$ sniffnet

Desktop:
Manjaro Linux 22.0.0

@GyulyVGC
Copy link
Owner

GyulyVGC commented Jan 5, 2023

If you previously run as root and then you try to run as normal user, it will panic because it tries to overwrite the previously generated report without success: in fact the previously generated report has admin privileges and cannot be overwritten by a normal user.

Delete the report file previously generated and you should be fine.

Let me know if it helps.

@burjui
Copy link
Author

burjui commented Jan 5, 2023

Oh, makes sense. That's why it suddenly started working after changing current directory in the terminal. Maybe sniffnet should write the report under ${HOME}/.local/var? That's a separate issue though.

@burjui burjui closed this as completed Jan 5, 2023
@GyulyVGC
Copy link
Owner

GyulyVGC commented Jan 5, 2023

Has it something to do with admin privileges? What benefit would this change introduce? Or, are you just asserting that it's not a good standard to generate the report in the current directory?

@burjui
Copy link
Author

burjui commented Jan 5, 2023

What benefit would this change introduce?

At least the subject of this issue will become irrelevant. The current behaviour is surprising (not in a good way). Even if I always run sniffnet as the same user, it still produces a report in every directory from which I run it.

not a good standard to generate the report in the current directory

I certainly think that. Traditional place for things like that is /var/tmp/<name>/ for daemons (see man hier for details), and, logically, for apps that would be ${HOME}/.local/var/tmp/<name>/.

@GyulyVGC
Copy link
Owner

GyulyVGC commented Jan 5, 2023

Thanks for pointing out, I will implement this change in the next release!

@GyulyVGC GyulyVGC reopened this Jan 5, 2023
@GyulyVGC GyulyVGC added this to the v1.1.0 milestone Jan 5, 2023
@GyulyVGC GyulyVGC changed the title thread 'thread_write_report' panic when run not as root thread 'thread_write_report' panic when run not as root. additionally, save report file in a fixed location independently from running directory. Jan 5, 2023
@GyulyVGC GyulyVGC changed the title thread 'thread_write_report' panic when run not as root. additionally, save report file in a fixed location independently from running directory. thread 'thread_write_report' panic when run not as root. additionally, it'd be nice to save report file in a fixed location independently from running directory. Jan 5, 2023
@GyulyVGC GyulyVGC added bug Something isn't working enhancement New feature, request, or improvement labels Jan 22, 2023
@GyulyVGC GyulyVGC modified the milestones: v1.1.0, v1.2.0 Feb 4, 2023
@GyulyVGC
Copy link
Owner

Textual report is now saved in a fixed directory, instead of using the directory where the execution was started.

The output is now saved in the same folder containing configuration files storing Sniffnet settings.
The directory is automatically chosen by confy depending on your architecture, and can be seen hovering on the "Open full report" button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature, request, or improvement
Projects
None yet
Development

No branches or pull requests

2 participants