fr_strerror_printf("Failed determining parent directory");
error:
talloc_free(dir);
- close(dir_fd);
+ if (sock_fd >= 0) close(sock_fd);
+ if (dir_fd >= 0) close(dir_fd);
+ if (parent_fd >= 0) close(parent_fd);
return -1;
}
if (ret < 0) {
fr_strerror_printf("Failed changing ownership of control socket directory: %s",
fr_syserror(errno));
- return -1;
+ goto error;
}
/*
* Control socket dir already exists, but we still need to
if (client_fd >= 0) {
fr_strerror_printf("Control socket '%s' is already in use", path);
close(client_fd);
- return -1;
+ goto error;
}
}
if (uid != (uid_t)-1) rad_seuid(euid);
if (gid != (gid_t)-1) rad_segid(egid);
- close(dir_fd);
+ if (dir_fd >= 0) close(dir_fd);
+ if (parent_fd >= 0) close(parent_fd);
return sock_fd;
}