Because mkstemp() create a file with mode 0600, only user doing
the commit (typically root) will be allowed to inspect the content
of the file after uci commit.
Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
char *volatile name = NULL;
char *volatile path = NULL;
char *filename = NULL;
char *volatile name = NULL;
char *volatile path = NULL;
char *filename = NULL;
volatile bool do_rename = false;
int fd;
volatile bool do_rename = false;
int fd;
uci_close_stream(f1);
if (do_rename) {
path = realpath(p->path, NULL);
uci_close_stream(f1);
if (do_rename) {
path = realpath(p->path, NULL);
- if (!path || rename(filename, path)) {
+ if (!path || stat(path, &statbuf) || chmod(filename, statbuf.st_mode) || rename(filename, path)) {
unlink(filename);
UCI_THROW(ctx, UCI_ERR_IO);
}
unlink(filename);
UCI_THROW(ctx, UCI_ERR_IO);
}