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

conn_sock: add chdir-attach option #226

Merged
merged 1 commit into from
Jan 14, 2021

Conversation

haircommander
Copy link
Collaborator

unfortunately, older podman versions rely on conmon truncating the unix socket length when setting up the attach socket.

Introduce a flag to gate the changed behavior, allowing newer podman versions to be able to handle longer UID in rootless mode,
but also allowing older podman versions to work.

Signed-off-by: Peter Hunt pehunt@redhat.com

@haircommander
Copy link
Collaborator Author

fixes #225

@rhatdan
Copy link
Member

rhatdan commented Jan 11, 2021

go fmt is not happy.

@rhatdan
Copy link
Member

rhatdan commented Jan 11, 2021

LGTM

@haircommander
Copy link
Collaborator Author

ptal @giuseppe @saschagrunert @mheon

src/conn_sock.c Outdated
@@ -188,7 +202,7 @@ static char *bind_unix_socket(char *socket_relative_name, int sock_type, mode_t
if (fchmod(socket_fd, perms))
pexitf("Failed to change socket permissions %s", sock_fullpath);

if (chdir(opt_socket_path) == -1)
if (do_chdir && chdir(opt_socket_path) == -1)
Copy link
Member

Choose a reason for hiding this comment

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

Could we use the same trick with O_PATH I've used for Podman so we don't need a new flag and avoid using chdir?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that's a good trick for the do_chdir case, but we still need this PR to maintain backwards compatibility with podman (that truncates the path once it gets long enough)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

acutally, that's a good trick for both cases, but we still will need to truncate the path sometimes, thus still need this flag

Copy link
Member

Choose a reason for hiding this comment

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

don't we need to teach podman how to use the new flag though? How will it work with older versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah new podman will use this flag to be able to fix #213
#213 will not be able to be fixed with older versions of podman

Copy link
Member

Choose a reason for hiding this comment

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

nevermind my last comment.

For backward compatibility could we bump the API version and use the full path version only when the API version is 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

jw, is there a reason you're opposed to a flag here? we could use api-version here, but it seems like a very small change to bump the conmon major version. and if we did, we'd still need a change in podman to actually absorb the change, which is no different than a flag

Copy link
Member

Choose a reason for hiding this comment

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

the main reason is that I'd prefer if possible to avoid chdir as it affects the entire process

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay I dropped chdir but kept a flag. Now we gate the behavior of truncating the path on a flag, but regardless don't chdir

Copy link
Member

Choose a reason for hiding this comment

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

thanks!

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

LGTM from my side

unfortunately, older podman versions rely on conmon truncating the unix socket length when setting up the attach socket.

Introduce a flag to gate the changed behavior, allowing newer podman versions to be able to handle longer UID in rootless mode,
but also allowing older podman versions to work.

This also removes the logic for `do_chdir` in favor of using a /proc/self/fd entry for the sock path.
That allows conmon to not chdir before attaching to the unix socket.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

/lgtm

@haircommander haircommander merged commit 93f5b30 into containers:master Jan 14, 2021
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.

4 participants