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

Fix Error "Service Access is denied" in service collector useApi #1036

Merged
merged 1 commit into from
Aug 22, 2022

Conversation

alvarocabanas
Copy link
Contributor

@alvarocabanas alvarocabanas commented Jul 29, 2022

Fix error preventing to collect certain restricted services when using the service collector in api mode "useApi".
Since the handler used sets by default SC_MANAGER_ALL_ACCESS when creating a service handler, in certain windows distributions and for certain services, it is not possible to open a connection to those services that are restricted.
Opening the service with GENERIC_READ fixes the issue.

This addresses #1037

Signed-off-by: Alvaro Cabanas [email protected]

@alvarocabanas alvarocabanas requested a review from a team as a code owner July 29, 2022 08:52
Signed-off-by: Alvaro Cabanas <[email protected]>
Signed-off-by: alvarocabanas <[email protected]>
@breed808
Copy link
Contributor

Thanks for submitting this! It's always good to reduce required permissions of the exporter where possible.

I take it that this is following up on the work previously submitted by @carlossscastro in #812? I'm not familiar with the syscalls/APIs in use so I'm not sure if I can provide a meaningful review.

@carlossscastro
Copy link
Contributor

carlossscastro commented Aug 22, 2022

Hi @breed808,

That's exactly a follow up from the implementation I did in #812. After a couple of reports from users that not all the services were being monitored, we found out that GO standard library to handle windows services requires SC_MANAGER_ALL_ACCESS permissions which is not ideal.
So @alvarocabanas implemented an alternative way, with direct syscalls to overcome that.
From the tests we both did (we work together in the same team) there is no loss in performance (which was the main reason for #812) and it solves the permissions issue.
From my side, FWIW, this is reviewed and approved

Thank You

@breed808
Copy link
Contributor

Thanks @carlossscastro, that context helps a lot here 👍

@breed808 breed808 merged commit 1c199e6 into prometheus-community:master Aug 22, 2022
@carlossscastro
Copy link
Contributor

Thanks @breed808

anubhavg-icpl pushed a commit to anubhavg-icpl/windows_exporter that referenced this pull request Sep 22, 2024
Fix Error "Service Access is denied" in service collector useApi
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.

3 participants