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

semaphore permissions: Trying to set 0o666 results in 0o664 instead #8

Closed
Para7etamol opened this issue May 29, 2024 · 6 comments
Closed

Comments

@Para7etamol
Copy link

Hi everyone!

When trying this:

using Random

sem_name="test_"*randstring(100)
rm(Semaphore,sem_name)
Semaphore(sem_name, 1; volatile=false, perms=0o666)

The resulting semaphore in /dev/shm/ has permissions 0o664 instead of 0o666

Using Julia 1.10.0 and Ubuntu 2204

Best regards
Oliver

@emmt
Copy link
Owner

emmt commented May 29, 2024

The permissions settings are masked against the process umask. What is the value of your umask? I have tried your example and the resulting permissions are 0o644 because my umask is 0o022.

@Para7etamol
Copy link
Author

Para7etamol commented May 29, 2024

Thanks for your quick response!

I understand that using default permissions (via umask) is a good idea, but I explicly specify the permissions so I expect them to be that way.

But it's pointless to whine because as I now see the masking is happening in sem_open ... :-(

@emmt
Copy link
Owner

emmt commented May 29, 2024

In d9d91b0, I have added the umask function. So that you can call it as:

old_msk = umask(0) # set umask, remembering old value
sem = Semaphore(sem_name, 1; volatile=false, perms=0o666) # open semaphore
umask(old_msk) # restore old umask value

This should create the semaphore file with correct permissions. For now I have update the doc. to mention that the perms settings are masked against the process umask.

Perhaps it is better if this is automatically done under the hood by Semaphore. What do you think?

Once we decide on this, I can make a new release.

@Para7etamol
Copy link
Author

To satisfy both expectations (mine to get what I specified and on the other hand people expecting sem_open's behaviour) you could make Semaphore() do the umasking under the hood, but let open(Semaphore,...) stick to sem_open / POSIX.

@emmt
Copy link
Owner

emmt commented May 29, 2024

Done in 22d3a48. Thanks for the suggestion.

I will register a new version as soon as I can get the documentation built again...

@emmt
Copy link
Owner

emmt commented May 31, 2024

Done.

@emmt emmt closed this as completed May 31, 2024
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

No branches or pull requests

2 participants