Mercurial > dovecot > core-2.2
view src/lib/unix-socket-create.c @ 18137:3009a1a6f6d5
global: freshen copyright
Robomatically:
git ls-files | xargs perl -p -i -e 's/(\d+)-201[0-4]/$1-2015/g;s/ (201[0-4]) Dovecot/ $1-2015 Dovecot/'
Happy 2015 everyone!
Signed-off-by: Phil Carmody <phil@dovecot.fi>
author | Phil Carmody <phil@dovecot.fi> |
---|---|
date | Mon, 05 Jan 2015 22:20:10 +0200 |
parents | add8c00fb3cc |
children | 0f22db71df7a |
line wrap: on
line source
/* Copyright (c) 2005-2015 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "net.h" #include "unix-socket-create.h" #include <unistd.h> #include <sys/stat.h> int unix_socket_create(const char *path, int mode, uid_t uid, gid_t gid, int backlog) { mode_t old_umask; int fd; old_umask = umask(0777 ^ mode); fd = net_listen_unix_unlink_stale(path, backlog); umask(old_umask); if (fd < 0) { i_error("net_listen_unix(%s) failed: %m", path); return -1; } if (uid != (uid_t)-1 || gid != (gid_t)-1) { /* set correct permissions */ if (chown(path, uid, gid) < 0) { i_error("chown(%s, %s, %s) failed: %m", path, dec2str(uid), dec2str(gid)); i_close_fd(&fd); return -1; } } return fd; }