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

Fix for home directory not found on Windows #44

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

Conversation

hydrajump
Copy link

After cross-compiling gof3r for windows/amd64 and running the binary
I got the following error,

home directory not found for current user
screenshot

The fix for this error is to use the third-party package go-homedir, which
detects "the user's home directory without the use of cgo, so the library
can be used in cross-compilation environments."

After cross-compiling `gof3r` for `windows/amd64` and running the binary
I got the following error,

home directory not found for current user

The fix for this error is to use the third-party package `go-homedir`, which
detects "the user's home directory without the use of cgo, so the library
can be used in cross-compilation environments."
@hydrajump
Copy link
Author

I tested the fix on darwin/amd64 and windows/amd64 to verify that the home directory was found correctly.

I used gox to cross-compile, e.g. gox -osarch="windows/amd64" -osarch="darwin/amd64"

@rlmcpherson
Copy link
Owner

Since I have not tested s3gof3r all on windows, I'd like to have more evidence it works correctly in general on windows before adding windows-specific code changes like this. If windows support is possible without significant changes to the existing code, it's certainly worth pursuing though.

Regarding this change specifically, I'd prefer not to introduce an entire 200+ line library dependency for the few lines of code it would take to add windows home dir support. The code could be included with proper attribution instead.

@mentalisttraceur
Copy link

Noting this here in so far as it is [edit1]may be[/edit1] useful:

At least the commandline gof3r works fine so long as the HOME envar is defined (just did go get from a clean install of the go windows installer. I do my Windows commandline work from inside busybox-w32's ash shell, so that sets up a couple of other environment variables and lightly mangles the extant environment variables (converts \ to /, since / is also a valid path separator on Windows).

However, I was able to run it without it complaining.

I imagine that simply falling back on the value of USERPROFILE [edit1]except it should be APPDATA - that's the "right-er" place to put application settings in the Windows world[/edit1] instead of HOME when HOME is undefined would be the "smallest code change" way of working with Windows. It might also be possible to just gracefully have gof3r "degrade" by dropping any functionality that needs a HOME dir, because I would imagine that the core feature set should work regardless of whether there is a HOME directory.

@mentalisttraceur
Copy link

Actually, APPDATA is probably the "right-er" variable to use instead of USERPROFILE on Windows, because that's more in line with where the Windows-y way of putting application data is. I've edited my above comment accordingly as well.

@rlmcpherson
Copy link
Owner

@mentalisttraceur Thanks for the info, that's a good idea to gracefully degrade on windows and possibly also support APPDATA as well.

If you're interested in helping make this change, a pull request would be welcome. I don't have an easily-available windows system to test the change on so it might be a while before I can set one up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants