-
Notifications
You must be signed in to change notification settings - Fork 616
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
settings: Only call MkdirAll on save #542
Conversation
Previously settingsFileName() created the ~/.config/pprof directory if it did not exist. However, this is not possible for user nobody, since its home directory is set to "/nonexistent". Instead, only create the directory when we actually attempt to save the file, so the error will happen at the appropriate interaction. This als prevents pprof from creating empty settings directories. Fixes the following error when running pprof's web UI as user nobody: mkdir /nonexistent: permission denied
internal/driver/settings.go
Outdated
|
||
// create the settings directory if it does not exist | ||
fdir := filepath.Dir(fname) | ||
if _, err := os.Stat(fdir); os.IsNotExist(err) { |
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.
Why is this check needed? I.e. why not os.MkdirAll(fdir, 0700)?
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.
Great suggestion. Mostly because I didn't think of it. It turns out: MkdirAll does exactly this stat right at the beginning. Oops! Removing this now.
Codecov Report
@@ Coverage Diff @@
## master #542 +/- ##
==========================================
- Coverage 68.33% 68.33% -0.01%
==========================================
Files 39 39
Lines 8006 8005 -1
==========================================
- Hits 5471 5470 -1
Misses 2114 2114
Partials 421 421
Continue to review full report at Codecov.
|
if err := os.MkdirAll(filepath.Dir(fname), 0700); err != nil { | ||
return fmt.Errorf("failed to create settings directory: %w", err) | ||
} | ||
|
||
if err := ioutil.WriteFile(fname, data, 0644); err != nil { |
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.
Maybe this should have been changed to 0600 too.
Bump from 20191205061153 => 20201109224723 My personal interest is to pull in google/pprof#564, which adds support for displaying names with `"` in them, which julia functions sometimes have (e.g. `var"#foo#23"`) Includes: - google/pprof#564 - google/pprof#575 - google/pprof#574 - google/pprof#571 - google/pprof#572 - google/pprof#570 - google/pprof#562 - google/pprof#561 - google/pprof#565 - google/pprof#560 - google/pprof#563 - google/pprof#557 - google/pprof#554 - google/pprof#552 - google/pprof#545 - google/pprof#549 - google/pprof#547 - google/pprof#541 - google/pprof#534 - google/pprof#542 - google/pprof#535 - google/pprof#531 - google/pprof#530 - google/pprof#528 - google/pprof#522 - google/pprof#525 - google/pprof#527 - google/pprof#519 - google/pprof#520 - google/pprof#517 - google/pprof#518 - google/pprof#514 - google/pprof#513 - google/pprof#510 - google/pprof#508 - google/pprof#506 - google/pprof#509 - google/pprof#504
* Update pprof to latest revision Bump from 20191205061153 => 20201109224723 My personal interest is to pull in google/pprof#564, which adds support for displaying names with `"` in them, which julia functions sometimes have (e.g. `var"#foo#23"`) Includes: - google/pprof#564 - google/pprof#575 - google/pprof#574 - google/pprof#571 - google/pprof#572 - google/pprof#570 - google/pprof#562 - google/pprof#561 - google/pprof#565 - google/pprof#560 - google/pprof#563 - google/pprof#557 - google/pprof#554 - google/pprof#552 - google/pprof#545 - google/pprof#549 - google/pprof#547 - google/pprof#541 - google/pprof#534 - google/pprof#542 - google/pprof#535 - google/pprof#531 - google/pprof#530 - google/pprof#528 - google/pprof#522 - google/pprof#525 - google/pprof#527 - google/pprof#519 - google/pprof#520 - google/pprof#517 - google/pprof#518 - google/pprof#514 - google/pprof#513 - google/pprof#510 - google/pprof#508 - google/pprof#506 - google/pprof#509 - google/pprof#504 * Update P/pprof/build_tarballs.jl - use a real version number Co-authored-by: Mosè Giordano <[email protected]> * Remove now unused `timestamp` * [pprof] Use `GitSource` Co-authored-by: Mosè Giordano <[email protected]>
settings: Only call MkdirAll on save Previously settingsFileName() created the ~/.config/pprof directory if it did not exist. However, this is not possible for user nobody, since its home directory is set to "/nonexistent". Instead, only create the directory when we actually attempt to save the file, so the error will happen at the appropriate interaction. This als prevents pprof from creating empty settings directories. Fixes the following error when running pprof's web UI as user nobody: mkdir /nonexistent: permission denied
Previously settingsFileName() created the ~/.config/pprof directory
if it did not exist. However, this is not possible for user nobody,
since its home directory is set to "/nonexistent". Instead, only
create the directory when we actually attempt to save the file, so
the error will happen at the appropriate interaction. This als
prevents pprof from creating empty settings directories.
Fixes the following error when running pprof's web UI as user nobody: