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

Cleanup XDGRuntime #3850

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

apostasie
Copy link
Contributor

@apostasie apostasie commented Jan 25, 2025

From reading code, it seems to me like:

  1. XDGRuntimeDir() should check the value of ROOTLESSKIT_PARENT_EUID (like ParentEUID does)
  2. getXDGRuntimeDir() in bypass4netns is essentially duplicating XDGRuntimeDir()
  3. getRuntimeVariableDataDir and CNIRuntimeDir should not ignore errors, and they seem to have faulty logic (relying on Geteuid regardless of conditions), or calling rootlessutil.ParentEUID which will redo stuff done already in XDGRuntimeDir()

PR addresses these.

@apostasie apostasie force-pushed the cleanup-xdg branch 2 times, most recently from b1c9415 to 890d40e Compare January 25, 2025 08:22
@apostasie
Copy link
Contributor Author

Was wondering if we should even incorporate into XDGRuntimeDir the extra logic

			if rootlessutil.IsRootlessChild() {
				return "", err
			}
			run = fmt.Sprintf("/run/user/%d", os.Geteuid())

but (for now) elected for pure refactoring with no change of behavior.

@apostasie
Copy link
Contributor Author

apostasie commented Jan 25, 2025

Not clear why the failures (some of it is definitely the usual stargz / layer not found), but the rest is weird (eg: platform timeout).

If we can poke it in case it is a fluke...

@apostasie apostasie marked this pull request as draft January 25, 2025 09:28
Signed-off-by: apostasie <[email protected]>
@apostasie apostasie marked this pull request as ready for review January 27, 2025 18:12
@apostasie
Copy link
Contributor Author

CI failure seems to be a timeout.

return "/run/user/" + euid, nil
euid, err := strconv.Atoi(os.Getenv("ROOTLESSKIT_PARENT_EUID"))
if err != nil {
return "", errors.New("environment variable XDG_RUNTIME_DIR is not set, see https://rootlesscontaine.rs/getting-started/common/login/")
Copy link
Member

Choose a reason for hiding this comment

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

The new code is harder to read, as the error returned here is about XDG_RUNTIME_DIR while the original err is about ROOTLESSKIT_PARENT_EUID

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 don't like any of that code either.

We can add more fine grained errors. Just not sure this is worth the effort.
Lmk what you would prefer.

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