-
Notifications
You must be signed in to change notification settings - Fork 241
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
su: Fix su - regression #1163
su: Fix su - regression #1163
Conversation
Launch a login shell again if requested through "su -" or "su -l". Fixes: d992343 ("src/: Use xasprintf() instead of its pattern") Closes: <shadow-maint#1160> Signed-off-by: Tobias Stoeckmann <[email protected]>
Should work. Is there a guarantee somewhere that Since I didn't find this guarantee now, I'll let maintainers decide and keep it as it is now to highlight the regression without doing more refactoring. |
Fair enough. I just noticed that cp was being reused throughout that section of code, so it seemed in keeping with the general flow. In this case, the first parameter is the address of the cp pointer, while the 3rd parameter is the value of the cp pointer so I don't believe it will be a problem here. That said, the stdarg variadic stuff in C has always struck me as a bit weird and kludgy. I usually try and avoid using it in my own code. wherever possible. Anyway, thanks for PR and the response,. As you say,, the shadow guys can decide for themselves. In all honesty, I preferred the old code before they switched to xasprintf(). |
Oh right, it's call by value for the var args. In that case your suggestion works as well. Thanks for clarification. |
It seems glibc is missing a $ grepc vasprintf /usr/include/
/usr/include/stdio.h:extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
__gnuc_va_list __arg)
__THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur; It should have I'll CC a few maintainers (we should also email their mailing list, but I'll CC them here for completeness). Cc: @fweimer-rh , @eggert |
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.
@hallyn should we release from master? Since we haven't yet applied any commits to master, I think this would be simpler.
|
Agree. Your patch better shows the regression. I'll merge now. Thanks! |
Sorry what does "release from master" mean @alejandro-colomar |
Should you release 4.17.1 just like you do with the .0 releases? Or should I create a That is, the commit that changes the version number should be on a branch. I would put that commit in the master branch, for simplicity. Would you do the honours? |
Oh. I can't think of a particular advantage to either one. |
Sure I can do from master branch. |
(seems we should have a testcase for this, using expect...) |
On the API design space, I don't like this API. I can't blame the authors, since it was designed a long time ago, way before the malloc() GNU attribute was invented (I think), and before static analysis was so powerful. These days, it would have been better to return a pointer to the newly allocated string, just like strdup(3). That would allow a much better static analysis. It also makes it obvious that the old value of the pointer is unimportant and ignored. Since most callers don't care about the length, but some may, I would have a That would result in |
Hmmm, I would go further and say that those who care about the lenght, would avoid asprintf(3) altogether, and use some faster APIs. And if one wants the length ocasionally, they can just call strlen(3); the performance loss by calling strlen(3) is negligible after a call to asprintf(3). So a good API would just omit the length at all, and just return the newly allocated string. New API in the oven, cooking while listening to the New Year's Concert by the Vienna Philharmonic. :) |
Launch a login shell again if requested through "su -" or "su -l".
Fixes: d992343 ("src/: Use xasprintf() instead of its pattern")
Closes: #1160