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

Atomize output files (--output.roa and --output.bgpsec) #124

Open
ydahhrk opened this issue Apr 21, 2024 · 1 comment
Open

Atomize output files (--output.roa and --output.bgpsec) #124

ydahhrk opened this issue Apr 21, 2024 · 1 comment

Comments

@ydahhrk
Copy link
Member

ydahhrk commented Apr 21, 2024

These files were originally created for debugging reasons, so Fort handles them somewhat carelessly.

But --output.roa has turned out to be useful, so it would be nice if it were more script-friendly. It sometimes contains less information than it's supposed to, presumably while Fort is writing it.

Workaround: Try rtrclient from rtrlib:

rtrclient -e -t csv -o roas.csv tcp localhost 323
ydahhrk added a commit that referenced this issue May 6, 2024
Fort used to clear the --output.roa and --output.bgpsec files to make
sure they were writable, during early validations.

So this is why the files spent so much time being empty! This was not
acceptable. It didn't even guarantee the files would still remain
writable by the time Fort needed to properly populate them.

Adjacent progress for #124.
@job
Copy link
Contributor

job commented Aug 27, 2024

Indeed the issue is that the program writes into a file while another program might be reading from it.

I recommend copying some code from OpenBSD/FreeBSD:

  • first write into a temp file 1
  • when done writing, rename() the temp file to the final destination 1
  • use a sighandler so that upon crash/exit the temp files get removed 1 and 2

Source: https://github.com/openbsd/src/blob/master/usr.sbin/rpki-client/output.c

ydahhrk added a commit that referenced this issue Oct 16, 2024
I feel like I need to relearn signals every time I have to interact with
them. Best get this done while the iron's hot.

1. The ROA file is first written as `<cache>/.roa`.
   The RK file is first written as `<cache>/.rk`.
2. When the validation run is done, `.roa` is renamed to `--output.roa`,
   and `.rk` becomes `--output.bgpsec`.
3. Most terminating signals unlink `.roa` and `.rk`.

Fixes #124.
@ydahhrk ydahhrk added this to the 2.0.0 milestone Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants