-
Notifications
You must be signed in to change notification settings - Fork 0
fix: update xauth on reboot/change #4
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
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Ideas, Features, Roadmap | ||
|
|
||
| ## Known Bugs | ||
|
|
||
| - the xauthority device changes when x or wayland is restarted. `igloo enter` should validate the existence of the xauthority device on each enter, replacing it if necessary | ||
|
|
||
| ## Ideas | ||
|
|
||
| - On a host with no VS Code install, we'll be running code inside each igloo container. It'd be nice to share settings between them. Can't really symlink the ~/.vscode dir from the host since it won't exist. Explore having a Shared State sort of thing where directories like that live in ~/.config/igloo/shared_state and are linked in (by default? configurable?). Implement: `[shared_state]` section in config file that stores listed directories in ~/.config/igloo/shared_state and symlinks listed directories into the container, allowing all igloo instances to share these directories. This feature could be used for one-off script storage too. | ||
|
|
||
| - copy the igloo binary into the container, and add one or more commands intended to run inside the container. Perhaps showing, editing `shared_state` contents? definitely `igloo status` should work inside the container and show that it knows it's inside. | ||
|
|
||
| - modify PS1 in the container to add `[igloo]` prefix, change color of prompt, something visual as an indicator? Or... simply add a tip in the readme showing how to do this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| package incus | ||
|
|
||
| import ( | ||
| "os" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| // TestUpdateXauthority_NoFile tests UpdateXauthority when no xauthority file exists | ||
| func TestUpdateXauthority_NoFile(t *testing.T) { | ||
| // Save current env vars | ||
| oldXauth := os.Getenv("XAUTHORITY") | ||
| oldHome := os.Getenv("HOME") | ||
| defer func() { | ||
| if oldXauth != "" { | ||
| _ = os.Setenv("XAUTHORITY", oldXauth) | ||
| } else { | ||
| _ = os.Unsetenv("XAUTHORITY") | ||
| } | ||
| _ = os.Setenv("HOME", oldHome) | ||
| }() | ||
|
|
||
| // Set env to point to non-existent file | ||
| tmpDir := t.TempDir() | ||
| _ = os.Setenv("HOME", tmpDir) | ||
| _ = os.Unsetenv("XAUTHORITY") | ||
|
|
||
| client := NewClient() | ||
|
|
||
| // This should not error when file doesn't exist - it just returns nil | ||
| err := client.UpdateXauthority("test-container") | ||
| if err != nil { | ||
| t.Errorf("UpdateXauthority() should not error when file doesn't exist, got: %v", err) | ||
| } | ||
| } | ||
|
|
||
| // TestUpdateXauthority_WithFile tests UpdateXauthority when xauthority file exists | ||
| // Note: This test can't fully test the incus commands without a running incus instance, | ||
| // but it verifies the file detection logic works | ||
| func TestUpdateXauthority_WithFile(t *testing.T) { | ||
| // Save current env vars | ||
| oldXauth := os.Getenv("XAUTHORITY") | ||
| oldHome := os.Getenv("HOME") | ||
| oldUser := os.Getenv("USER") | ||
| defer func() { | ||
| if oldXauth != "" { | ||
| _ = os.Setenv("XAUTHORITY", oldXauth) | ||
| } else { | ||
| _ = os.Unsetenv("XAUTHORITY") | ||
| } | ||
| _ = os.Setenv("HOME", oldHome) | ||
| _ = os.Setenv("USER", oldUser) | ||
| }() | ||
|
|
||
| // Create a temporary xauthority file | ||
| tmpDir := t.TempDir() | ||
| xauthFile := tmpDir + "/.Xauthority" | ||
| if err := os.WriteFile(xauthFile, []byte("fake xauth data"), 0600); err != nil { | ||
| t.Fatalf("Failed to create test xauthority file: %v", err) | ||
| } | ||
|
|
||
| _ = os.Setenv("HOME", tmpDir) | ||
| _ = os.Setenv("USER", "testuser") | ||
| _ = os.Unsetenv("XAUTHORITY") | ||
|
|
||
| client := NewClient() | ||
|
|
||
| // This will attempt to call incus commands which will fail without incus installed | ||
| // but we can verify it at least tries to process the file | ||
| err := client.UpdateXauthority("test-container") | ||
|
|
||
| // We expect an error because incus isn't available in test environment, | ||
| // but we're verifying the logic path is taken when the file exists | ||
| // The function should have attempted to check device existence | ||
| if err == nil { | ||
| // If no error, then either incus is available (unlikely in CI) | ||
| // or the logic correctly handled the case | ||
| t.Log("UpdateXauthority succeeded (incus may be available)") | ||
| } else { | ||
| // Expected case: incus command failed | ||
| errMsg := err.Error() | ||
| if !strings.Contains(errMsg, "incus") && !strings.Contains(errMsg, "device") && | ||
| !strings.Contains(errMsg, "executable file not found") && !strings.Contains(errMsg, "command not found") { | ||
| t.Errorf("Expected incus-related error, got: %v", err) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // TestUpdateXauthority_CustomPath tests UpdateXauthority with XAUTHORITY env var set | ||
| func TestUpdateXauthority_CustomPath(t *testing.T) { | ||
| // Save current env vars | ||
| oldXauth := os.Getenv("XAUTHORITY") | ||
| oldUser := os.Getenv("USER") | ||
| defer func() { | ||
| if oldXauth != "" { | ||
| _ = os.Setenv("XAUTHORITY", oldXauth) | ||
| } else { | ||
| _ = os.Unsetenv("XAUTHORITY") | ||
| } | ||
| _ = os.Setenv("USER", oldUser) | ||
| }() | ||
|
|
||
| // Create a temporary xauthority file with custom path | ||
| tmpDir := t.TempDir() | ||
| xauthFile := tmpDir + "/.mutter-Xwaylandauth.ABC123" | ||
| if err := os.WriteFile(xauthFile, []byte("fake xauth data"), 0600); err != nil { | ||
| t.Fatalf("Failed to create test xauthority file: %v", err) | ||
| } | ||
|
|
||
| _ = os.Setenv("XAUTHORITY", xauthFile) | ||
| _ = os.Setenv("USER", "testuser") | ||
|
|
||
| client := NewClient() | ||
|
|
||
| // This will attempt to call incus commands which will fail without incus installed | ||
| err := client.UpdateXauthority("test-container") | ||
|
|
||
| // We expect an error because incus isn't available in test environment | ||
| if err == nil { | ||
| t.Log("UpdateXauthority succeeded (incus may be available)") | ||
| } else { | ||
| // Expected case: incus command failed | ||
| errMsg := err.Error() | ||
| if !strings.Contains(errMsg, "incus") && !strings.Contains(errMsg, "device") && | ||
| !strings.Contains(errMsg, "executable file not found") && !strings.Contains(errMsg, "command not found") { | ||
| t.Errorf("Expected incus-related error, got: %v", err) | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.