Skip to content

Conversation

dblsaiko
Copy link

@dblsaiko dblsaiko commented Apr 4, 2025

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dblsaiko dblsaiko force-pushed the push-uqsozolyrlor branch 2 times, most recently from 0c7495f to 9d1d341 Compare April 5, 2025 10:49
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

Comment on lines +336 to +401
if let Some(mode) = mode {
let mut permissions = fs::metadata(socket)
.context("could not read socket metadata")?
.permissions();
let mode = u32::from_str_radix(mode, 8)
.with_context(|| format!("could not parse mode: {mode}"))?;
permissions.set_mode(mode);
fs::set_permissions(socket, permissions)
.context("could not set socket permissions")?;
}
Copy link
Member

Choose a reason for hiding this comment

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

To avoid any potential race conditions, I would appreciate if we used the opened file descriptor directly.

This is a little bit annoying to do, but basically, you can:

This way we're sure that if for some reason the socket gets deleted, gets moved or whatever, we don't end up doing operations on the wrong file. It only ever gets opened once

Copy link
Author

Choose a reason for hiding this comment

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

That unfortunately doesn't work, calling fchmod on a socket fd does nothing. See https://stackoverflow.com/a/15450698

(Still, change here: dblsaiko@push-looktxnmnmsw)

@@ -124,6 +124,9 @@ pub enum BindConfig {
/// Path to the socket
#[schemars(with = "String")]
socket: Utf8PathBuf,

/// Socket file mode
Copy link
Member

Choose a reason for hiding this comment

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

Please add in the comment what form you expect this to be. You could also use schemars' example attribute, which will appear in the generate JSONSchema

@@ -58,6 +58,7 @@ http:

# Third option: listen on the given UNIX socket
- socket: /tmp/mas.sock
mode: "660" # optional
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mode: "660" # optional
mode: "660" # permissions to set on the socket, optional

@dblsaiko dblsaiko force-pushed the push-uqsozolyrlor branch from 9d1d341 to 7dbcbc5 Compare May 13, 2025 16:53
@dblsaiko dblsaiko force-pushed the push-uqsozolyrlor branch from 7dbcbc5 to 692c826 Compare July 29, 2025 19:34
Signed-off-by: Katalin Rebhan <[email protected]>
@dblsaiko dblsaiko force-pushed the push-uqsozolyrlor branch from 692c826 to 5676b41 Compare July 29, 2025 19:36
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.

3 participants