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

consul-template does not preserve user and group owners of existing destination file #1379

Closed
jsfrerot opened this issue May 12, 2020 · 3 comments · Fixed by #1473
Closed
Labels
Milestone

Comments

@jsfrerot
Copy link

Consul Template version

consul-template v0.25.0 (99efa64)

Opening new issue for same problem as 1061

Command

# ls -al web-key.pem
-rw-rw---- 1 root cloud 1675 May 12 17:14 web-key.pem
# systemctl restart consul-template@web
# ls -al web-key.pem
-rw-rw---- 1 root root 1679 May 12 17:26 web-key.pem

Expected behavior

What should have happened?
File shouldn't have changed ownership

Actual behavior

What actually happened?
Ownership is replace with the user/group of the running service. In this case root/root

Steps to reproduce

# ls -al web-key.pem
-rw-rw---- 1 root cloud 1675 May 12 17:14 web-key.pem
# systemctl restart consul-template@web
# ls -al web-key.pem
-rw-rw---- 1 root root 1679 May 12 17:26 web-key.pem

References

@findkim findkim added the bug label May 12, 2020
@eikenb
Copy link
Contributor

eikenb commented Feb 17, 2021

Hey @jsfrerot, belated thanks for the report.

I cannot reproduce this. Eg. running this little script the GID of the file stays the same and I verified the code is updating both the group (gid) and user (uid) ownership of the file. This is on Linux. Though it should work on any *nix. It will not work on Windows.

To run, replace [group] with a group are a member of (or anything if you test with root).

#!/bin/sh

rm -f out

echo foo > out
chgrp [group] out

cat > in.tmpl << EOF
bar
EOF

stat out
echo "-----------------------------------------------------------------"
consul-template -template "in.tmpl:out" -exec "cat out" -once > /dev/null
stat out

@AlexeyDemidov
Copy link

It seems that the file ownership is being reset to root:root when there is perms = present in template {} in the config file.

@eikenb
Copy link
Contributor

eikenb commented May 26, 2021

Thanks @AlexeyDemidov, I was able to reproduce it with that additional information. I'm looking into it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants