-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 username lookup in case of missing USER environment variable #245
Conversation
Ping? |
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'll do these changes by myself.
#if defined(HAVE_PWD_H) && defined(HAVE_UNISTD_H) | ||
uid_t uid; | ||
struct passwd pwd; | ||
struct passwd*result = NULL; |
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.
Could you add a whitespace right before "result"?
struct passwd* result = NULL
struct passwd*result = NULL; | ||
char buffer[1024] = {'\0'}; | ||
uid = geteuid(); | ||
int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof (buffer), &result); |
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.
Could you remove the whitespace between sizeof and buffer?
int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof (buffer), &result); | ||
if(pwuid_res == 0) { | ||
g_my_user_name = pwd.pw_name; | ||
} |
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.
Please concatenate with the next line
char buffer[1024] = {'\0'}; | ||
uid = geteuid(); | ||
int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof (buffer), &result); | ||
if(pwuid_res == 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.
A whitespace after "if"
Sorry for the latency.. |
Thanks |
Fix username lookup in case of missing USER environment variable
This commit fixes an issue with invalid-user in file prefix when USER environment variable is not defined.