If the user wants the fd to stay valid he should keep a reference to the
message object or duplicate the fd.
This unifies behaviour of demarshalling data fields and unix fds.
break;
case SD_BUS_TYPE_UNIX_FD: {
- int copy;
uint32_t j;
j = BUS_MESSAGE_BSWAP32(m, *(uint32_t*) q);
if (j >= m->n_fds)
return -EBADMSG;
- copy = fcntl(m->fds[j], F_DUPFD_CLOEXEC, 3);
- if (copy < 0)
- return -errno;
-
- *(int*) p = copy;
+ *(int*) p = m->fds[j];
break;
}
goto fail;
}
- close_nointr_nofail(fd);
-
r = sd_bus_reply_method_return(bus, m, NULL);
if (r < 0) {
log_error("Failed to send reply: %s", strerror(-r));