<div dir="ltr">Hi there,<div><br></div><div>The issue has been discussed before, in case of this patch <a href="http://reviews.llvm.org/D14446">http://reviews.llvm.org/D14446</a>.</div><div><br></div><div>Some see this issue as a feature to disable access to home directory. </div><div><br></div><div>I'm happy to implement whatever we agree on.</div><div><br></div><div>- Paweł</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 20, 2016 at 8:51 AM Sean Silva via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">We probably don't want to silently mutate the environment (which could lead to surprises), but calling a proper system library function to get the home directory makes sense.</div><div dir="ltr"><div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 19, 2016 at 11:18 AM, Greg Clayton via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I recently was using llvm code from a process that I manually spawned as a child process and noticed that llvm::sys::path::home_directory() only works if "HOME" is set in the process environment:<br>
<br>
bool home_directory(SmallVectorImpl<char> &result) {<br>
if (char *RequestedDir = getenv("HOME")) {<br>
result.clear();<br>
result.append(RequestedDir, RequestedDir + strlen(RequestedDir));<br>
return true;<br>
}<br>
<br>
return false;<br>
}<br>
<br>
This is in lib/Support/Unix/Path.inc. Do we want to try a little bit harder? Maybe something like:<br>
<br>
bool home_directory(SmallVectorImpl<char> &result) {<br>
if (char *RequestedDir = getenv("HOME")) {<br>
result.clear();<br>
result.append(RequestedDir, RequestedDir + strlen(RequestedDir));<br>
return true;<br>
} else {<br>
struct passwd *pw = getpwuid(getuid());<br>
if (pw && pw->pw_dir && pw->pw_dir[0])<br>
{<br>
setenv("HOME", pw->pw_dir, 0);<br>
result.assign(llvm::StringRef(pw->pw_dir));<br>
return true;<br>
}<br>
}<br>
return false;<br>
}<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>