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

Change default umask from 777 to 022 #22589

Merged
merged 10 commits into from
Sep 23, 2024
Merged

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented Sep 19, 2024

Addresses #17269.

This PR follows the approach made in #17270 but sets default umask to a more permissive value (022). Additionally, it includes a unit test to cover umask functionality.

test/test_core.py Outdated Show resolved Hide resolved
test/stat/test_umask.c Outdated Show resolved Hide resolved
test/stat/test_umask.c Outdated Show resolved Hide resolved
test/stat/test_umask.c Outdated Show resolved Hide resolved
@fluiddot
Copy link
Contributor Author

Thanks @sbc100 for taking a look at the PR 🙇 ! It's my first attempt to add unit tests to the repository, so bear with me for any mistakes 😅 .

@sbc100
Copy link
Collaborator

sbc100 commented Sep 19, 2024

Thanks @sbc100 for taking a look at the PR 🙇 ! It's my first attempt to add unit tests to the repository, so bear with me for any mistakes 😅 .

Thanks for your contribution! Much appreciated.

@fluiddot
Copy link
Contributor Author

Btw, I picked the value 027 following #17270, but maybe we should consider a more permissive approach using 022. Looks like on many UNIX systems, 022 is the default value. WDYT?

}

int main() {
signal(SIGABRT, cleanup);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove this line, along with the cleanup function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've addressed this in 9619d38.


int main() {
signal(SIGABRT, cleanup);
test();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also I guess you might as well inline the test into main since that is all it contains now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, good point. I've applied this in 9619d38.

@also_with_wasmfs
def test_umask(self):
self.set_setting("FORCE_FILESYSTEM")
self.do_runf('stat/test_umask.c', 'success')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move this test into test/other? And then use do_other_test to run it? You can run it with --rebase to generate the expected output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry, I forgot to relocate the file after b0d7dcf.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've addressed this in 9619d38.

// Get the default umask
mode_t default_umask = get_umask();
printf("default umask: %o\n", default_umask);
assert(default_umask == 027);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think making the default 022 makes sense yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I'll update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this in 2891de1.

@fluiddot fluiddot changed the title Change default umask from 777 to 027 Change default umask from 777 to 022 Sep 23, 2024
@@ -28,7 +28,7 @@ static int g_pid = 42;
static int g_pgid = 42;
static int g_ppid = 1;
static int g_sid = 42;
static mode_t g_umask = S_IRWXU | S_IRWXG | S_IRWXO;
static mode_t g_umask = S_IWGRP | S_IWOTH;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reference, here are the definitions of values used here:

#define S_ISUID 04000
#define S_ISGID 02000
#define S_ISVTX 01000
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IXUSR 0100
#define S_IRWXU 0700
#define S_IRGRP 0040
#define S_IWGRP 0020
#define S_IXGRP 0010
#define S_IRWXG 0070
#define S_IROTH 0004
#define S_IWOTH 0002
#define S_IXOTH 0001
#define S_IRWXO 0007

@sbc100 sbc100 merged commit d286f12 into emscripten-core:main Sep 23, 2024
28 checks passed
@fluiddot fluiddot deleted the update-umask branch September 23, 2024 17:06
@fluiddot
Copy link
Contributor Author

Thanks @sbc100 for reviewing and approving the PR 🙇 !

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.

2 participants