Bugzilla bug 70217: ported NSS to BeOS. The patch is contributed by

Christopher Seawood <seawood@netscape.com>.
This commit is contained in:
wtc%netscape.com 2002-02-22 04:23:30 +00:00
parent 3d445136d1
commit 6c79ece2fe
24 changed files with 195 additions and 50 deletions

79
security/coreconf/BeOS.mk Normal file
View File

@ -0,0 +1,79 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape security libraries.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2002 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU General Public License Version 2 or later (the
# "GPL"), in which case the provisions of the GPL are applicable
# instead of those above. If you wish to allow use of your
# version of this file only under the terms of the GPL and not to
# allow others to use your version of this file under the MPL,
# indicate your decision by deleting the provisions above and
# replace them with the notice and other provisions required by
# the GPL. If you do not delete the provisions above, a recipient
# may use your version of this file under either the MPL or the
# GPL.
#
# Config stuff for BeOS
#
include $(CORE_DEPTH)/coreconf/UNIX.mk
XP_DEFINE := $(XP_DEFINE:-DXP_UNIX=-DXP_BEOS)
USE_PTHREADS =
ifeq ($(USE_PTHREADS),1)
IMPL_STRATEGY = _PTH
endif
CC = gcc
CCC = g++
RANLIB = ranlib
DEFAULT_COMPILER = gcc
ifeq ($(OS_TEST),ppc)
OS_REL_CFLAGS = -Dppc
CPU_ARCH = ppc
else
OS_REL_CFLAGS = -Di386
CPU_ARCH = x86
endif
MKSHLIB = $(CC) -nostart -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
ifdef BUILD_OPT
OPTIMIZER = -O2
endif
OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wall -pipe
OS_LIBS = -lbe
DEFINES += -DBEOS
ifdef USE_PTHREADS
DEFINES += -D_REENTRANT
endif
ARCH = beos
DSO_CFLAGS = -fPIC
DSO_LDOPTS =
DSO_LDFLAGS =

View File

@ -58,7 +58,7 @@ endif
# one for each OS release. #
#######################################################################
TARGET_OSES = FreeBSD BSD_OS NetBSD OpenUNIX OS2 QNX Darwin
TARGET_OSES = FreeBSD BSD_OS NetBSD OpenUNIX OS2 QNX Darwin BeOS
ifeq (,$(filter-out $(TARGET_OSES),$(OS_TARGET)))
include $(CORE_DEPTH)/coreconf/$(OS_TARGET).mk

View File

@ -55,10 +55,16 @@ typedef unsigned int mode_t;
#define HAVE_LCHOWN
#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(VMS) || defined(NTO) || defined(DARWIN)
#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(VMS) || defined(NTO) || defined(DARWIN) || defined(BEOS)
#undef HAVE_LCHOWN
#endif
#define HAVE_FCHMOD
#if defined(BEOS)
#undef HAVE_FCHMOD
#endif
#ifdef LINUX
#include <getopt.h>
#endif
@ -403,7 +409,11 @@ retry:
if (utime(toname, &utb) < 0)
fail("cannot set times of %s", toname);
}
#ifdef HAVE_FCHMOD
if (fchmod(tofd, mode) < 0)
#else
if (chmod(toname, mode) < 0)
#endif
fail("cannot change mode of %s", toname);
if ((owner || group) && fchown(tofd, uid, gid) < 0)
fail("cannot change owner of %s", toname);

View File

@ -41,7 +41,7 @@
#define NUM_SLOTS 32
#if !defined (XP_UNIX) && !defined (_WINDOWS) && !defined(XP_OS2)
#if !defined (XP_UNIX) && !defined (_WINDOWS) && !defined (XP_OS2) && !defined (XP_BEOS)
#define XP_MAC 1 /*Make sure we get this define in for Mac builds*/
#endif

View File

@ -39,7 +39,7 @@
#define _GENCI_H_ 1
#include "seccomon.h"
#if defined (XP_UNIX) || defined (XP_WIN32) || defined (XP_OS2)
#if defined (XP_UNIX) || defined (XP_WIN32) || defined (XP_OS2) || defined (XP_BEOS)
/*
* On unix, NT, Windows '95, and OS/2 we use full maci

View File

@ -54,7 +54,7 @@
/*#include "keylow.h" */
#include "secder.h"
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
#include <unistd.h>
#endif

View File

@ -406,8 +406,8 @@ fort_GenerateRandom(unsigned char *buf, int bytes)
/*
* NOTE: that MAC is missing below.
*/
#if defined (XP_UNIX) || defined (XP_OS2)
#ifdef XP_UNIX
#if defined (XP_UNIX) || defined (XP_OS2) || defined (XP_BEOS)
#if defined (XP_UNIX) || defined (XP_BEOS)
#define NS_PATH_SEP ':'
#define NS_DIR_SEP '/'
#define NS_DEFAULT_PATH ".:/bin/netscape:/etc/netscape/:/etc"
@ -448,7 +448,7 @@ local_getFileInfo(const char *fn, PRFileInfo *info)
}
return rv;
}
#endif /* UNIX & OS/2 */
#endif /* UNIX, OS/2, and BEOS */
#ifdef XP_WIN
#define NS_PATH_SEP ';'

View File

@ -32,7 +32,7 @@
*/
#include "seccomon.h"
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
#include "unix_rand.c"
#endif
#ifdef XP_WIN

View File

@ -550,6 +550,39 @@ GetHighResClock(void *buf, size_t maxbytes)
#endif /* VMS */
#ifdef BEOS
#include <be/kernel/OS.h>
static size_t
GetHighResClock(void *buf, size_t maxbytes)
{
bigtime_t bigtime; /* Actually an int64 */
bigtime = real_time_clock_usecs();
return CopyLowBits(buf, maxbytes, &bigtime, sizeof(bigtime));
}
static void
GiveSystemInfo(void)
{
system_info *info = NULL;
int32 val;
get_system_info(info);
if (info) {
val = info->boot_time;
RNG_RandomUpdate(&val, sizeof(val));
val = info->used_pages;
RNG_RandomUpdate(&val, sizeof(val));
val = info->used_ports;
RNG_RandomUpdate(&val, sizeof(val));
val = info->used_threads;
RNG_RandomUpdate(&val, sizeof(val));
val = info->used_teams;
RNG_RandomUpdate(&val, sizeof(val));
}
}
#endif /* BEOS */
#if defined(nec_ews)
#include <sys/systeminfo.h>
@ -735,6 +768,16 @@ void RNG_SystemInfoForRNG(void)
#else
extern char **environ;
#endif
#ifdef BEOS
static const char * const files[] = {
"/boot/var/swap",
"/boot/var/log/syslog",
"/boot/var/tmp",
"/boot/home/config/settings",
"/boot/home",
0
};
#else
static const char * const files[] = {
"/etc/passwd",
"/etc/utmp",
@ -743,6 +786,7 @@ void RNG_SystemInfoForRNG(void)
"/usr/tmp",
0
};
#endif
#ifdef DO_PS
For now it is considered that it is too expensive to run the ps command

View File

@ -203,7 +203,7 @@ typedef struct JAR_Physical_
unsigned long offset;
unsigned long length;
unsigned long uncompressed_length;
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
uint16 mode;
#endif
}

View File

@ -47,7 +47,7 @@
/* commercial compression */
#include "jzlib.h"
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
#include "sys/stat.h"
#endif
@ -252,7 +252,7 @@ int JAR_extract
(unsigned int) phy->compression);
}
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
if (phy->mode)
chmod (outpath, 0400 | (mode_t) phy->mode);
#endif
@ -891,7 +891,7 @@ static int jar_listzip (JAR *jar, JAR_FILE fp)
goto loser;
}
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
/* with unix we need to locate any bits from
the protection mask in the external attributes. */
{

View File

@ -32,7 +32,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
# $Id: nssinit.c,v 1.38 2002/01/29 22:27:15 relyea%netscape.com Exp $
# $Id: nssinit.c,v 1.39 2002/02/22 04:23:20 wtc%netscape.com Exp $
*/
#include <ctype.h>
@ -261,7 +261,7 @@ static const char *dllname =
"nssckbi.dll";
#elif defined(HPUX)
"libnssckbi.sl";
#elif defined(XP_UNIX)
#elif defined(XP_UNIX) || defined(XP_BEOS)
"libnssckbi.so";
#elif defined(XP_MAC)
"NSS Builtin Root Certs";

View File

@ -59,6 +59,10 @@ EXTRA_SHARED_LIBS += \
-lnspr4 \
$(NULL)
ifeq ($(OS_ARCH), BeOS)
EXTRA_SHARED_LIBS += -lbe
endif
ifeq ($(OS_ARCH), Darwin)
EXTRA_SHARED_LIBS += -dylib_file @executable_path/libsoftokn3.dylib:$(DIST)/lib/libsoftokn3.dylib
endif

View File

@ -34,12 +34,12 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: emulate.c,v 1.4 2001/12/07 02:04:24 relyea%netscape.com Exp $
* $Id: emulate.c,v 1.5 2002/02/22 04:23:22 wtc%netscape.com Exp $
*/
#include "nspr.h"
#if defined( XP_UNIX )
#if defined( XP_UNIX ) || defined( XP_BEOS )
#include <fcntl.h>
#endif
#if defined(WIN32)
@ -95,7 +95,7 @@ ssl_EmulateAcceptRead( PRFileDesc * sd,
}
#if !defined( XP_UNIX ) && !defined( WIN32 )
#if !defined( XP_UNIX ) && !defined( WIN32 ) && !defined( XP_BEOS )
/*
* _PR_EmulateTransmitFile
*
@ -293,12 +293,12 @@ done:
PR_CloseFileMap(mapHandle);
return count;
}
#endif /* XP_UNIX */
#endif /* XP_UNIX || WIN32 || XP_BEOS */
#if !defined( XP_UNIX ) && !defined( WIN32 )
#if !defined( XP_UNIX ) && !defined( WIN32 ) && !defined( XP_BEOS )
/*
* _PR_EmulateSendFile
*
@ -442,7 +442,7 @@ done:
return rv;
}
#else /* UNIX and NT handled below */
#else /* UNIX, NT, and BEOS handled below */
/*
* _PR_UnixSendFile
@ -630,4 +630,4 @@ done:
PR_Close(sd);
return count;
}
#endif /* UNIX and NT */
#endif /* UNIX, NT, and BEOS */

View File

@ -34,7 +34,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: sslimpl.h,v 1.21 2001/11/22 00:46:48 jpierre%netscape.com Exp $
* $Id: sslimpl.h,v 1.22 2002/02/22 04:23:24 wtc%netscape.com Exp $
*/
#ifndef __sslimpl_h_
@ -53,7 +53,7 @@
#include "hasht.h"
#include "nssilock.h"
#include "pkcs11t.h"
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
#include "unistd.h"
#endif
#include "nssrwlk.h"
@ -1273,7 +1273,7 @@ SEC_END_PROTOS
#include <process.h>
#endif
#if defined(XP_UNIX) || defined(XP_OS2)
#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
#define SSL_GETPID() getpid()
#elif defined(WIN32)

View File

@ -30,7 +30,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: sslmutex.c,v 1.7 2002/02/16 02:52:06 wtc%netscape.com Exp $
* $Id: sslmutex.c,v 1.8 2002/02/22 04:23:24 wtc%netscape.com Exp $
*/
#include "sslmutex.h"
@ -83,7 +83,7 @@ static SECStatus single_process_sslMutex_Lock(sslMutex* pMutex)
return SECSuccess;
}
#if defined(LINUX) || defined(AIX) || defined(VMS)
#if defined(LINUX) || defined(AIX) || defined(VMS) || defined(BEOS)
#include <unistd.h>
#include <fcntl.h>

View File

@ -30,7 +30,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: sslmutex.h,v 1.4 2002/02/16 02:52:07 wtc%netscape.com Exp $
* $Id: sslmutex.h,v 1.5 2002/02/22 04:23:24 wtc%netscape.com Exp $
*/
#ifndef __SSLMUTEX_H_
#define __SSLMUTEX_H_ 1
@ -77,7 +77,7 @@ typedef struct
typedef int sslPID;
#elif defined(LINUX) || defined(AIX) || defined(VMS)
#elif defined(LINUX) || defined(AIX) || defined(VMS) || defined(BEOS)
#include <sys/types.h>
#include "prtypes.h"

View File

@ -32,7 +32,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: sslnonce.c,v 1.9 2001/11/09 05:39:36 nelsonb%netscape.com Exp $
* $Id: sslnonce.c,v 1.10 2002/02/22 04:23:24 wtc%netscape.com Exp $
*/
#include "nssrenam.h"
@ -44,7 +44,7 @@
#include "sslproto.h"
#include "nssilock.h"
#include "nsslocks.h"
#if defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS)
#if defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS) || defined(XP_BEOS)
#include <time.h>
#endif
@ -348,7 +348,7 @@ PRUint32
ssl_Time(void)
{
PRUint32 myTime;
#if defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS)
#if defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS) || defined(XP_BEOS)
myTime = time(NULL); /* accurate until the year 2038. */
#else
/* portable, but possibly slower */

View File

@ -32,7 +32,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: sslsecur.c,v 1.14 2001/11/08 02:15:38 nelsonb%netscape.com Exp $
* $Id: sslsecur.c,v 1.15 2002/02/22 04:23:25 wtc%netscape.com Exp $
*/
#include "cert.h"
#include "secitem.h"
@ -47,6 +47,8 @@
#include "winsock.h" /* for MSG_PEEK */
#elif defined(XP_MAC)
#include "macsocket.h"
#elif defined(BEOS)
#define MSG_PEEK 0x2
#else
#include <sys/socket.h> /* for MSG_PEEK */
#endif

View File

@ -32,7 +32,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: sslsnce.c,v 1.19 2002/02/16 02:52:07 wtc%netscape.com Exp $
* $Id: sslsnce.c,v 1.20 2002/02/22 04:23:26 wtc%netscape.com Exp $
*/
/* Note: ssl_FreeSID() in sslnonce.c gets used for both client and server
@ -69,7 +69,7 @@
#include "nssrenam.h"
#include "seccomon.h"
#if defined(XP_UNIX) || defined(XP_WIN32) || defined (XP_OS2)
#if defined(XP_UNIX) || defined(XP_WIN32) || defined (XP_OS2) || defined(XP_BEOS)
#include "cert.h"
#include "ssl.h"
@ -80,7 +80,7 @@
#include <stdio.h>
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
#include <syslog.h>
#include <fcntl.h>
@ -282,11 +282,11 @@ typedef struct inheritanceStr inheritance;
#endif /* _win32 */
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
#define DEFAULT_CACHE_DIRECTORY "/tmp"
#endif /* XP_UNIX */
#endif /* XP_UNIX || XP_BEOS */
/************************************************************************/
@ -294,7 +294,7 @@ typedef struct inheritanceStr inheritance;
static void
IOError(int rv, char *type)
{
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
syslog(LOG_ALERT,
"SSL: %s error with session-id cache, pid=%d, rv=%d, error='%m'",
type, myPid, rv);
@ -992,7 +992,7 @@ InitCache(cacheDesc *cache, int maxCacheEntries, PRUint32 ssl2_timeout,
}
/* Create file names */
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
/* there's some confusion here about whether PR_OpenAnonFileMap wants
** a directory name or a file name for its first argument.
cfn = PR_smprintf("%s/.sslsvrcache.%d", directory, myPid);
@ -1206,7 +1206,7 @@ SSL_ConfigMPServerSIDCache( int maxCacheEntries,
result = SECFailure;
}
#if defined(XP_UNIX)
#if defined(XP_UNIX) || defined(XP_BEOS)
/* Launch thread to poll cache for expired locks on Unix */
LaunchLockPoller(cache);
#endif
@ -1359,7 +1359,7 @@ SSL_InheritMPServerSIDCache(const char * envString)
return SSL_InheritMPServerSIDCacheInstance(&globalCache, envString);
}
#if defined(XP_UNIX)
#if defined(XP_UNIX) || defined(XP_BEOS)
#define SID_LOCK_EXPIRATION_TIMEOUT 30 /* seconds */

View File

@ -35,7 +35,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: sslsock.c,v 1.23 2001/12/07 01:36:23 relyea%netscape.com Exp $
* $Id: sslsock.c,v 1.24 2002/02/22 04:23:26 wtc%netscape.com Exp $
*/
#include "seccomon.h"
#include "cert.h"
@ -1800,7 +1800,7 @@ ssl_NewSocket(void)
#endif
#ifdef DEBUG
#if defined(XP_UNIX) || defined(XP_WIN32)
#if defined(XP_UNIX) || defined(XP_WIN32) || defined(XP_BEOS)
if (firsttime) {
firsttime = 0;

View File

@ -38,7 +38,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: unix_err.c,v 1.5 2002/02/10 05:24:49 wtc%netscape.com Exp $
* $Id: unix_err.c,v 1.6 2002/02/22 04:23:26 wtc%netscape.com Exp $
*/
#if 0
@ -48,7 +48,7 @@
#include "prerror.h"
#endif
#if defined (__bsdi__) || defined(NTO) || defined(DARWIN)
#if defined (__bsdi__) || defined(NTO) || defined(DARWIN) || defined(BEOS)
#undef _PR_POLL_AVAILABLE
#endif

View File

@ -38,7 +38,7 @@
*
* NOTE - These are not public interfaces
*
* $Id: secport.c,v 1.10 2002/02/05 22:20:43 jpierre%netscape.com Exp $
* $Id: secport.c,v 1.11 2002/02/22 04:23:29 wtc%netscape.com Exp $
*/
#include "seccomon.h"
@ -60,7 +60,7 @@
#include "prthread.h"
#endif /* THREADMARK */
#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_OS2)
#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_OS2) || defined(XP_BEOS)
#include <stdlib.h>
#else
#include "wtypes.h"

View File

@ -38,14 +38,14 @@
*
* NOTE - These are not public interfaces
*
* $Id: secport.h,v 1.2 2001/05/21 21:25:32 wtc%netscape.com Exp $
* $Id: secport.h,v 1.3 2002/02/22 04:23:30 wtc%netscape.com Exp $
*/
#ifndef _SECPORT_H_
#define _SECPORT_H_
/*
* define XP_MAC, XP_WIN, or XP_UNIX, in case they are not defined
* define XP_MAC, XP_WIN, XP_BEOS, or XP_UNIX, in case they are not defined
* by anyone else
*/
#ifdef macintosh
@ -69,6 +69,12 @@
#endif
#endif
#ifdef __BEOS__
# ifndef XP_BEOS
# define XP_BEOS
# endif
#endif
#ifdef unix
# ifndef XP_UNIX
# define XP_UNIX