Patch from Renaud to report some broken Solaris porting from past.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1353 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Steven Dake 2007-03-06 16:18:44 +00:00
parent 1675a43aef
commit cb154572a2
16 changed files with 127 additions and 49 deletions

View File

@ -13,7 +13,7 @@ ifneq "" "$(findstring BSD,$(UNAME))"
endif
ifeq "$(UNAME)" "SunOS"
OPENAIS_COMPAT=SOLARIS
# CC must be set to gcc compiled to link with gnu-ld
# Note that CC must be set to gcc compiled to link with gnu-ld
endif
ifndef OPENAIS_COMPAT
$(error "OPENAIS_COMPAT cannot be detected, it must be manually defined")
@ -41,7 +41,7 @@ LDFLAGS =
DYFLAGS =
# Adding the TS_CLASS flag enables not being scheduled RR
#CFLAGS += -DTS_CLASS
CFLAGS += -DTS_CLASS
# build CFLAGS, LDFLAGS
#
@ -91,5 +91,11 @@ ifeq (${OPENAIS_COMPAT}, SOLARIS)
override CFLAGS += -DOPENAIS_SOLARIS -D_REENTRANT
override LDFLAGS += -lpthread
# See http://sources.redhat.com/ml/bug-gnu-utils/2000-07/msg00168.html
override LDFLAGS += -Wl,--export-dynamic
override LDFLAGS += -Wl,--export-dynamic -Wl,-rpath-link=/usr/lib
ifeq ($(shell uname -r), 5.10)
override CFLAGS += -DHAVE_GETPEERUCRED -DHAVE_SCANDIR -DHAVE_ALPHASORT
endif
ifeq ($(shell uname -r), 5.11)
override CFLAGS += -DHAVE_GETPEERUCRED -DHAVE_SCANDIR -DHAVE_ALPHASORT
endif
endif

View File

@ -672,7 +672,7 @@ static int mcast_sync_data (
req_exec.protocol_version = AMF_PROTOCOL_VERSION;
req_exec.object_type = object_type;
iov[0].iov_base = &req_exec;
iov[0].iov_base = (char *)&req_exec;
iov[0].iov_len = sizeof (struct req_exec_amf_sync_data);
iov[1].iov_base = buf;
iov[1].iov_len = len;

View File

@ -361,7 +361,7 @@ static void *clc_command_run (void *context)
waitpid (pid, &status, 0);
if (WIFEXITED (status) != 0 && WEXITSTATUS(status) != 0) {
fprintf (stderr, "Error: CLC_CLI (%d) failed with exit status:"
" %d - %s\n", pid, WEXITSTATUS(status),
" %d - %s\n", (int)pid, WEXITSTATUS(status),
strerror (WEXITSTATUS(status)));
/*
* Store the exit code from the script in the return data.
@ -370,7 +370,7 @@ static void *clc_command_run (void *context)
}
if (WIFSIGNALED (status) != 0) {
fprintf (stderr, "Error: CLC_CLI (%d) failed with exit status:"
" %d\n", pid, WTERMSIG(status));
" %d\n", (int)pid, WTERMSIG(status));
/*
* TODO: remove this and handle properly later...
*/
@ -381,7 +381,7 @@ static void *clc_command_run (void *context)
*/
}
xprintf ("process (%d) finished with %x\n", pid, status);
xprintf ("process (%d) finished with %x\n", (int)pid, status);
if (clc_command_run_data->completion_callback) {
clc_command_run_data->completion_callback (context);
}

View File

@ -1356,7 +1356,7 @@ int amf_msg_mcast (int msg_id, void *buf, size_t len)
msg.header.size = sizeof (msg);
msg.header.id = SERVICE_ID_MAKE (AMF_SERVICE, msg_id);
iov[0].iov_base = &msg;
iov[0].iov_base = (char *)&msg;
iov[0].iov_len = sizeof (msg);
if (buf == NULL) {

View File

@ -3473,7 +3473,7 @@ static int sync_checkpoint_section_transmit (
iovecs[0].iov_base = (char *)&req_exec_ckpt_sync_checkpoint_section;
iovecs[0].iov_len = sizeof (req_exec_ckpt_sync_checkpoint_section);
iovecs[1].iov_base = checkpoint_section->section_descriptor.section_id.id;
iovecs[1].iov_base = (char *)checkpoint_section->section_descriptor.section_id.id;
iovecs[1].iov_len = checkpoint_section->section_descriptor.section_id.id_len;
iovecs[2].iov_base = checkpoint_section->section_data;
iovecs[2].iov_len = checkpoint_section->section_descriptor.section_size;

View File

@ -32,6 +32,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPENAIS_BSD
#include <alloca.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@ -523,7 +526,7 @@ static int cpg_node_joinleave_send (struct group_info *gi, struct process_info *
req_exec_cpg_procjoin.header.size = sizeof(req_exec_cpg_procjoin);
req_exec_cpg_procjoin.header.id = SERVICE_ID_MAKE(CPG_SERVICE, fn);
req_exec_cpg_iovec.iov_base = &req_exec_cpg_procjoin;
req_exec_cpg_iovec.iov_base = (char *)&req_exec_cpg_procjoin;
req_exec_cpg_iovec.iov_len = sizeof(req_exec_cpg_procjoin);
result = totempg_groups_mcast_joined (openais_group_handle, &req_exec_cpg_iovec, 1, TOTEMPG_AGREED);
@ -635,7 +638,7 @@ static void cpg_confchg_fn (
/* Don't send this message until we get the final configuration message */
if (configuration_type == TOTEM_CONFIGURATION_REGULAR && req_exec_cpg_downlist.left_nodes) {
req_exec_cpg_iovec.iov_base = &req_exec_cpg_downlist;
req_exec_cpg_iovec.iov_base = (char *)&req_exec_cpg_downlist;
req_exec_cpg_iovec.iov_len = req_exec_cpg_downlist.header.size;
totempg_groups_mcast_joined (openais_group_handle, &req_exec_cpg_iovec, 1, TOTEMPG_AGREED);
@ -1099,9 +1102,9 @@ static void message_handler_req_lib_cpg_mcast (void *conn, void *message)
memcpy(&req_exec_cpg_mcast.group_name, &gi->group_name,
sizeof(mar_cpg_name_t));
req_exec_cpg_iovec[0].iov_base = &req_exec_cpg_mcast;
req_exec_cpg_iovec[0].iov_base = (char *)&req_exec_cpg_mcast;
req_exec_cpg_iovec[0].iov_len = sizeof(req_exec_cpg_mcast);
req_exec_cpg_iovec[1].iov_base = &req_lib_cpg_mcast->message;
req_exec_cpg_iovec[1].iov_base = (char *)&req_lib_cpg_mcast->message;
req_exec_cpg_iovec[1].iov_len = msglen;
// TODO: guarantee type...

View File

@ -54,6 +54,9 @@
#include <signal.h>
#include <sched.h>
#include <time.h>
#if defined(OPENAIS_SOLARIS) && defined(HAVE_GETPEERUCRED)
#include <ucred.h>
#endif
#include "../include/saAis.h"
#include "../include/list.h"
@ -79,6 +82,10 @@
#include "util.h"
#ifdef OPENAIS_SOLARIS
#define MSG_NOSIGNAL 0
#endif
#define SERVER_BACKLOG 5
/*
@ -565,15 +572,17 @@ retry_poll:
return (0);
}
#if defined(OPENAIS_LINUX)
#if defined(OPENAIS_LINUX) || defined(OPENAIS_SOLARIS)
/* SUN_LEN is broken for abstract namespace
*/
#define AIS_SUN_LEN(a) sizeof(*(a))
char *socketname = "libais.socket";
#else
#define AIS_SUN_LEN(a) SUN_LEN(a)
#endif
#if defined(OPENAIS_LINUX)
char *socketname = "libais.socket";
#else
char *socketname = "/var/run/libais.socket";
#endif
@ -653,9 +662,14 @@ static int conn_info_outq_flush (struct conn_info *conn_info) {
msg_send.msg_name = 0;
msg_send.msg_namelen = 0;
msg_send.msg_iovlen = 1;
#ifndef OPENAIS_SOLARIS
msg_send.msg_control = 0;
msg_send.msg_controllen = 0;
msg_send.msg_flags = 0;
#else
msg_send.msg_accrights = 0;
msg_send.msg_accrightslen = 0;
#endif
while (!queue_is_empty (outq)) {
queue_item = queue_item_get (outq);
@ -721,9 +735,6 @@ static void libais_deliver (struct conn_info *conn_info)
char cmsg_cred[CMSG_SPACE (sizeof (struct ucred))];
struct ucred *cred;
int on = 0;
#else
uid_t euid;
gid_t egid;
#endif
int send_ok = 0;
int send_ok_joined = 0;
@ -734,6 +745,7 @@ static void libais_deliver (struct conn_info *conn_info)
msg_recv.msg_iovlen = 1;
msg_recv.msg_name = 0;
msg_recv.msg_namelen = 0;
#ifndef OPENAIS_SOLARIS
msg_recv.msg_flags = 0;
if (conn_info->authenticated) {
@ -741,13 +753,14 @@ static void libais_deliver (struct conn_info *conn_info)
msg_recv.msg_controllen = 0;
} else {
#ifdef OPENAIS_LINUX
uid_t euid = -1;
gid_t egid = -1;
msg_recv.msg_control = (void *)cmsg_cred;
msg_recv.msg_controllen = sizeof (cmsg_cred);
#else
euid = -1; egid = -1;
if (getpeereid(conn_info->fd, &euid, &egid) != -1 &&
(euid == 0 || egid == g_gid_valid)) {
conn_info->authenticated = 1;
conn_info->authenticated = 1;
}
if (conn_info->authenticated == 0) {
log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because gid is %d, expecting %d\n", egid, g_gid_valid);
@ -755,6 +768,36 @@ static void libais_deliver (struct conn_info *conn_info)
#endif
}
#else /* OPENAIS_SOLARIS */
msg_recv.msg_accrights = 0;
msg_recv.msg_accrightslen = 0;
if (! conn_info->authenticated) {
#ifdef HAVE_GETPEERUCRED
ucred_t *uc;
uid_t euid = -1;
gid_t egid = -1;
if (getpeerucred(conn_info->fd, &uc) == 0) {
euid = ucred_geteuid(uc);
egid = ucred_getegid(uc);
if ((euid == 0) || (egid == g_gid_valid)) {
conn_info->authenticated = 1;
}
ucred_free(uc);
}
if (conn_info->authenticated == 0) {
log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because gid is %d, expecting %d\n", (int)egid, g_gid_valid);
}
#else
log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated "
"because platform does not support "
"authentication with sockets, continuing "
"with a fake authentication\n");
conn_info->authenticated = 1;
#endif
}
#endif
iov_recv.iov_base = &conn_info->inb[conn_info->inb_start];
iov_recv.iov_len = (SIZEINB) - conn_info->inb_start;
if (conn_info->inb_inuse == SIZEINB) {
@ -835,7 +878,7 @@ retry_recv:
* to queue a message, otherwise tell the library we are busy and to
* try again later
*/
send_ok_joined_iovec.iov_base = header;
send_ok_joined_iovec.iov_base = (char *)header;
send_ok_joined_iovec.iov_len = header->size;
send_ok_joined = totempg_groups_send_ok_joined (openais_group_handle,
&send_ok_joined_iovec, 1);
@ -1107,9 +1150,14 @@ int openais_conn_send_response (
msg_send.msg_name = 0;
msg_send.msg_namelen = 0;
msg_send.msg_iovlen = 1;
#ifndef OPENAIS_SOLARIS
msg_send.msg_control = 0;
msg_send.msg_controllen = 0;
msg_send.msg_flags = 0;
#else
msg_send.msg_accrights = 0;
msg_send.msg_accrightslen = 0;
#endif
if (queue_is_full (outq)) {
/*

View File

@ -391,9 +391,9 @@ static void sync_deliver_fn (
{
int i;
int barrier_completed;
sync_msg_t *msg = iovec[0].iov_base;
sync_msg_t *msg = (sync_msg_t *)iovec[0].iov_base;
ENTER("type %d, len %d", msg->header.id, iovec[0].iov_len);
ENTER("type %d, len %d", msg->header.id, (int)iovec[0].iov_len);
if (endian_conversion_required) {
swab_mar_req_header_t (&msg->header);

View File

@ -186,6 +186,7 @@ int totemip_compare(const void *a, const void *b)
* Family not set, should be!
*/
assert (0);
exit (1);
}
}

View File

@ -1106,6 +1106,7 @@ static int totemnet_build_sockets_ip (
}
}
#ifndef OPENAIS_SOLARIS
/*
* Bind to a specific interface for multicast send and receive
*/
@ -1135,6 +1136,7 @@ static int totemnet_build_sockets_ip (
}
break;
}
#endif
return 0;
}

View File

@ -38,6 +38,10 @@
#include <pthread.h>
#include "assert.h"
#ifdef OPENAIS_SOLARIS
/* struct queue is already defined in sys/stream.h on Solaris */
#define queue _queue
#endif
struct queue {
int head;
int tail;

View File

@ -264,7 +264,7 @@ static int ldso_path_build (char *path, char *filename)
return (0);
}
#ifdef OPENAIS_SOLARIS
#ifndef HAVE_SCANDIR
static int scandir (
const char *dir, struct dirent ***namelist,
int (*filter)(const struct dirent *),
@ -331,7 +331,9 @@ fail:
return -1;
}
}
#endif
#ifndef HAVE_ALPHASORT
static int alphasort (const struct dirent **a, const struct dirent **b)
{
return strcmp ((*a)->d_name, (*b)->d_name);

View File

@ -412,7 +412,7 @@ cpg_error_t cpg_join (
marshall_to_mar_cpg_name_t (&req_lib_cpg_trackstart.group_name,
group);
iov[0].iov_base = &req_lib_cpg_trackstart;
iov[0].iov_base = (char *)&req_lib_cpg_trackstart;
iov[0].iov_len = sizeof (struct req_lib_cpg_trackstart);
error = saSendMsgReceiveReply (cpg_inst->dispatch_fd, iov, 1,
@ -430,7 +430,7 @@ cpg_error_t cpg_join (
marshall_to_mar_cpg_name_t (&req_lib_cpg_join.group_name,
group);
iov[0].iov_base = &req_lib_cpg_join;
iov[0].iov_base = (char *)&req_lib_cpg_join;
iov[0].iov_len = sizeof (struct req_lib_cpg_join);
error = saSendMsgReceiveReply (cpg_inst->response_fd, iov, 1,
@ -471,7 +471,7 @@ cpg_error_t cpg_leave (
marshall_to_mar_cpg_name_t (&req_lib_cpg_leave.group_name,
group);
iov[0].iov_base = &req_lib_cpg_leave;
iov[0].iov_base = (char *)&req_lib_cpg_leave;
iov[0].iov_len = sizeof (struct req_lib_cpg_leave);
pthread_mutex_lock (&cpg_inst->response_mutex);
@ -522,7 +522,7 @@ cpg_error_t cpg_mcast_joined (
req_lib_cpg_mcast.guarantee = guarantee;
req_lib_cpg_mcast.msglen = msg_len;
iov[0].iov_base = &req_lib_cpg_mcast;
iov[0].iov_base = (char *)&req_lib_cpg_mcast;
iov[0].iov_len = sizeof (struct req_lib_cpg_mcast);
memcpy (&iov[1], iovec, iov_len * sizeof (struct iovec));
@ -572,7 +572,7 @@ cpg_error_t cpg_membership_get (
marshall_to_mar_cpg_name_t (&req_lib_cpg_membership_get.group_name,
group_name);
iov.iov_base = &req_lib_cpg_membership_get;
iov.iov_base = (char *)&req_lib_cpg_membership_get;
iov.iov_len = sizeof (mar_req_header_t);
pthread_mutex_lock (&cpg_inst->response_mutex);

View File

@ -34,7 +34,7 @@
instantiate() {
# echo clc_cli_script instantiating component $SA_AMF_COMPONENT_NAME $1
./openais-instantiate $1
openais-instantiate $1
exit $?
}

View File

@ -53,6 +53,18 @@
#include "saAis.h"
#include "cpg.h"
#ifdef OPENAIS_SOLARIS
#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)
#endif
int alarm_notice;
void cpg_bm_confchg_fn (

View File

@ -83,7 +83,7 @@ static void _die (char *file, int line, char *format, ...)
va_list ap;
sprintf (buf, "%d - %s:#%d - Error: '%s', exiting...\n",
getpid(), file, line, format);
(int)getpid(), file, line, format);
va_start (ap, format);
vfprintf (stderr, buf, ap);
@ -100,7 +100,7 @@ static void response (
do {
result = saAmfResponse (handle, invocation, error);
if (result == SA_AIS_ERR_TRY_AGAIN) {
fprintf(stderr, "%d: TRY_AGAIN received\n", getpid());
fprintf(stderr, "%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -397,7 +397,7 @@ static SaSelectionObjectT comp_init ()
do {
result = saAmfInitialize (&handle, &amfCallbacks, &version);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -408,7 +408,7 @@ static SaSelectionObjectT comp_init ()
do {
result = saAmfSelectionObjectGet (handle, &select_fd);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -419,7 +419,7 @@ static SaSelectionObjectT comp_init ()
do {
result = saAmfComponentNameGet (handle, &compNameGlobal);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -435,7 +435,7 @@ static SaSelectionObjectT comp_init ()
SA_AMF_HEALTHCHECK_AMF_INVOKED,
SA_AMF_COMPONENT_FAILOVER);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -450,7 +450,7 @@ static SaSelectionObjectT comp_init ()
SA_AMF_HEALTHCHECK_COMPONENT_INVOKED,
SA_AMF_COMPONENT_FAILOVER);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -465,7 +465,7 @@ static SaSelectionObjectT comp_init ()
do {
result = saAmfComponentRegister (handle, &badname, NULL);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -477,7 +477,7 @@ static SaSelectionObjectT comp_init ()
do {
result = saAmfComponentRegister (handle, &compNameGlobal, NULL);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -495,7 +495,7 @@ static SaSelectionObjectT comp_init ()
SA_AMF_HEALTHCHECK_AMF_INVOKED,
SA_AMF_COMPONENT_FAILOVER);
if (result == SA_AIS_ERR_TRY_AGAIN) {
printf("%d: TRY_AGAIN received\n", getpid());
printf("%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -517,31 +517,31 @@ static void handle_intr (void)
die ("saAmfFinalize failed %d", result);
}
fprintf(stderr, "%d: %s exiting\n",
getpid(), compNameGlobal.value);
(int)getpid(), compNameGlobal.value);
exit (EXIT_SUCCESS);
break;
case UNREGISTER:
fprintf(stderr, "%d: %s unregistering\n",
getpid(), compNameGlobal.value);
(int)getpid(), compNameGlobal.value);
result = saAmfComponentUnregister (
handle, &compNameGlobal, NULL);
if (result != SA_AIS_OK) {
die ("saAmfComponentUnregister failed %d", result);
}
fprintf(stderr, "%d: waiting after unregister\n", getpid());
fprintf(stderr, "%d: waiting after unregister\n", (int)getpid());
while (1) {
sleep (100000000);
}
break;
case ERROR_REPORT:
fprintf(stderr, "%d: %s error reporting\n",
getpid(), compNameGlobal.value);
(int)getpid(), compNameGlobal.value);
result = saAmfComponentErrorReport (
handle, &compNameGlobal, 0, SA_AMF_COMPONENT_RESTART, 0);
if (result != SA_AIS_OK) {
die ("saAmfComponentErrorReport failed %d", result);
}
fprintf(stderr, "%d: waiting after error report\n", getpid());
fprintf(stderr, "%d: waiting after error report\n", (int)getpid());
while (1) {
sleep (100000000);
}
@ -577,7 +577,7 @@ int main (int argc, char **argv)
do {
result = saAmfDispatch (handle, SA_DISPATCH_ALL);
if (result == SA_AIS_ERR_TRY_AGAIN) {
fprintf(stderr, "%d: TRY_AGAIN received\n", getpid());
fprintf(stderr, "%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -591,7 +591,7 @@ int main (int argc, char **argv)
result = saAmfHealthcheckConfirm (handle, &compNameGlobal,
&keyCompInvoked, SA_AIS_OK);
if (result == SA_AIS_ERR_TRY_AGAIN) {
fprintf(stderr, "%d: TRY_AGAIN received\n", getpid());
fprintf(stderr, "%d: TRY_AGAIN received\n", (int)getpid());
usleep (100000);
}
} while (result == SA_AIS_ERR_TRY_AGAIN);
@ -602,7 +602,7 @@ int main (int argc, char **argv)
}
} while (stop == 0);
fprintf(stderr, "%d: exiting...\n", getpid());
fprintf(stderr, "%d: exiting...\n", (int)getpid());
exit (EXIT_SUCCESS);
}