Skip to content

Conversation

@Minnozz
Copy link
Contributor

@Minnozz Minnozz commented Jul 26, 2021

And use more restrictive permissions.
We should not accidentally overwrite a random file.

See discussion in 86a5568#r654858470

@cristianoc
Copy link
Collaborator

Would you rebase? This can probably progress now.

@Minnozz Minnozz force-pushed the rescript-format-tmpfile-open-exclusive branch from 28b8832 to 2a91836 Compare June 26, 2022 19:00
@Minnozz
Copy link
Contributor Author

Minnozz commented Jun 26, 2022

@cristianoc Done.

Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

Where's the "check if tmpfile exists" part?

@Minnozz
Copy link
Contributor Author

Minnozz commented Jun 26, 2022

The wx flags to openSync:

'w': Open file for writing. The file is created (if it does not exist) or truncated (if it exists). 'wx': Like 'w' but fails if the path exists. 
@cristianoc
Copy link
Collaborator

How about failing with a dedicated error message if that exists?

@Minnozz Minnozz force-pushed the rescript-format-tmpfile-open-exclusive branch from 2a91836 to a28f277 Compare June 26, 2022 19:11
@Minnozz
Copy link
Contributor Author

Minnozz commented Jun 27, 2022

@cristianoc I would rather depend on tmp to create the temporary file, which encasulates this logic. Is that okay?

@cristianoc
Copy link
Collaborator

@cristianoc I would rather depend on tmp to create the temporary file, which encasulates this logic. Is that okay?

Notice on failure one gets a nice checkout of all the files used. In the current dir, visible with git diff.

That's an experience to keep.

@cristianoc
Copy link
Collaborator

@cristianoc I would rather depend on tmp to create the temporary file, which encasulates this logic. Is that okay?

Notice on failure one gets a nice checkout of all the files used. In the current dir, visible with git diff.

That's an experience to keep.

Sorry wrong comment

@cristianoc
Copy link
Collaborator

Comment: sure go ahead

@cristianoc
Copy link
Collaborator

Btw how comes this does not work?

 var filename = path.join( os.tmpdir(), "rescript_" + crypto.randomBytes(8).toString("hex") + path.parse(use_stdin).base );
@Minnozz
Copy link
Contributor Author

Minnozz commented Jun 29, 2022

I created a new PR that uses the tmp package: #5486.

@Minnozz Minnozz closed this Jun 29, 2022
@cristianoc
Copy link
Collaborator

Back to this.

@cristianoc cristianoc reopened this Jul 3, 2022
@cristianoc cristianoc force-pushed the rescript-format-tmpfile-open-exclusive branch from a28f277 to 8a5d40a Compare July 3, 2022 20:18
@cristianoc cristianoc changed the base branch from master to 2.2.3 July 3, 2022 20:18
@cristianoc cristianoc changed the base branch from 2.2.3 to master July 3, 2022 20:19
@cristianoc cristianoc force-pushed the rescript-format-tmpfile-open-exclusive branch from 8a5d40a to 2ecec2e Compare July 3, 2022 20:20
…st, and use mode 0o600 We should not accidentally overwrite a random file.
@cristianoc cristianoc force-pushed the rescript-format-tmpfile-open-exclusive branch from 2ecec2e to 76a6d75 Compare July 3, 2022 20:32
@cristianoc
Copy link
Collaborator

Will complete this.
Missing context of where this originated. Where is the issue where this was reported to create problems?

@cristianoc cristianoc merged commit 7be331a into rescript-lang:master Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants