Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/ipc_sysv_mq.c | 18 +++++++++++-------
tests/bms.c | 4 ++++
tests/check_ipc.c | 10 +++++-----
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/lib/ipc_sysv_mq.c b/lib/ipc_sysv_mq.c
index 2eb8189..6b2b716 100644
--- a/lib/ipc_sysv_mq.c
+++ b/lib/ipc_sysv_mq.c
@@ -48,7 +48,8 @@ static int32_t sysv_mq_create(struct qb_ipcs_service *s)
struct msqid_ds info;
int32_t res = 0;
- s->u.smq.q = msgget(s->u.smq.key, IPC_CREAT | O_EXCL | IPC_NOWAIT);
+ s->u.smq.q = msgget(s->u.smq.key, IPC_CREAT | O_EXCL | IPC_NOWAIT |
+ S_IWUSR | S_IRUSR | S_IWGRP);
if (s->u.smq.q == -1) {
res = -errno;
perror("msgget:REQUEST");
@@ -58,16 +59,20 @@ static int32_t sysv_mq_create(struct qb_ipcs_service *s)
res = msgctl(s->u.smq.q, IPC_STAT, &info);
if (res != 0) {
res = -errno;
- perror("msgctl");
+ perror("msgctl:STAT");
qb_util_log(LOG_ERR, "error getting mq info");
return res;
}
- info.msg_qbytes = 10 * s->max_msg_size;
+ if (info.msg_perm.uid != 0) {
+ qb_util_log(LOG_WARNING, "not enough privileges to increase msg_qbytes");
+ return res;
+ }
+ info.msg_qbytes = 2 * s->max_msg_size;
res = msgctl(s->u.smq.q, IPC_SET, &info);
if (res != 0) {
res = -errno;
- perror("msgctl");
+ perror("msgctl:SET");
qb_util_log(LOG_ERR, "error changing msg_qbytes to %zu",
10 * s->max_msg_size);
}
@@ -78,7 +83,8 @@ static int32_t sysv_mq_unnamed_create(struct qb_ipcc_smq_one_way
*queue)
{
retry_creating_the_q:
queue->key = random();
- queue->q = msgget(queue->key, IPC_CREAT | IPC_EXCL | IPC_NOWAIT);
+ queue->q = msgget(queue->key, IPC_CREAT | IPC_EXCL | IPC_NOWAIT |
+ S_IWUSR | S_IRUSR | S_IRGRP);
if (queue->q == -1 && errno == EEXIST) {
goto retry_creating_the_q;
} else if (queue->q == -1) {
@@ -477,7 +483,5 @@ int32_t qb_ipcs_smq_create(struct qb_ipcs_service * s)
s->funcs.request_recv = qb_ipcs_smq_request_recv;
s->needs_sock_for_poll = QB_TRUE;
- //s->max_msg_size = MSGMAX;
-
return sysv_mq_create(s);
}
diff --git a/tests/bms.c b/tests/bms.c
index 550d003..8486526 100644
--- a/tests/bms.c
+++ b/tests/bms.c
@@ -54,6 +54,7 @@ static qb_ipcs_service_pt s1;
static int32_t s1_connection_authenticate_fn(qb_ipcs_connection_handle_t conn, uid_t uid,
gid_t gid)
{
+#if 0
if (uid == 0 && gid == 0) {
if (verbose) {
printf("%s:%d %s authenticated connection\n",
@@ -63,6 +64,9 @@ static int32_t s1_connection_authenticate_fn(qb_ipcs_connection_handle_t
conn, u
}
printf("%s:%d %s() BAD user!\n", __FILE__, __LINE__, __func__);
return 0;
+#else
+ return 1;
+#endif
}
diff --git a/tests/check_ipc.c b/tests/check_ipc.c
index 8dbc85d..59ffa21 100644
--- a/tests/check_ipc.c
+++ b/tests/check_ipc.c
@@ -38,7 +38,6 @@
#define MAX_MSG_SIZE (8192*16)
static qb_ipcc_connection_t *conn;
static enum qb_ipc_type ipc_type;
-static qb_handle_t poll_handle;
#define IPC_MSG_REQ_TX_RX (QB_IPC_MSG_USER_START + 3)
#define IPC_MSG_RES_TX_RX (QB_IPC_MSG_USER_START + 13)
@@ -296,7 +295,7 @@ repeat_send:
}
}
- res = qb_ipcc_event_recv(conn, &res_header, 0);
+ res = qb_ipcc_event_recv(conn, (void**)&res_header, 0);
ck_assert_int_eq(res, sizeof(struct qb_ipc_response_header));
ck_assert_int_eq(res_header->id, IPC_MSG_RES_DISPATCH);
qb_ipcc_event_release(conn);
@@ -327,9 +326,10 @@ static Suite *ipc_suite(void)
tcase_set_timeout(tc, 10);
suite_add_tcase(s, tc);
-// tc = tcase_create("ipc_txrx_sysv_mq");
-// tcase_add_test(tc, test_ipc_txrx_smq);
-// suite_add_tcase(s, tc);
+ tc = tcase_create("ipc_txrx_sysv_mq");
+ tcase_add_test(tc, test_ipc_txrx_smq);
+ tcase_set_timeout(tc, 10);
+ suite_add_tcase(s, tc);
tc = tcase_create("ipc_dispatch_shm");
tcase_add_test(tc, test_ipc_disp_shm);
--
1.7.2.3