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

fixes #1564 usr home #1582

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"os"
"os/user"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -300,13 +301,26 @@ func createContainer(container, image, release, authFile string, showCommandToEn

dbusSystemSocketMountArg := dbusSystemSocket + ":" + dbusSystemSocket

homeDirEvaled, err := filepath.EvalSymlinks(currentUser.HomeDir)
user, err := user.Current()
if err != nil{
logrus.Errorf("Failed to get HOME directory: %v", err)
}
homeDir := user.HomeDir
resolvedPath, err := filepath.EvalSymlinks(HomeDir)
Copy link
Member

Choose a reason for hiding this comment

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

It should be homeDir, not HomeDir. This is causing:

cmd/create.go:308:2: declared and not used: homeDir
cmd/create.go:309:45: undefined: HomeDir

if err != nil{
logrus.Errorf("Failed to evaluate symlinks for HOME directory: %v", err)
return err
}


/*homeDirEvaled = os.UserHomeDir()
homeDirEvaled, err := filepath.EvalSymlinks(homeDirEvaled)
if err != nil {
return fmt.Errorf("failed to canonicalize %s", currentUser.HomeDir)
}

logrus.Debugf("%s canonicalized to %s", currentUser.HomeDir, homeDirEvaled)
homeDirMountArg := homeDirEvaled + ":" + homeDirEvaled + ":rslave"
homeDirMountArg := homeDirEvaled + ":" + homeDirEvaled + ":rslave"*/

var avahiSocketMount []string

Expand Down
1 change: 1 addition & 0 deletions src/cmd/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"os"

Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: stray newline.


"github.com/containers/toolbox/pkg/utils"
"github.com/spf13/cobra"
Expand Down
1 change: 0 additions & 1 deletion src/cmd/initContainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"io/ioutil"
"os"
"os/user"
Copy link
Member

Choose a reason for hiding this comment

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

I bet this line is causing:

cmd/initContainer.go:270:21: undefined: user
cmd/initContainer.go:580:15: undefined: user

Why did you remove the import of os/user?

"path/filepath"
"strconv"
"strings"
Expand Down
1 change: 1 addition & 0 deletions src/cmd/rootMigrationPath.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"os"
"os/user"
"strings"

"github.com/containers/toolbox/pkg/utils"
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"io"
"os"
"os/user"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -441,7 +442,7 @@ func runCommandWithFallbacks(container string,

workDir = runFallbackWorkDirs[runFallbackWorkDirsIndex]
if workDir == "" {
workDir = currentUser.HomeDir
workDir = user.Current()
}

fmt.Fprintf(os.Stderr, "Using %s instead.\n", workDir)
Expand Down
1 change: 1 addition & 0 deletions src/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"fmt"
"io"
"os"
"os/user"
Copy link
Member

Choose a reason for hiding this comment

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

I bet this line is causing:

cmd/utils.go:30:2: user redeclared in this block
cmd/utils.go:28:2: other declaration of user

The code was already importing os/user a few lines below, so no need to import it again. :)

Copy link
Member

Choose a reason for hiding this comment

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

Now you removed both imports, and it's causing:

cmd/utils.go:333:38: undefined: user

"os/exec"
"os/user"
"path/filepath"
Expand Down