aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-09 13:02:37 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-09 13:02:37 +0100
commit08c3711dd8b5a42108815ab42fec2b90096885a4 (patch)
treeb59bb45b3218f3e1f9fa5edd87d431077ca29d3a /src/libutil
parent4f6bfc0564efc37b37b8a66b0d54e42266517f3c (diff)
downloadrspamd-08c3711dd8b5a42108815ab42fec2b90096885a4.tar.gz
rspamd-08c3711dd8b5a42108815ab42fec2b90096885a4.zip
Fix ownership when listening on UNIX sockets.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/addr.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libutil/addr.c b/src/libutil/addr.c
index 1c7f4dbdf..042331008 100644
--- a/src/libutil/addr.c
+++ b/src/libutil/addr.c
@@ -285,8 +285,8 @@ rspamd_parse_unix_path (rspamd_inet_addr_t **target, const char *src)
#endif
addr->u.un->mode = 00644;
- addr->u.un->mode = 0;
- addr->u.un->group = 0;
+ addr->u.un->owner = (uid_t)-1;
+ addr->u.un->group = (gid_t)-1;
cur_tok = &tokens[1];
pwlen = sysconf (_SC_GETPW_R_SIZE_MAX);
@@ -602,11 +602,15 @@ rspamd_inet_address_listen (const rspamd_inet_addr_t *addr, gint type,
if (addr->af == AF_UNIX) {
path = addr->u.un->addr.sun_path;
/* Try to set mode and owner */
- if (chown (path, addr->u.un->owner, addr->u.un->group) == -1) {
- msg_info ("cannot change owner for %s to %d:%d: %s",
- path, addr->u.un->owner, addr->u.un->group,
- strerror (errno));
+
+ if (addr->u.un->owner != (uid_t)-1 || addr->u.un->group != (gid_t)-1) {
+ if (chown (path, addr->u.un->owner, addr->u.un->group) == -1) {
+ msg_info ("cannot change owner for %s to %d:%d: %s",
+ path, addr->u.un->owner, addr->u.un->group,
+ strerror (errno));
+ }
}
+
if (chmod (path, addr->u.un->mode) == -1) {
msg_info ("cannot change mode for %s to %od %s",
path, addr->u.un->mode, strerror (errno));