Maintain ownership when rewriting universal variables file

Fixes #2176
This commit is contained in:
ridiculousfish 2015-09-26 15:24:55 -07:00
parent c30de8add4
commit f086bc9564

View File

@ -847,6 +847,14 @@ bool env_universal_t::sync(callback_data_list_t *callbacks)
if (success)
{
/* Ensure we maintain ownership and permissions (#2176) */
struct stat sbuf;
if (wstat(vars_path, &sbuf) >= 0)
{
fchown(private_fd, sbuf.st_uid, sbuf.st_gid);
fchmod(private_fd, sbuf.st_mode);
}
/* Apply new file */
success = this->move_new_vars_file_into_place(private_file_path, vars_path);
}