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

Access denied on Geolite2-City.mmdb when running cscli hub upgrade while Crowdsec is running on Windows Platform #3269

Open
cstisa opened this issue Oct 3, 2024 · 2 comments
Labels
kind/bug Something isn't working os/win triage/accepted value/high Doing this significantly improves some areas version/1.6.3
Milestone

Comments

@cstisa
Copy link

cstisa commented Oct 3, 2024

What happened?

Dear Crowdsec Community,

When we perform a cscli hub upgrade or cscli hub upgrade --force on a host running Windows Server Operating System we have the following error :

C:\Windows\system32>cscli hub upgrade
level=info msg="Upgrading parsers"
level=info msg="crowdsecurity/http-logs: up-to-date"
level=info msg="crowdsecurity/mssql-logs: up-to-date"
level=info msg="crowdsecurity/dateparse-enrich: up-to-date"
level=info msg="crowdsecurity/geoip-enrich: up-to-date"
level=error msg="Failed to remove destination file before renaming: remove C:\\ProgramData\\CrowdSec\\data\\GeoLite2-City.mmdb: Access is denied." url="https://hub-data.crowdsec.net/mmdb_update/GeoLite2-City.mmdb"
level=fatal msg="crowdsecurity/geoip-enrich: download failed: while downloading data for C:\\ProgramData\\CrowdSec\\config\\parsers\\s02-enrich\\geoip-enrich.yaml: while getting data: remove C:\\ProgramData\\CrowdSec\\data\\GeoLite2-City.mmdb: Access is denied."
C:\Windows\system32>cscli hub upgrade --force
level=info msg="Upgrading parsers"
level=info msg="crowdsecurity/geoip-enrich: up-to-date"
level=error msg="Failed to remove destination file before renaming: remove C:\\ProgramData\\CrowdSec\\data\\GeoLite2-City.mmdb: Access is denied." url="https://hub-data.crowdsec.net/mmdb_update/GeoLite2-City.mmdb"
level=fatal msg="crowdsecurity/geoip-enrich: download failed: while downloading data for C:\\ProgramData\\CrowdSec\\config\\parsers\\s02-enrich\\geoip-enrich.yaml: while getting data: remove C:\\ProgramData\\CrowdSec\\data\\GeoLite2-City.mmdb: Access is denied."

It seems that it can not remove the GeoLite2-City.mmdb while Crowdsec Service is running

After stopping the service and running again the command the process is working as expected.

When there are no update of this mmdb Geolite file the process is working as expected.

What did you expect to happen?

The process of running cscli hub upgrade should work without any intervention (stopping) on the service.

How can we reproduce it (as minimally and precisely as possible)?

Perform a cscli hub upgrade on a command prompt with administrator privilege while crowdsec is running and the Geolite files are not up to date.

Anything else we need to know?

No response

Crowdsec version

C:\Windows\system32>cscli version
version: v1.6.3-188f580f
Codename: alphaga
BuildDate: 2024-09-13_09:47:13
GoVersion: 1.22.6
Platform: windows
libre2: WebAssembly
User-Agent: crowdsec/v1.6.3-188f580f-windows
Constraint_parser: >= 1.0, <= 3.0
Constraint_scenario: >= 1.0, <= 3.0
Constraint_api: v1
Constraint_acquis: >= 1.0, < 2.0

OS version

# On Windows:
C:\Windows\system32>wmic os get Caption, Version, BuildNumber, OSArchitecture
BuildNumber  Caption                                 OSArchitecture  Version
17763        Microsoft Windows Server 2019 Standard  64-bit          10.0.17763

Enabled collections and parsers

$ cscli hub list -o raw
# paste output here

Acquisition config

```console # On Linux: $ cat /etc/crowdsec/acquis.yaml /etc/crowdsec/acquis.d/* # paste output here

On Windows:

C:> Get-Content C:\ProgramData\CrowdSec\config\acquis.yaml

paste output here

Config show

No response

Prometheus metrics

No response

Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.

No response

Thanks for the help and support !

Have a nice day

Edouard Fazenda for CSTI SA.

Copy link

github-actions bot commented Oct 3, 2024

@cstisa: Thanks for opening an issue, it is currently awaiting triage.

In the meantime, you can:

  1. Check Crowdsec Documentation to see if your issue can be self resolved.
  2. You can also join our Discord.
  3. Check Releases to make sure your agent is on the latest version.
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@blotus
Copy link
Member

blotus commented Oct 3, 2024

Hello,

This one might be a bit tricky: the MMDB files are mmap()'ed (or the Windows equivalent in your case) on startup, and windows (AFAIK) forbids deleting/replacing a file that has valid handles pointing to it.

This issue was most likely hidden in the past as we did not support automatically updating the datafiles, and after we did, the auto-update for the MMDB files was disabled server-side to workaround a crash while we implemented the fix in crowdsec.

We'll try to come up with a solution and let you know.

@buixor buixor added this to the 1.6.4 milestone Oct 3, 2024
@buixor buixor added triage/accepted value/high Doing this significantly improves some areas and removed needs/triage labels Oct 15, 2024
@buixor buixor modified the milestones: 1.6.4, 1.6.5 Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working os/win triage/accepted value/high Doing this significantly improves some areas version/1.6.3
Projects
None yet
Development

No branches or pull requests

3 participants