Skip to content

Set correct permissions on <dest> file creation #28

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

Closed
wants to merge 1 commit into from

Conversation

JustAdam
Copy link
Contributor

The creation of a new output file each time the config changes causes problems with its ownership and permissions; when the output file is on a Docker volume.
Without doing additional user adding/user space mapping stuff, Docker writes the file as root:root and 0600, which for all sense and purposes makes it unreadable for everything else.
If a file already exists, then the file's ownership and permissions are left untouched by Docker.

I couldn't see why a temp file was being used so this patch removes the use of it, and instead will truncate and overwrite the existing file.

@jwilder
Copy link
Collaborator

jwilder commented Sep 22, 2014

It's used so that updating the file is atomic. I also had plans to add a check command option but have not implemented it. It would use the temp file as input and run a check config type commander such as nginx -c /tmp/foo.tmp -t

@JustAdam JustAdam changed the title Removed use of temp file for comparison. Set correct permissions on <dest> file creation Sep 23, 2014
@JustAdam
Copy link
Contributor Author

I have updated the patch accordingly.

@JustAdam
Copy link
Contributor Author

Is either this or #27 likely to be merged?

if _, err := os.Stat(config.Dest); err == nil {
if fi, err := os.Stat(config.Dest); err == nil {
dest.Chmod(fi.Mode())
dest.Chown(int(fi.Sys().(*syscall.Stat_t).Uid), int(fi.Sys().(*syscall.Stat_t).Gid))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both of these calls ignore the error return value.

@JustAdam
Copy link
Contributor Author

Ah yes :) Fixed that

@jwilder
Copy link
Collaborator

jwilder commented Oct 1, 2014

Merged as 1b6ec.

@jwilder jwilder closed this Oct 1, 2014
@jwilder
Copy link
Collaborator

jwilder commented Oct 1, 2014

Thanks for the PR!

@JustAdam JustAdam deleted the generatefile-fix branch October 8, 2014 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants