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

Permission Denied on linux #9

Closed
jacek-kurlit opened this issue Jul 6, 2024 · 5 comments · Fixed by #10
Closed

Permission Denied on linux #9

jacek-kurlit opened this issue Jul 6, 2024 · 5 comments · Fixed by #10
Assignees
Labels
bug Something isn't working Linux
Milestone

Comments

@jacek-kurlit
Copy link
Contributor

Hello,

When I try to use this create I receive error
{ code: 13, kind: PermissionDenied, message: "Permission denied" }
All I do is calling let ports = listeners::get_all();

I'm using fedora 40, is there any limitation on linux systems?
I want to use this create in my tool but I cannot force user to run as root

@jacek-kurlit
Copy link
Contributor Author

jacek-kurlit commented Jul 6, 2024

I tried to debug where this error comes from and I have found this place
helpers::build_inode_proc_map()
linie 17
let dir_fd = rustix::fs::openat(

@jacek-kurlit
Copy link
Contributor Author

I have found some solution by filtering error_kind == PermissionDenied

        let dir_fd = match dir_fd {
            Ok(fd) => fd,
            Err(e) if e.kind() == ErrorKind::PermissionDenied => {
                continue;
            }
            Err(e) => return Err(Box::new(e)),
        };

I can create PR with fix if you are interested

@GyulyVGC
Copy link
Owner

Hey @jacek-kurlit thank you so much for this ticket and for your solution, you can feel free to open a PR and I'll be happy to merge.
As you've said, this error is generated from the fact that some processes are run with privileges and cannot be seen by regular users. I used to run this library as sudo on Linux, but if we can improve this aspect by letting normal users see standard processes, that's actually a good idea.

@GyulyVGC GyulyVGC added the bug Something isn't working label Jul 10, 2024
@GyulyVGC GyulyVGC added this to the 0.2.1 milestone Jul 10, 2024
@GyulyVGC GyulyVGC added the Linux label Jul 10, 2024
@GyulyVGC
Copy link
Owner

GyulyVGC commented Jul 10, 2024

Actually you can skip all kind of errors... a change I should apply also in other places of the code is to ignore all the errors that are related to a specific process but that don't compromise other processes.

@jacek-kurlit
Copy link
Contributor Author

jacek-kurlit commented Jul 11, 2024

Hi!

I have created PR #10

I didn't go as far to ignore all errors as I wasn't sure if this is good idea to swallow error without any info for lib user.
Also I have changed code by simply checking user permissions to read fd before opening it.

@GyulyVGC GyulyVGC linked a pull request Jul 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Linux
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants