Initial stab at porting to Solaris.

It compiles without warning (with CC=gcc) but doesn't link
because NaCL doesn't build yet.
This commit is contained in:
Paul Gardner-Stephen 2012-09-05 18:53:22 +09:30
parent ed7edd3865
commit bba6839656
26 changed files with 147 additions and 43 deletions

View File

@ -1,7 +1,5 @@
SRCS= \ SRCS= \
audiodevices.c \ audiodevices.c \
audio_alsa.c \
audio_msm_g1.c \
audio_reflector.c \ audio_reflector.c \
batman.c \ batman.c \
ciphers.c \ ciphers.c \
@ -61,6 +59,12 @@ SRCS= \
vomp.c \ vomp.c \
xprintf.c xprintf.c
# Only build these on Linux
ifeq (0, 1)
SRCS+= audio_alsa.c \
audio_msm_g1.c
endif
MONITORCLIENTSRCS=conf.c \ MONITORCLIENTSRCS=conf.c \
log.c \ log.c \
mkdir.c \ mkdir.c \
@ -95,11 +99,14 @@ HDRS= fifo.h \
monitor-client.h \ monitor-client.h \
sqlite-amalgamation-3070900/sqlite3.h sqlite-amalgamation-3070900/sqlite3.h
LDFLAGS=@LDFLAGS@ @PORTAUDIO_LIBS@ @SRC_LIBS@ @SPANDSP_LIBS@ @CODEC2_LIBS@ @PTHREAD_LIBS@ LDFLAGS=@LDFLAGS@ @LIBS@ @PORTAUDIO_LIBS@ @SRC_LIBS@ @SPANDSP_LIBS@ @CODEC2_LIBS@ @PTHREAD_LIBS@
CFLAGS= -Isqlite-amalgamation-3070900 @CPPFLAGS@ @CFLAGS@ @PORTAUDIO_CFLAGS@ @SRC_CFLAGS@ @SPANDSP_CFLAGS@ @PTHREAD_CFLAGS@ $(VOIPTEST_CFLAGS) CFLAGS= -Isqlite-amalgamation-3070900 @CPPFLAGS@ @CFLAGS@ @PORTAUDIO_CFLAGS@ @SRC_CFLAGS@ @SPANDSP_CFLAGS@ @PTHREAD_CFLAGS@ $(VOIPTEST_CFLAGS)
CFLAGS+=-fPIC CFLAGS+=-fPIC
CFLAGS+=-Wall -Wno-unused-value CFLAGS+=-Wall -Wno-unused-value
# Solaris magic
CFLAGS+=-DSHA2_USE_INTTYPES_H -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1
-include Makefile.dbg -include Makefile.dbg
DEFS= @DEFS@ DEFS= @DEFS@

View File

@ -30,8 +30,12 @@ int recordBufferSize=0;
int detectAudioDevice() int detectAudioDevice()
{ {
#ifdef ANDROID
if (!audev) audev=audio_msm_g1_detect(); if (!audev) audev=audio_msm_g1_detect();
#endif
#ifdef linux
if (!audev) audev=audio_alsa_detect(); if (!audev) audev=audio_alsa_detect();
#endif
if (audev) { if (audev) {
WHYF("Detected audio device '%s'",audev->name); WHYF("Detected audio device '%s'",audev->name);
return 0; return 0;

View File

@ -17,6 +17,11 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <sys/types.h>
#include <netinet/in.h>
#include <inttypes.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <time.h> #include <time.h>
#include "serval.h" #include "serval.h"
@ -206,9 +211,9 @@ int getBatmanPeerList(char *socket_path,struct in_addr peers[],int *peer_count,i
askagain: askagain:
/* Make socket */ /* Make socket */
sock=socket(AF_LOCAL,SOCK_STREAM,0); sock=socket(PF_UNIX,SOCK_STREAM,0);
memset(&socket_address,0,sizeof(struct sockaddr_un)); memset(&socket_address,0,sizeof(struct sockaddr_un));
socket_address.sun_family=AF_LOCAL; socket_address.sun_family=PF_UNIX;
if (strlen(socket_path)>256) return WHY("BATMAN socket path too long"); if (strlen(socket_path)>256) return WHY("BATMAN socket path too long");
strcpy(socket_address.sun_path,socket_path); strcpy(socket_address.sun_path,socket_path);

View File

@ -17,6 +17,10 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "serval.h" #include "serval.h"
int sock = -1; int sock = -1;

View File

@ -662,7 +662,9 @@ int app_server_start(int argc, const char *const *argv, struct command_line_opti
creates a new server daemon process with the correct argv[0]. Otherwise, the servald creates a new server daemon process with the correct argv[0]. Otherwise, the servald
process appears as a process with argv[0] = "org.servalproject". */ process appears as a process with argv[0] = "org.servalproject". */
if (execpath) { if (execpath) {
execl(execpath, execpath, "start", "foreground", NULL); /* XXX: Need the cast on Solaris because it defins NULL as 0L and gcc doesn't
* see it as a sentinal */
execl(execpath, execpath, "start", "foreground", (void *)NULL);
_exit(-1); _exit(-1);
} }
_exit(server(NULL)); _exit(server(NULL));
@ -672,10 +674,7 @@ int app_server_start(int argc, const char *const *argv, struct command_line_opti
/* Main process. Allow a few seconds for the child process to report for duty. */ /* Main process. Allow a few seconds for the child process to report for duty. */
time_ms_t timeout = gettime_ms() + 5000; time_ms_t timeout = gettime_ms() + 5000;
do { do {
struct timespec delay; sleep_ms(200); // 5 Hz
delay.tv_sec = 0;
delay.tv_nsec = 200000000; // 200 ms = 5 Hz
nanosleep(&delay, NULL);
} while ((pid = server_pid()) == 0 && gettime_ms() < timeout); } while ((pid = server_pid()) == 0 && gettime_ms() < timeout);
if (pid == -1) if (pid == -1)
return -1; return -1;

2
config.guess vendored
View File

@ -1 +1 @@
/usr/share/libtool/config/config.guess /opt/csw/share/libtool/config/config.guess

2
config.sub vendored
View File

@ -1 +1 @@
/usr/share/libtool/config/config.sub /opt/csw/share/libtool/config/config.sub

View File

@ -59,8 +59,15 @@ if test -n "$JAVAC"; then
popdef([AC_MSG_ERROR]) popdef([AC_MSG_ERROR])
fi fi
dnl XXX Isn't this pointless? we are always linked against libc
AC_CHECK_LIB(c,srandomdev) AC_CHECK_LIB(c,srandomdev)
dnl Solaris hides nanosleep here
AC_CHECK_LIB(rt,nanosleep)
dnl BSD way of getting socket creds
AC_CHECK_FUNC(getpeereid)
AC_CHECK_HEADERS( AC_CHECK_HEADERS(
stdio.h \ stdio.h \
errno.h \ errno.h \
@ -86,6 +93,10 @@ AC_CHECK_HEADERS(
signal.h \ signal.h \
jni.h \ jni.h \
alsa/asoundlib.h \ alsa/asoundlib.h \
ucred.h \
sys/filio.h \
sys/endian.h \
sys/byteorder.h \
) )
echo "Fetching and building NaCl if required." echo "Fetching and building NaCl if required."

View File

@ -179,7 +179,9 @@ dna_helper_start(const char *command, const char *arg, const char *mysid)
fflush(stderr); fflush(stderr);
_exit(-1); _exit(-1);
} }
execl(command, command, arg, NULL); /* XXX: Need the cast on Solaris because it defins NULL as 0L and gcc doesn't
* see it as a sentinal */
execl(command, command, arg, (void *)NULL);
LOGF_perror(LOG_LEVEL_FATAL, "execl(%s, %s, %s, NULL)", command, command, arg ? arg : "NULL"); LOGF_perror(LOG_LEVEL_FATAL, "execl(%s, %s, %s, NULL)", command, command, arg ? arg : "NULL");
fflush(stderr); fflush(stderr);
do { _exit(-1); } while (1); do { _exit(-1); } while (1);

View File

@ -74,7 +74,9 @@ static int safeSystem(char *cmd_file)
if(pid == -1) if(pid == -1)
return WHY_perror("fork"); return WHY_perror("fork");
if (pid == 0) { if (pid == 0) {
execlp(shell, shell, "-c", cmd_file,NULL); /* XXX: Need the cast on Solaris because it defins NULL as 0L and gcc doesn't
* see it as a sentinal */
execlp(shell, shell, "-c", cmd_file,(void*)NULL);
_exit(1); _exit(1);
} }
// Wait for child to finish // Wait for child to finish

View File

@ -1 +1 @@
/usr/share/libtool/config/install-sh /opt/csw/share/libtool/config/install-sh

View File

@ -1125,7 +1125,7 @@ unsigned char *keyring_find_sas_private(keyring_file *k,unsigned char *sid,
int cn=0,in=0,kp=0; int cn=0,in=0,kp=0;
if (!keyring_find_sid(k,&cn,&in,&kp,sid)) { if (!keyring_find_sid(k,&cn,&in,&kp,sid)) {
RETURN(WHYNULL("Could not find SID in keyring, so can't find SAS")); RETURNNULL(WHYNULL("Could not find SID in keyring, so can't find SAS"));
} }
for(kp=0;kp<k->contexts[cn]->identities[in]->keypair_count;kp++) for(kp=0;kp<k->contexts[cn]->identities[in]->keypair_count;kp++)
@ -1139,7 +1139,7 @@ unsigned char *keyring_find_sas_private(keyring_file *k,unsigned char *sid,
RETURN(k->contexts[cn]->identities[in]->keypairs[kp]->private_key); RETURN(k->contexts[cn]->identities[in]->keypairs[kp]->private_key);
} }
RETURN(WHYNULL("Identity lacks SAS")); RETURNNULL(WHYNULL("Identity lacks SAS"));
} }
struct sid_sas_mapping { struct sid_sas_mapping {
@ -1329,11 +1329,11 @@ unsigned char *keyring_find_sas_public(keyring_file *k,unsigned char *sid)
==KEYTYPE_CRYPTOBOX) ==KEYTYPE_CRYPTOBOX)
bcopy(keyring->contexts[0]->identities[0]->keypairs[0]->public_key, bcopy(keyring->contexts[0]->identities[0]->keypairs[0]->public_key,
mdp.out.src.sid,SID_SIZE); mdp.out.src.sid,SID_SIZE);
else { RETURN(WHYNULL("couldn't request SAS (I don't know who I am)")); } else { RETURNNULL(WHYNULL("couldn't request SAS (I don't know who I am)")); }
mdp.out.payload_length=1; mdp.out.payload_length=1;
mdp.out.payload[0]=KEYTYPE_CRYPTOSIGN; mdp.out.payload[0]=KEYTYPE_CRYPTOSIGN;
if (overlay_mdp_dispatch(&mdp, 0 /* system generated */, NULL, 0)) if (overlay_mdp_dispatch(&mdp, 0 /* system generated */, NULL, 0))
RETURN(WHYNULL("Failed to send SAS resolution request")); RETURNNULL(WHYNULL("Failed to send SAS resolution request"));
if (debug & DEBUG_KEYRING) if (debug & DEBUG_KEYRING)
DEBUGF("Dispatched SAS resolution request"); DEBUGF("Dispatched SAS resolution request");
RETURN(NULL); RETURN(NULL);
@ -1458,9 +1458,9 @@ struct nm_record nm_cache[NM_CACHE_SLOTS];
unsigned char *keyring_get_nm_bytes(sockaddr_mdp *known,sockaddr_mdp *unknown) unsigned char *keyring_get_nm_bytes(sockaddr_mdp *known,sockaddr_mdp *unknown)
{ {
IN(); IN();
if (!known) { RETURN(WHYNULL("known pub key is null")); } if (!known) { RETURNNULL(WHYNULL("known pub key is null")); }
if (!unknown) { RETURN(WHYNULL("unknown pub key is null")); } if (!unknown) { RETURNNULL(WHYNULL("unknown pub key is null")); }
if (!keyring) { RETURN(WHYNULL("keyring is null")); } if (!keyring) { RETURNNULL(WHYNULL("keyring is null")); }
int i; int i;
@ -1478,7 +1478,7 @@ unsigned char *keyring_get_nm_bytes(sockaddr_mdp *known,sockaddr_mdp *unknown)
in fact a known key */ in fact a known key */
int cn=0,in=0,kp=0; int cn=0,in=0,kp=0;
if (!keyring_find_sid(keyring,&cn,&in,&kp,known->sid)) if (!keyring_find_sid(keyring,&cn,&in,&kp,known->sid))
{ RETURN(WHYNULL("known key is not in fact known.")); } { RETURNNULL(WHYNULL("known key is not in fact known.")); }
/* work out where to store it */ /* work out where to store it */
if (nm_slots_used<NM_CACHE_SLOTS) { if (nm_slots_used<NM_CACHE_SLOTS) {

17
log.c
View File

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/param.h>
#include <time.h> #include <time.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
@ -400,15 +401,15 @@ ssize_t get_self_executable_path(char *buf, size_t len)
int log_backtrace(struct __sourceloc where) int log_backtrace(struct __sourceloc where)
{ {
open_logging(); open_logging();
char execpath[160]; char execpath[MAXPATHLEN];
if (get_self_executable_path(execpath, sizeof execpath) == -1) if (get_self_executable_path(execpath, sizeof execpath) == -1)
return WHY("cannot log backtrace: own executable path unknown"); return WHY("cannot log backtrace: own executable path unknown");
char tempfile[512]; char tempfile[MAXPATHLEN];
if (!FORM_SERVAL_INSTANCE_PATH(tempfile, "servalXXXXXX.gdb")) if (!FORM_SERVAL_INSTANCE_PATH(tempfile, "servalgdb.XXXXX"))
return -1; return -1;
int tmpfd = mkstemps(tempfile, 4); int tmpfd = mkstemp(tempfile);
if (tmpfd == -1) if (tmpfd == -1)
return WHY_perror("mkstemps"); return WHY_perror("mkstemp");
if (write_str(tmpfd, "backtrace\n") == -1) { if (write_str(tmpfd, "backtrace\n") == -1) {
close(tmpfd); close(tmpfd);
unlink(tempfile); unlink(tempfile);
@ -420,7 +421,7 @@ int log_backtrace(struct __sourceloc where)
return -1; return -1;
} }
char pidstr[12]; char pidstr[12];
snprintf(pidstr, sizeof pidstr, "%u", getpid()); snprintf(pidstr, sizeof pidstr, "%jd", (intmax_t)getpid());
int stdout_fds[2]; int stdout_fds[2];
if (pipe(stdout_fds) == -1) if (pipe(stdout_fds) == -1)
return WHY_perror("pipe"); return WHY_perror("pipe");
@ -442,7 +443,9 @@ int log_backtrace(struct __sourceloc where)
_exit(-2); _exit(-2);
} }
close(stdout_fds[0]); close(stdout_fds[0]);
execlp("gdb", "gdb", "-n", "-batch", "-x", tempfile, execpath, pidstr, NULL); /* XXX: Need the cast on Solaris because it defins NULL as 0L and gcc doesn't
* see it as a sentinal */
execlp("gdb", "gdb", "-n", "-batch", "-x", tempfile, execpath, pidstr, (void*)NULL);
perror("execlp(\"gdb\")"); perror("execlp(\"gdb\")");
do { _exit(-3); } while (1); do { _exit(-3); } while (1);
break; break;

View File

@ -1 +1 @@
/usr/share/libtool/config/ltmain.sh /opt/csw/share/libtool/config/ltmain.sh

View File

@ -27,6 +27,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "rhizome.h" #include "rhizome.h"
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_UCRED_H
#include <ucred.h>
#endif
#if defined(LOCAL_PEERCRED) && !defined(SO_PEERCRED) #if defined(LOCAL_PEERCRED) && !defined(SO_PEERCRED)
#define SO_PEERCRED LOCAL_PEERCRED #define SO_PEERCRED LOCAL_PEERCRED
#endif #endif
@ -263,12 +267,14 @@ void monitor_client_poll(struct sched_ent *alarm)
} }
static void monitor_new_client(int s) { static void monitor_new_client(int s) {
#ifdef linux #ifdef SO_PEERCRED
struct ucred ucred; struct ucred ucred;
socklen_t len; socklen_t len;
int res; int res;
#else #elif defined(HAVE_GETPEEREID)
gid_t othergid; gid_t othergid;
#elif defined(HAVE_UCRED_H)
ucred_t *ucred;
#endif #endif
uid_t otheruid; uid_t otheruid;
struct monitor_context *c; struct monitor_context *c;
@ -276,7 +282,8 @@ static void monitor_new_client(int s) {
if (set_nonblock(s) == -1) if (set_nonblock(s) == -1)
goto error; goto error;
#ifdef linux #ifdef SO_PEERCRED
/* Linux way */
len = sizeof(ucred); len = sizeof(ucred);
res = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &ucred, &len); res = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &ucred, &len);
if (res) { if (res) {
@ -288,11 +295,22 @@ static void monitor_new_client(int s) {
goto error; goto error;
} }
otheruid = ucred.uid; otheruid = ucred.uid;
#else #elif defined(HAVE_UCRED_H)
/* Solaris way */
if (getpeerucred(s, &ucred) != 0) {
WHY_perror("getpeerucred()");
goto error;
}
otheruid = ucred_geteuid(ucred);
ucred_free(ucred);
#elif defined(HAVE_GETPEEREID)
/* BSD way */
if (getpeereid(s, &otheruid, &othergid) != 0) { if (getpeereid(s, &otheruid, &othergid) != 0) {
WHY_perror("getpeereid()"); WHY_perror("getpeereid()");
goto error; goto error;
} }
#else
#error No way to get socket peer credentials
#endif #endif
if (otheruid != getuid()) { if (otheruid != getuid()) {

View File

@ -17,6 +17,10 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
#include "serval.h" #include "serval.h"
@ -219,7 +223,13 @@ int overlay_bind_socket(const struct sockaddr *addr, size_t addr_size, char *int
/* Automatically close socket on calls to exec(). /* Automatically close socket on calls to exec().
This makes life easier when we restart with an exec after receiving This makes life easier when we restart with an exec after receiving
a bad signal. */ a bad signal. */
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, NULL) | O_CLOEXEC); fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, NULL) |
#ifdef FD_CLOEXEC
FD_CLOEXEC
#else
O_CLOEXEC
#endif
);
#ifdef SO_BINDTODEVICE #ifdef SO_BINDTODEVICE
/* /*

View File

@ -291,7 +291,7 @@ unsigned char *overlay_mdp_decrypt(overlay_frame *f, overlay_mdp_frame *mdp, int
mdp->packetTypeAndFlags|=MDP_NOCRYPT|MDP_NOSIGN; mdp->packetTypeAndFlags|=MDP_NOCRYPT|MDP_NOSIGN;
break; break;
case OF_CRYPTO_CIPHERED: case OF_CRYPTO_CIPHERED:
RETURN(WHYNULL("decryption not implemented")); RETURNNULL(WHYNULL("decryption not implemented"));
mdp->packetTypeAndFlags|=MDP_NOSIGN; mdp->packetTypeAndFlags|=MDP_NOSIGN;
break; break;
case OF_CRYPTO_SIGNED: case OF_CRYPTO_SIGNED:
@ -301,7 +301,7 @@ unsigned char *overlay_mdp_decrypt(overlay_frame *f, overlay_mdp_frame *mdp, int
is not available. */ is not available. */
unsigned char *key = keyring_find_sas_public(keyring,mdp->out.src.sid); unsigned char *key = keyring_find_sas_public(keyring,mdp->out.src.sid);
if (!key) if (!key)
RETURN(WHYNULL("SAS key not currently on record, cannot verify")); RETURNNULL(WHYNULL("SAS key not currently on record, cannot verify"));
/* get payload and following compacted signature */ /* get payload and following compacted signature */
b=&f->payload->bytes[0]; b=&f->payload->bytes[0];

View File

@ -298,19 +298,24 @@ overlay_frame *op_dup(overlay_frame *in)
/* clone the frame */ /* clone the frame */
overlay_frame *out=malloc(sizeof(overlay_frame)); overlay_frame *out=malloc(sizeof(overlay_frame));
if (!out) return WHYNULL("malloc() failed"); if (!out) {
WHY("malloc() failed");
return NULL;
}
/* copy main data structure */ /* copy main data structure */
bcopy(in,out,sizeof(overlay_frame)); bcopy(in,out,sizeof(overlay_frame));
out->payload=ob_new(in->payload->length); out->payload=ob_new(in->payload->length);
if (!out->payload) { if (!out->payload) {
free(out); free(out);
return WHYNULL("ob_new() failed"); WHY("ob_new() failed");
return NULL;
} }
if (ob_append_bytes(out->payload,&in->payload->bytes[0],in->payload->length)) if (ob_append_bytes(out->payload,&in->payload->bytes[0],in->payload->length))
{ {
op_free(out); op_free(out);
return WHYNULL("could not duplicate payload bytes"); WHY("could not duplicate payload bytes");
return NULL;
} }
return out; return out;
} }

View File

@ -17,6 +17,10 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "serval.h" #include "serval.h"
char *batman_socket=NULL; char *batman_socket=NULL;

View File

@ -872,7 +872,7 @@ int rhizome_store_file(rhizome_manifest *m,const unsigned char *key)
WARNF("File has grown by %lld bytes. I will just store the original number of bytes so that the hash (hopefully) matches",stat.st_size-m->fileLength); WARNF("File has grown by %lld bytes. I will just store the original number of bytes so that the hash (hopefully) matches",stat.st_size-m->fileLength);
} }
unsigned char *addr = mmap(NULL, m->fileLength, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0); unsigned char *addr = mmap(NULL, m->fileLength, PROT_READ, MAP_SHARED, fd, 0);
if (addr==MAP_FAILED) { if (addr==MAP_FAILED) {
WHY_perror("mmap"); WHY_perror("mmap");
WHY("mmap() of associated file failed."); WHY("mmap() of associated file failed.");

View File

@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <signal.h> #include <signal.h>
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#include "serval.h" #include "serval.h"
#include "str.h" #include "str.h"

View File

@ -21,6 +21,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "rhizome.h" #include "rhizome.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int rhizome_manifest_to_bar(rhizome_manifest *m,unsigned char *bar) int rhizome_manifest_to_bar(rhizome_manifest *m,unsigned char *bar)
{ {

View File

@ -1163,5 +1163,6 @@ void dump_stack();
#define OUT() fd_func_exit(&_this_call); #define OUT() fd_func_exit(&_this_call);
#define RETURN(X) { OUT() return(X); } #define RETURN(X) { OUT() return(X); }
#define RETURNNULL { OUT() return(NULL); }
#endif // __SERVALD_SERVALD_H #endif // __SERVALD_SERVALD_H

View File

@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include "xprintf.h" #include "xprintf.h"
#define MAX_SPACES 120 #define MAX_SPACES 120

View File

@ -828,7 +828,13 @@ int createServerSocket()
This makes life easier when we restart with an exec after receiving This makes life easier when we restart with an exec after receiving
a bad signal. */ a bad signal. */
fcntl(sock, F_SETFL, fcntl(sock, F_SETFL,
fcntl(sock, F_GETFL, NULL)|O_CLOEXEC); fcntl(sock, F_GETFL, NULL)|
#ifdef FD_CLOEXEC
FD_CLOEXEC
#else
O_CLOEXEC
#endif
);
int i=1; int i=1;
setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &i, sizeof(i)); setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &i, sizeof(i));

14
sha2.c
View File

@ -36,8 +36,22 @@
#ifdef HAVE_SYS_ENDIAN_H #ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#ifdef HAVE_SYS_BYTEORDER_H
#include <sys/byteorder.h>
#endif
#include "sha2.h" #include "sha2.h"
/* Translate from Solaris */
#ifndef BYTE_ORDER
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
#ifdef _BIG_ENDIAN
#define BYTE_ORDER BIG_ENDIAN
#else
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#endif
/* /*
* ASSERT NOTE: * ASSERT NOTE:
* Some sanity checking code is included using assert(). On my FreeBSD * Some sanity checking code is included using assert(). On my FreeBSD