mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-15 06:42:51 +01:00
Style cleanup.
This commit is contained in:
parent
a716ad4a35
commit
e86caa0bd0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=341009
@ -144,29 +144,27 @@ safe_read(struct cached_connection_ *connection, void *data, size_t data_size)
|
||||
static int
|
||||
send_credentials(struct cached_connection_ *connection, int type)
|
||||
{
|
||||
union {
|
||||
struct cmsghdr hdr;
|
||||
char pad[CMSG_SPACE(sizeof(struct cmsgcred))];
|
||||
} cmsg;
|
||||
struct msghdr mhdr;
|
||||
struct iovec iov;
|
||||
struct kevent eventlist;
|
||||
int nevents;
|
||||
ssize_t result;
|
||||
int res;
|
||||
|
||||
struct msghdr cred_hdr;
|
||||
struct iovec iov;
|
||||
|
||||
struct {
|
||||
struct cmsghdr hdr;
|
||||
char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
|
||||
} cmsg;
|
||||
|
||||
memset(&cmsg, 0, sizeof(cmsg));
|
||||
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(struct cmsgcred));
|
||||
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(struct cmsgcred));
|
||||
cmsg.hdr.cmsg_level = SOL_SOCKET;
|
||||
cmsg.hdr.cmsg_type = SCM_CREDS;
|
||||
|
||||
memset(&cred_hdr, 0, sizeof(struct msghdr));
|
||||
cred_hdr.msg_iov = &iov;
|
||||
cred_hdr.msg_iovlen = 1;
|
||||
cred_hdr.msg_control = (caddr_t)&cmsg;
|
||||
cred_hdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
|
||||
memset(&mhdr, 0, sizeof(mhdr));
|
||||
mhdr.msg_iov = &iov;
|
||||
mhdr.msg_iovlen = 1;
|
||||
mhdr.msg_control = &cmsg;
|
||||
mhdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
|
||||
|
||||
iov.iov_base = &type;
|
||||
iov.iov_len = sizeof(int);
|
||||
@ -178,8 +176,8 @@ send_credentials(struct cached_connection_ *connection, int type)
|
||||
nevents = _kevent(connection->write_queue, NULL, 0, &eventlist, 1,
|
||||
NULL);
|
||||
if (nevents == 1 && eventlist.filter == EVFILT_WRITE) {
|
||||
result = (_sendmsg(connection->sockfd, &cred_hdr,
|
||||
MSG_NOSIGNAL) == -1) ? -1 : 0;
|
||||
result = _sendmsg(connection->sockfd, &mhdr,
|
||||
MSG_NOSIGNAL) == -1 ? -1 : 0;
|
||||
EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
|
||||
0, 0, NULL);
|
||||
_kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
|
||||
|
@ -130,44 +130,41 @@ safe_read(struct nscd_connection_ *connection, void *data, size_t data_size)
|
||||
static int
|
||||
send_credentials(struct nscd_connection_ *connection, int type)
|
||||
{
|
||||
union {
|
||||
struct cmsghdr hdr;
|
||||
char pad[CMSG_SPACE(sizeof(struct cmsgcred))];
|
||||
} cmsg;
|
||||
struct msghdr mhdr;
|
||||
struct iovec iov;
|
||||
struct kevent eventlist;
|
||||
int nevents;
|
||||
ssize_t result;
|
||||
int res;
|
||||
|
||||
struct msghdr cred_hdr;
|
||||
struct iovec iov;
|
||||
|
||||
union {
|
||||
struct cmsghdr hdr;
|
||||
char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
|
||||
} cmsg;
|
||||
|
||||
TRACE_IN(send_credentials);
|
||||
memset(&cmsg, 0, sizeof(cmsg));
|
||||
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(struct cmsgcred));
|
||||
cmsg.hdr.cmsg_level = SOL_SOCKET;
|
||||
cmsg.hdr.cmsg_type = SCM_CREDS;
|
||||
|
||||
memset(&cred_hdr, 0, sizeof(struct msghdr));
|
||||
cred_hdr.msg_iov = &iov;
|
||||
cred_hdr.msg_iovlen = 1;
|
||||
cred_hdr.msg_control = &cmsg;
|
||||
cred_hdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
|
||||
memset(&mhdr, 0, sizeof(mhdr));
|
||||
mhdr.msg_iov = &iov;
|
||||
mhdr.msg_iovlen = 1;
|
||||
mhdr.msg_control = &cmsg;
|
||||
mhdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
|
||||
|
||||
iov.iov_base = &type;
|
||||
iov.iov_len = sizeof(int);
|
||||
|
||||
EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
|
||||
NOTE_LOWAT, sizeof(int), NULL);
|
||||
NOTE_LOWAT, sizeof(int), NULL);
|
||||
res = kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
|
||||
|
||||
nevents = kevent(connection->write_queue, NULL, 0, &eventlist, 1, NULL);
|
||||
if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
|
||||
result = (sendmsg(connection->sockfd, &cred_hdr, 0) == -1) ? -1
|
||||
: 0;
|
||||
result = sendmsg(connection->sockfd, &mhdr, 0) == -1 ? -1 : 0;
|
||||
EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
|
||||
0, 0, NULL);
|
||||
0, 0, NULL);
|
||||
kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
|
||||
TRACE_OUT(send_credentials);
|
||||
return (result);
|
||||
|
@ -155,38 +155,37 @@ clear_config_entry_part(struct configuration_entry *config_entry,
|
||||
static int
|
||||
on_query_startup(struct query_state *qstate)
|
||||
{
|
||||
struct msghdr cred_hdr;
|
||||
struct iovec iov;
|
||||
union {
|
||||
struct cmsghdr hdr;
|
||||
char pad[CMSG_SPACE(sizeof(struct cmsgcred))];
|
||||
} cmsg;
|
||||
struct msghdr mhdr;
|
||||
struct iovec iov;
|
||||
struct cmsgcred *cred;
|
||||
int elem_type;
|
||||
|
||||
union {
|
||||
struct cmsghdr hdr;
|
||||
char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
|
||||
} cmsg;
|
||||
|
||||
TRACE_IN(on_query_startup);
|
||||
assert(qstate != NULL);
|
||||
|
||||
memset(&cred_hdr, 0, sizeof(struct msghdr));
|
||||
cred_hdr.msg_iov = &iov;
|
||||
cred_hdr.msg_iovlen = 1;
|
||||
cred_hdr.msg_control = &cmsg;
|
||||
cred_hdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
|
||||
memset(&mhdr, 0, sizeof(mhdr));
|
||||
mhdr.msg_iov = &iov;
|
||||
mhdr.msg_iovlen = 1;
|
||||
mhdr.msg_control = &cmsg;
|
||||
mhdr.msg_controllen = sizeof(cmsg);
|
||||
|
||||
memset(&iov, 0, sizeof(struct iovec));
|
||||
memset(&iov, 0, sizeof(iov));
|
||||
iov.iov_base = &elem_type;
|
||||
iov.iov_len = sizeof(int);
|
||||
iov.iov_len = sizeof(elem_type);
|
||||
|
||||
if (recvmsg(qstate->sockfd, &cred_hdr, 0) == -1) {
|
||||
if (recvmsg(qstate->sockfd, &mhdr, 0) == -1) {
|
||||
TRACE_OUT(on_query_startup);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (cred_hdr.msg_controllen < CMSG_LEN(sizeof(struct cmsgcred))
|
||||
|| cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(struct cmsgcred))
|
||||
|| cmsg.hdr.cmsg_level != SOL_SOCKET
|
||||
|| cmsg.hdr.cmsg_type != SCM_CREDS) {
|
||||
if (mhdr.msg_controllen != CMSG_SPACE(sizeof(struct cmsgcred)) ||
|
||||
cmsg.hdr.cmsg_len != CMSG_LEN(sizeof(struct cmsgcred)) ||
|
||||
cmsg.hdr.cmsg_level != SOL_SOCKET ||
|
||||
cmsg.hdr.cmsg_type != SCM_CREDS) {
|
||||
TRACE_OUT(on_query_startup);
|
||||
return (-1);
|
||||
}
|
||||
@ -206,9 +205,9 @@ on_query_startup(struct query_state *qstate)
|
||||
return (-1);
|
||||
#else
|
||||
if ((elem_type != CET_READ_REQUEST) &&
|
||||
(elem_type != CET_MP_READ_SESSION_REQUEST) &&
|
||||
(elem_type != CET_WRITE_REQUEST) &&
|
||||
(elem_type != CET_MP_WRITE_SESSION_REQUEST)) {
|
||||
(elem_type != CET_MP_READ_SESSION_REQUEST) &&
|
||||
(elem_type != CET_WRITE_REQUEST) &&
|
||||
(elem_type != CET_MP_WRITE_SESSION_REQUEST)) {
|
||||
TRACE_OUT(on_query_startup);
|
||||
return (-1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user