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 building on Android by avoiding getpwent() #3441
Fix building on Android by avoiding getpwent() #3441
Conversation
The getpwent() function does not link when building for Android, and user names on that platform are not interesting anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like the "return 0" thing going on here - and there still should be usernames on Android, interesting or not. I'd like if you checked getpwent linkability in autoconf and provided a workaround of some sort, if practical.
@@ -1187,6 +1187,10 @@ bool completer_t::try_complete_variable(const wcstring &str) { | |||
/// | |||
/// \return 0 if unable to complete, 1 otherwise | |||
bool completer_t::try_complete_user(const wcstring &str) { | |||
#ifdef __ANDROID__ | |||
// The getpwent() call does not exist on Android (and user names are not interesting). | |||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is strictly speaking correct and functionally equivalent to return false;
please do the latter for clarity. Having said that, I agree with @floam that since Android is derived from Linux it presumably does utilize UIDs and we should therefore be returning something meaningful on that platform if that is possible. If everything doesn't run as UID zero, and there is no other way to map a UID to name, perhaps this should simply synthesize a user name by doing something like return sprintf(buf, "user#%d", getuid());
. That is obviously just pseudo-code but you get the idea.
Thanks a lot for the feedback! I've updated from As for a fallback, a Linux user on Android isn't really a user - each installed app gets an UID assigned. Listing all UID:s is not possible without root access, and doing a ~USER type expansion does not make sense since every app is sandboxed and can't access eachother. So I think a fallback is not really possible. As for an autoconf check if |
Okay, given that in Android OS there really isn't any such thing as usernames I'm okay with just returning false for that completer. Go ahead and make the behavior dependent on whether there is a usable getpwent() and I think you're done. |
I found this stuff interesting: http://androidxref.com/4.2.2_r1/xref/bionic/libc/docs/OVERVIEW.TXT#231 http://androidxref.com/5.0.0_r2/xref/bionic/libc/bionic/stubs.cpp#357 Maybe we could do similar. There are some mappings defined in a header file as well. |
For the record I would prefer an autoconf check for whether |
Great, we can merge this. |
@krader1961 Changed it to an autoconf check instead of I've left the Android-specific comments for now as it's the only relevant platform I know about lacking getpwent() - let me know if those comments should be removed/changed! |
The getpwent() function does not link when building for Android, and user names on that platform are not interesting anyway.
This patch is part of an effort to upstream patches used by the fish package in Termux.