Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Conversation

@DariuszOstolski
Copy link
Contributor

@DariuszOstolski DariuszOstolski commented Sep 19, 2017

This commit fixes an issue with invalid-user in file prefix when USER environment variable is not defined.

@DariuszOstolski
Copy link
Contributor Author

Ping?

Copy link
Contributor

@shinh shinh left a 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;
Copy link
Contributor

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);
Copy link
Contributor

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;
}
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A whitespace after "if"

@shinh
Copy link
Contributor

shinh commented Oct 20, 2017

Sorry for the latency..

@shinh shinh merged commit ebf81ac into google:master Oct 20, 2017
@DariuszOstolski
Copy link
Contributor Author

Thanks

durswd pushed a commit to durswd/glog that referenced this pull request Sep 2, 2019
Fix username lookup in case of missing USER environment variable
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants