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

Add pledge and unveil #3823

Merged
merged 1 commit into from Mar 10, 2024
Merged

Add pledge and unveil #3823

merged 1 commit into from Mar 10, 2024

Conversation

catap
Copy link
Contributor

@catap catap commented Mar 9, 2024

pledge is using to restrict system operations, and unveil to unveil parts of a restricted filesystem view.

Both of them available at OpenBSD for years. Anyway some work to port it to Linux is onging but it far from the end, and the best status is Justine's work to port it into cosmopolitan libc.


#include <errno.h>

int pledge(const char *promises, const char *execpromises) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not try to redefine it here under the original name, instead let's define it as scalanative_pledge and redirect Scala to it by adding @name("scalanative_pledge") annotation. Same for unveil function

@catap
Copy link
Contributor Author

catap commented Mar 10, 2024

After some thinking I'd like to remove C-level placeholder. Let linker fail if user tries to use this function on unsupported OS.

This is much better and user friendly behaviour that return undocummented error via errno.

I'll update PR shortly

`pledge` is using to restrict system operations, and `unveil` to unveil
parts of a restricted filesystem view.

Both of them available at OpenBSD for years. Anyway some work to port it
to Linux is onging but it far from the end, and the best status is
Justine's work to port it into cosmopolitan libc.
@catap catap marked this pull request as draft March 10, 2024 09:49
@catap catap marked this pull request as ready for review March 10, 2024 09:51
@WojciechMazur WojciechMazur merged commit 01fe709 into scala-native:main Mar 10, 2024
61 checks passed
@catap catap deleted the unveil-pledge branch March 10, 2024 13:23
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.

None yet

2 participants