temp_path = t_strconcat(path, ".tmp", NULL);
old_mask = umask(0);
- fd = open(temp_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ fd = open(temp_path, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0600);
umask(old_mask);
if (fd == -1) {
if (dict->fd == -1) {
/* quota file doesn't exist yet, we need to create it */
- dict->fd = open(dict->path, O_CREAT | O_RDWR, 0600);
+ dict->fd = open(dict->path, O_CREAT | O_RDWR | O_NOFOLLOW, 0600);
if (dict->fd == -1 && errno == ENOENT) {
if (file_dict_mkdir(dict, error_r) < 0)
return -1;
- dict->fd = open(dict->path, O_CREAT | O_RDWR, 0600);
+ dict->fd = open(dict->path, O_CREAT | O_RDWR | O_NOFOLLOW, 0600);
}
if (dict->fd == -1) {
if (errno == EACCES)
if (file_dict_lock(dict, &lock, error_r) < 0)
return -1;
temp_path = t_strdup_printf("%s.tmp", dict->path);
- fd = creat(temp_path, 0600);
+ fd = open(temp_path, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0600);
if (fd == -1) {
*error_r = t_strdup_printf(
"dict-file: creat(%s) failed: %m", temp_path);
path = *path_r = t_strconcat(path_prefix, ".tmp", NULL);
old_mask = umask(0);
- fd = open(path, O_RDWR|O_CREAT|O_EXCL, index->set.mode);
+ fd = open(path, O_RDWR|O_CREAT | O_EXCL | O_NOFOLLOW, index->set.mode);
umask(old_mask);
if (fd == -1 && errno == EEXIST) {
/* stale temp file. unlink and recreate rather than overwriting,
if (i_unlink(path) < 0)
return -1;
old_mask = umask(0);
- fd = open(path, O_RDWR|O_CREAT|O_EXCL, index->set.mode);
+ fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
+ index->set.mode);
umask(old_mask);
}
if (fd == -1) {
i_assert(log->fd == -1);
log->open_timestamp = ioloop_time;
- log->fd = open(log->filepath, O_RDWR | O_APPEND);
+ log->fd = open(log->filepath, O_RDWR | O_APPEND | O_NOFOLLOW);
if (log->fd != -1)
return 0;
/* try to create it */
old_mode = umask(0666 ^ log->mode);
- log->fd = open(log->filepath, O_RDWR | O_APPEND | O_CREAT, 0666);
+ log->fd = open(log->filepath, O_RDWR | O_APPEND | O_CREAT | O_NOFOLLOW, 0666);
umask(old_mode);
if (log->fd == -1) {
test_assert(expect_index_rewrite);
path = *path_r = t_strconcat(path_prefix, ".tmp", NULL);
- fd = open(path, O_RDWR|O_CREAT, 0600);
+ fd = open(path, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
if (fd == -1) {
i_error("creat() failed: %m");
return -1;
return;
}
- fd = open(str_c(path), O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, 0600);
+ fd = open(str_c(path), O_WRONLY | O_CREAT | O_TRUNC |
+ O_NONBLOCK | O_NOFOLLOW, 0600);
if (fd == -1) {
e_error(db->api.event, "creat(%s) failed: %m", str_c(path));
return;
int fd;
old_mask = umask(0666 & ~perm->file_create_mode);
- fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open(path, O_RDWR | O_CREAT | O_TRUNC | O_NOFOLLOW, 0666);
umask(old_mask);
if (fd == -1 && errno == ENOENT && parents &&
(p = strrchr(path, '/')) != NULL) {
}
/* try again */
old_mask = umask(0666 & ~perm->file_create_mode);
- fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open(path, O_RDWR | O_CREAT | O_TRUNC | O_NOFOLLOW, 0666);
umask(old_mask);
}
if (fd == -1) {
useless. */
old_mask = umask(0777 & ~perm->file_create_mode);
fd = open(str_c(path),
- O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0777);
+ O_WRONLY | O_CREAT | O_TRUNC | O_EXCL | O_NOFOLLOW, 0777);
umask(old_mask);
} while (fd == -1 && errno == EEXIST);
old_mask = umask(0);
path = t_strconcat(path, "/dovecot-shared", NULL);
- fd = open(path, O_WRONLY | O_CREAT, perm->file_create_mode);
+ fd = open(path, O_WRONLY | O_CREAT | O_NOFOLLOW, perm->file_create_mode);
umask(old_mask);
if (fd == -1) {
path = t_strconcat(mailbox_get_path(box),
"/"MAILDIR_SUBFOLDER_FILENAME, NULL);
old_mask = umask(0);
- fd = open(path, O_CREAT | O_WRONLY, perm->file_create_mode);
+ fd = open(path, O_CREAT | O_WRONLY | O_NOFOLLOW, perm->file_create_mode);
umask(old_mask);
if (fd != -1) {
/* ok */
for (i = 0;; i++) {
old_mask = umask(0777 & ~perm->file_create_mode);
- fd = open(temp_path, O_RDWR | O_CREAT | O_TRUNC, 0777);
+ fd = open(temp_path, O_RDWR | O_CREAT | O_TRUNC | O_NOFOLLOW, 0777);
umask(old_mask);
if (fd != -1)
break;
mailbox_list_get_root_permissions(list, &perm);
old_mask = umask(0666 & ~perm.file_create_mode);
- fd = open(path, O_RDWR | O_CREAT, 0666);
+ fd = open(path, O_RDWR | O_CREAT | O_NOFOLLOW, 0666);
umask(old_mask);
if (fd == -1) {
e_error(user->event, "open(%s) failed: %m", path);
tmp = t_strdup_printf("%s.%08x", path, cur_value);
/* the file is empty, don't bother with permissions */
old_mask = umask(0);
- fd = open(tmp, O_RDWR | O_CREAT | O_EXCL, 0444);
+ fd = open(tmp, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0444);
umask(old_mask);
if (fd != -1 || errno != EEXIST)
break;
}
old_umask = umask(0);
- fd_out = open(tmppath, O_WRONLY | O_CREAT | O_TRUNC, st.st_mode);
+ fd_out = open(tmppath, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, st.st_mode);
umask(old_umask);
if (fd_out == -1) {
i_error("open(%s, O_CREAT) failed: %m", tmppath);
{
int fd;
- fd = open(lock_info->lock_path, O_RDWR | O_EXCL | O_CREAT, 0666);
+ fd = open(lock_info->lock_path, O_RDWR | O_EXCL | O_CREAT | O_NOFOLLOW, 0666);
if (fd == -1) {
if (errno == EEXIST)
return 0;
int in_fd, out_fd;
in_path = t_strdup_printf("%s.in", prefix);
- in_fd = open(in_path, O_CREAT | O_APPEND | O_WRONLY, 0600);
+ in_fd = open(in_path, O_CREAT | O_APPEND | O_WRONLY | O_NOFOLLOW, 0600);
if (in_fd == -1) {
if (errno != ENOENT && !ENOACCESS(errno))
i_error("rawlog: creat(%s) failed: %m", in_path);
}
out_path = t_strdup_printf("%s.out", prefix);
- out_fd = open(out_path, O_CREAT | O_APPEND | O_WRONLY, 0600);
+ out_fd = open(out_path, O_CREAT | O_APPEND | O_WRONLY | O_NOFOLLOW, 0600);
if (out_fd == -1) {
if (errno != ENOENT && !ENOACCESS(errno))
i_error("rawlog: creat(%s) failed: %m", out_path);
if ((ret = iostream_rawlog_try_create_tcp(path, input, output)) != 0)
return ret < 0 ? -1 : 0;
- fd = open(path, O_CREAT | O_APPEND | O_WRONLY, 0600);
+ fd = open(path, O_CREAT | O_APPEND | O_WRONLY | O_NOFOLLOW, 0600);
if (fd == -1) {
if (errno != ENOENT && !ENOACCESS(errno))
i_error("rawlog: creat(%s) failed: %m", path);
enum ostream_create_file_flags flags)
{
int fd;
- int open_flags = O_WRONLY|O_CREAT;
+ int open_flags = O_WRONLY | O_CREAT | O_NOFOLLOW;
if (HAS_ANY_BITS(flags, OSTREAM_CREATE_FILE_FLAG_APPEND))
open_flags |= O_APPEND;
else
int fd;
old_umask = umask(0666 ^ mode);
- fd = open(path, O_RDWR | O_EXCL | O_CREAT, 0666);
+ fd = open(path, O_RDWR | O_EXCL | O_CREAT | O_NOFOLLOW, 0666);
umask(old_umask);
if (fd != -1)
/* write the error message to a file (we're chdired to
base dir) */
path = t_strconcat(FATAL_FILENAME, NULL);
- fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
+ fd = open(path, O_CREAT | O_TRUNC | O_WRONLY | O_NOFOLLOW, 0600);
if (fd != -1) {
VA_COPY(args2, args);
str = t_strdup_vprintf(format, args2);
pid = t_strconcat(dec2str(getpid()), "\n", NULL);
- fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0644);
if (fd == -1)
i_fatal("open(%s) failed: %m", path);
if (write_full(fd, pid, strlen(pid)) < 0)
static bool exporter_file_open_plain(struct file_event_exporter *node)
{
- node->fd = open(node->fname, O_CREAT|O_APPEND|O_WRONLY, 0600);
+ node->fd = open(node->fname, O_CREAT | O_APPEND | O_WRONLY |
+ O_NOFOLLOW, 0600);
if (node->fd == -1) {
if (ioloop_time - node->last_error > EXPORTER_LAST_ERROR_DELAY)
exporter_file_open_error(node, "open");
if ((proxy->flags & RAWLOG_FLAG_LOG_INPUT) != 0) {
fname = t_strdup_printf("%s.in", str_c(path_prefix));
- fd = open(fname, O_CREAT|O_EXCL|O_WRONLY, 0600);
+ fd = open(fname, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600);
if (fd == -1) {
i_error("rawlog_open: creat(%s): %m", fname);
return;
if ((proxy->flags & RAWLOG_FLAG_LOG_OUTPUT) != 0) {
fname = t_strdup_printf("%s.out", str_c(path_prefix));
- fd = open(fname, O_CREAT|O_EXCL|O_WRONLY, 0600);
+ fd = open(fname, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600);
if (fd == -1) {
i_error("rawlog_open: creat(%s): %m", fname);
o_stream_destroy(&proxy->in_output);