mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
Added more debugging information.
This commit is contained in:
@@ -216,8 +216,11 @@ int send_auth_reply(main_server_st* s, struct proc_st* proc,
|
||||
}
|
||||
|
||||
ret = sendmsg(proc->fd, &hdr, 0);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
int e = errno;
|
||||
mslog(s, proc, LOG_ERR, "sendmsg: %s", strerror(e));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (r == REP_AUTH_OK) {
|
||||
ret = serialize_additional_data(s, proc);
|
||||
@@ -260,7 +263,12 @@ int send_auth_reply_msg(main_server_st* s, struct proc_st* proc)
|
||||
iov[1].iov_len = sizeof(resp);
|
||||
hdr.msg_iovlen++;
|
||||
|
||||
return(sendmsg(proc->fd, &hdr, 0));
|
||||
ret = sendmsg(proc->fd, &hdr, 0);
|
||||
if (ret < 0) {
|
||||
int e = errno;
|
||||
mslog(s, proc, LOG_ERR, "sendmsg: %s", strerror(e));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int check_user_group_status(main_server_st *s, struct proc_st* proc,
|
||||
|
||||
@@ -92,7 +92,7 @@ int send_udp_fd(main_server_st* s, struct proc_st * proc, int fd)
|
||||
char control[CMSG_SPACE(sizeof(int))];
|
||||
} control_un;
|
||||
struct cmsghdr *cmptr;
|
||||
|
||||
int ret;
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
iov[0].iov_base = &cmd;
|
||||
@@ -110,7 +110,12 @@ int send_udp_fd(main_server_st* s, struct proc_st * proc, int fd)
|
||||
cmptr->cmsg_type = SCM_RIGHTS;
|
||||
memcpy(CMSG_DATA(cmptr), &fd, sizeof(int));
|
||||
|
||||
return(sendmsg(proc->fd, &hdr, 0));
|
||||
ret = sendmsg(proc->fd, &hdr, 0);
|
||||
if (ret < 0) {
|
||||
int e = errno;
|
||||
mslog(s, proc, LOG_ERR, "sendmsg: %s", strerror(e));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int handle_script_exit(main_server_st *s, struct proc_st* proc, int code)
|
||||
@@ -120,7 +125,7 @@ int ret;
|
||||
if (code == 0) {
|
||||
ret = send_auth_reply(s, proc, REP_AUTH_OK);
|
||||
if (ret < 0) {
|
||||
mslog(s, proc, LOG_ERR, "could not send reply auth cmd.");
|
||||
mslog(s, proc, LOG_ERR, "could not send auth reply cmd.");
|
||||
ret = ERR_BAD_COMMAND;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ static int send_auth_req(int fd, const struct cmd_auth_req_st* r)
|
||||
struct iovec iov[2];
|
||||
uint8_t cmd;
|
||||
struct msghdr hdr;
|
||||
int ret;
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
|
||||
@@ -188,7 +189,12 @@ static int send_auth_req(int fd, const struct cmd_auth_req_st* r)
|
||||
hdr.msg_iov = iov;
|
||||
hdr.msg_iovlen = 2;
|
||||
|
||||
return(sendmsg(fd, &hdr, 0));
|
||||
ret = sendmsg(fd, &hdr, 0);
|
||||
if (ret < 0) {
|
||||
int e = errno;
|
||||
syslog(LOG_ERR, "send_auth_req: sendmsg: %s", strerror(e));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int send_auth_init(int fd, const struct cmd_auth_init_st* r)
|
||||
@@ -196,6 +202,7 @@ static int send_auth_init(int fd, const struct cmd_auth_init_st* r)
|
||||
struct iovec iov[2];
|
||||
uint8_t cmd;
|
||||
struct msghdr hdr;
|
||||
int ret;
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
|
||||
@@ -210,7 +217,12 @@ static int send_auth_init(int fd, const struct cmd_auth_init_st* r)
|
||||
hdr.msg_iov = iov;
|
||||
hdr.msg_iovlen = 2;
|
||||
|
||||
return(sendmsg(fd, &hdr, 0));
|
||||
ret = sendmsg(fd, &hdr, 0);
|
||||
if (ret < 0) {
|
||||
int e = errno;
|
||||
syslog(LOG_ERR, "send_auth_req: sendmsg: %s", strerror(e));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int send_auth_cookie_req(int fd, const struct cmd_auth_cookie_req_st* r)
|
||||
@@ -218,6 +230,7 @@ static int send_auth_cookie_req(int fd, const struct cmd_auth_cookie_req_st* r)
|
||||
struct iovec iov[2];
|
||||
uint8_t cmd;
|
||||
struct msghdr hdr;
|
||||
int ret;
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
|
||||
@@ -232,7 +245,12 @@ static int send_auth_cookie_req(int fd, const struct cmd_auth_cookie_req_st* r)
|
||||
hdr.msg_iov = iov;
|
||||
hdr.msg_iovlen = 2;
|
||||
|
||||
return(sendmsg(fd, &hdr, 0));
|
||||
ret = sendmsg(fd, &hdr, 0);
|
||||
if (ret < 0) {
|
||||
int e = errno;
|
||||
syslog(LOG_ERR, "send_auth_req: sendmsg: %s", strerror(e));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int read_str_value_length(worker_st *ws, char** res)
|
||||
@@ -360,7 +378,7 @@ static int recv_auth_reply(worker_st *ws, struct cmd_auth_reply_st *resp)
|
||||
|
||||
if (cmdlen < 2) {
|
||||
int e = errno;
|
||||
oclog(ws, LOG_ERR, "Received incorrect data (%d, expected %d) from main: %s", cmdlen, (int)2, strerror(e));
|
||||
oclog(ws, LOG_ERR, "auth_reply: incorrect data (%d, expected %d) from main: %s", cmdlen, (int)2, strerror(e));
|
||||
return ERR_AUTH_FAIL;
|
||||
}
|
||||
if (cmd != AUTH_REP)
|
||||
@@ -373,7 +391,7 @@ static int recv_auth_reply(worker_st *ws, struct cmd_auth_reply_st *resp)
|
||||
return ERR_AUTH_CONTINUE;
|
||||
case REP_AUTH_OK:
|
||||
if (cmdlen < sizeof(*resp)) {
|
||||
oclog(ws, LOG_ERR, "Received incorrect data (%d, expected %d) from main", ret, (int)sizeof(*resp)+1);
|
||||
oclog(ws, LOG_ERR, "auth_reply: incorrect data (%d, expected %d) from main", ret, (int)sizeof(*resp)+1);
|
||||
return ERR_AUTH_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,12 +108,12 @@ static int recv_resume_fetch_reply(worker_st *ws, struct cmd_resume_fetch_reply_
|
||||
ret = recvmsg( ws->cmd_fd, &hdr, 0);
|
||||
if (ret <= sizeof(*resp)-MAX_SESSION_DATA_SIZE) {
|
||||
int e = errno;
|
||||
oclog(ws, LOG_ERR, "received incorrect data (%d, expected %d) from main: %s", ret, (int)sizeof(*resp)+1, strerror(e));
|
||||
oclog(ws, LOG_ERR, "resume_fetch_reply: incorrect data (%d, expected %d) from main: %s", ret, (int)sizeof(*resp)+1, strerror(e));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cmd != RESUME_FETCH_REP) {
|
||||
oclog(ws, LOG_ERR, "received unexpected response (%d, expected %d) from main", (int)cmd, (int)RESUME_FETCH_REP);
|
||||
oclog(ws, LOG_ERR, "resume_fetch_reply: unexpected response (%d, expected %d) from main", (int)cmd, (int)RESUME_FETCH_REP);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user