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

Allow reading/writing text envelopes from pipes #4384

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

LudvikGalois
Copy link
Contributor

Previously the functions to read text envelopes used readFile from
Data.ByteString. Unfortunately, that doesn't work with pipes, so we've
switched to a function that does.

Additionally, on unix based systems, we've changed how writing to an
owned file works. Previously a new file was created (and since we
created it, we must own it) and then copied into place. Unfortunately
this doesn't work with symlinks, fifos, unix sockets or anything else
that isn't a "normal" file. What we do now is grab the file descriptor,
call fchown on it, which sets us as the owner (or errors out if we can't
do that), and then write to the file.

Fixes #4235

Previously the functions to read text envelopes used `readFile` from
Data.ByteString. Unfortunately, that doesn't work with pipes, so we've
switched to a function that does.

Additionally, on unix based systems, we've changed how writing to an
owned file works. Previously a new file was created (and since we
created it, we must own it) and then copied into place. Unfortunately
this doesn't work with symlinks, fifos, unix sockets or anything else
that isn't a "normal" file. What we do now is grab the file descriptor,
call fchown on it, which sets us as the owner (or errors out if we can't
do that), and then write to the file.
@LudvikGalois LudvikGalois force-pushed the ludvikgalois/support-pipes-in-transaction branch from ec5063c to e8c5317 Compare August 25, 2022 03:24
@LudvikGalois LudvikGalois mentioned this pull request Aug 25, 2022
19 tasks
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One question

bracketOnError
(openFd path WriteOnly (Just ownerModes) defaultFileFlags)
closeFd
(\fd -> setFdOwnerAndGroup fd user (-1) >> pure fd)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -1 for the group id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setFdOwnerAndGroup is a thin wrapper over fchown, and has kept the behaviour of the original (-1 for "do not change") instead of changing the type to be a more idiomatic Haskell Maybe Int.

@LudvikGalois
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Aug 30, 2022

Build succeeded:

@iohk-bors iohk-bors bot merged commit d1d80d9 into master Aug 30, 2022
@iohk-bors iohk-bors bot deleted the ludvikgalois/support-pipes-in-transaction branch August 30, 2022 15:43
@CarlosLopezDeLara CarlosLopezDeLara mentioned this pull request Aug 31, 2022
40 tasks
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.

[BUG] - CLI is not allowing process substitution on certain commands
2 participants