这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@wall6e
Copy link

@wall6e wall6e commented Jul 15, 2023

Would it be possible to use os.UserHomeDir() instead of usr.Current().HomeDir please ?

To my knowledge os.UserHomeDir() is the only function which take environment variables into account. On Unix, including macOS, it returns the $HOME environment variable. On Windows, it returns %USERPROFILE%.
More details can be found in the official documentation:
https://pkg.go.dev/os#UserHomeDir

See the test case below:
Difference between os.UserHomeDir() and usr.Current().HomeDir

The current state causes problems, for example, when using subfinder in an aws lambda. The home directory retrieved with usr.Current().HomeDir is "/home/sbx_user1051", whereas this part of the file system is impracticable because is read-only . As it stands, setting the environment variable $HOME doesn't get around this problem, and it's impossible to use a custom configuration.

See below, the output of the echo 'HOME='\$HOME; /go/bin/subfinder -d xxxx.com commands:

AWS lambda commands ouput

@ehsandeep
Copy link
Member

@wall6e see projectdiscovery/utils#172; this change will be added in all the PD projects via utils library upon next release.

@ehsandeep ehsandeep changed the base branch from main to dev July 31, 2023 10:17
@ehsandeep ehsandeep added the Status: On Hold Similar to blocked, but is assigned to someone label Jul 31, 2023
@Mzack9999 Mzack9999 removed the Status: On Hold Similar to blocked, but is assigned to someone label Aug 9, 2023
@Mzack9999
Copy link
Member

@Mzack9999 Mzack9999 self-requested a review August 9, 2023 13:11
@Mzack9999
Copy link
Member

@wall6e Thanks for your PR. Unfortunately I think the changes might not fix the issue as they are related to potential outdated code #930, additionally projectdiscovery/utils#172 doesn't address this particular scenario as https://github.com/projectdiscovery/utils/blob/cc554490e5c6deb0ce47330091c457e10992240a/folder/folderutil.go#L149 uses user.Current() which internally relies on entries from passwd files (ref: https://linux.die.net/man/3/getpwuid) - probably the change should be made within github.com/projectdiscovery/utils/folder/folderutil.go.HomeDirOrDefault(..)

@dogancanbakir
Copy link
Member

Fixed in #1013, closing this.

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