Skip to content
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

dnsdist: Save history to home-dir #4779

Merged
merged 1 commit into from
Jan 13, 2017

Conversation

pieterlexis
Copy link
Contributor

Short description

Only use CWD as a last resort. This prevents cluttering directories with .dnsdist_history files

Closes #4562

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled and tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added regression tests
  • added unit tests
  • checked that this code was merged to master

struct passwd pwd;
struct passwd *result;
char buf[16384];
getpwuid_r(getuid(), &pwd, buf, sizeof(buf), &result);
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should use geteuid() instead, in the unlikely event dnsdist is started with -u while in foreground mode.

ret = string(pwd.pw_dir);
if (homedir && !ignoreHOME) // $HOME overrides what the OS tells us
ret = string(homedir);
ret.append("/.dnsdist_history");
Copy link
Member

Choose a reason for hiding this comment

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

How about not setting ret to "." beforehand and testing here if it's empty? If it is (somehow $HOME or pwd.pw_dir were empty or nothing worked), we could then fallback to "." before appending "/.dnsdist_history". This would prevent trying to write in "/.dnsdist_history".

@pieterlexis pieterlexis force-pushed the dnsdist-history-to-home branch from 936c472 to 9364403 Compare December 20, 2016 11:51
@pieterlexis pieterlexis merged commit 6f3c797 into PowerDNS:master Jan 13, 2017
@pieterlexis pieterlexis deleted the dnsdist-history-to-home branch January 13, 2017 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants