diff -Naur cernlib2003.orig/Imakefile cernlib2003.new/Imakefile --- cernlib2003.orig/Imakefile 1996-12-16 07:08:41.000000000 -0800 +++ cernlib2003.new/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -7,8 +7,12 @@ SUBDIRS= $(LIBDIRS) patchy cfortran #ifdef CERNLIB_UNIX +#ifdef CERNLIB_MACOSX +SUBDIRS:= $(SUBDIRS) scripts +#else SUBDIRS:= $(SUBDIRS) scripts mgr #endif +#endif InstallLibSubdirs($(LIBDIRS)) diff -Naur cernlib2003.orig/config/Imake.cf cernlib2003.new/config/Imake.cf --- cernlib2003.orig/config/Imake.cf 1998-09-25 02:23:38.000000000 -0700 +++ cernlib2003.new/config/Imake.cf 2003-12-29 11:21:25.000000000 -0800 @@ -214,6 +214,13 @@ #define MacIIArchitecture #endif /* macII */ +#ifdef __APPLE__ +# define MacroIncludeFile +# define MacroFile MacOSX.cf +# define MacOSXArchitecture +# define DarwinArchitecture +#endif + #ifdef _CRAY #define MacroIncludeFile #define MacroFile cray.cf diff -Naur cernlib2003.orig/config/Imake.rules cernlib2003.new/config/Imake.rules --- cernlib2003.orig/config/Imake.rules 2000-04-19 03:51:00.000000000 -0700 +++ cernlib2003.new/config/Imake.rules 2003-12-29 11:21:25.000000000 -0800 @@ -2167,7 +2167,7 @@ #define CppScriptTarget(dst,src,defs,deplist) @@\ dst:: src deplist @@\ RemoveFile($@) @@\ - $(CPP) defs $@ @@\ + $(CPP) defs src | CppSedMagic >$@ @@\ chmod a+x $@ @@\ @@\ clean:: @@\ @@ -2199,7 +2199,7 @@ #define CppFileTarget(dst,src,defs,deplist) @@\ dst:: src deplist @@\ RemoveFile($@) @@\ - $(CPP) defs $@ @@\ + $(CPP) defs src | CppSedMagic >$@ @@\ @@\ clean:: @@\ RemoveFiles(dst) diff -Naur cernlib2003.orig/config/MacOSX.cf cernlib2003.new/config/MacOSX.cf --- cernlib2003.orig/config/MacOSX.cf 1969-12-31 16:00:00.000000000 -0800 +++ cernlib2003.new/config/MacOSX.cf 2003-12-29 11:21:25.000000000 -0800 @@ -0,0 +1,160 @@ +XCOMM platform: $SFO: MOSXS.cf,v 1.0 95/11/19 23:21:00 sl Exp $ + +#define OSVendor Apple Computer, Inc. +#ifdef MacOSXArchitecture +#define OSName MacOSX +#define OSMajorVersion DefaultOSMajorVersion +#define OSMinorVersion DefaultOSMinorVersion +#define OSTeenyVersion 0 +#endif + +XCOMM #define ProjectRulesFile +XCOMM #define ProjectTmplFile + +#define InstKmemFlags -m 2755 -g kmem +/* #define ConstructMFLAGS NO */ + +#define HasNdbm YES +#define SetTtyGroup YES +#define HasBsearch YES +#ifdef MacOSXArchitecture +#define HasPutenv YES +#define MathLibrary /**/ +#define DBMLibrary /**/ +#define TermcapLibrary /**/ +#define HasBSD44Sockets YES +#define HAS_SNPRINTF YES +#endif + +#define NeedConstPrototypes YES +#define NeedVarargsPrototypes YES +#define NeedFunctionPrototypes YES +#define NeedWidePrototypes NO + +#define GzipFontCompression YES +#define CompressAllFonts YES + +#ifndef HasShm +# define HasShm YES +#endif +#ifndef BuildGlxExt +# define BuildGlxExt YES +# define GlxUseNSGL YES +#endif +#define BuildServer YES +#define BuildXprint NO +#define BuildFonts YES +#define BuildDPMS NO + +#define TenonServer YES +#define XprtServer NO +#define XVendorString "Tenon Intersystems Xtools" +#define XVendorRelease 1000 +#ifndef UseRgbTxt +#define UseRgbTxt YES +#endif + +#define BuildPexExt NO + +#ifndef BuildGLXLibrary +# define BuildGLXLibrary YES +#endif + +/* no direct graphics extension */ +#define BuildXF86DGA NO + +/* no extra tablets and weird input devices */ +#define BuildXInputExt NO + +/* Build Xinerama (aka panoramiX) extension */ +#define BuildXinerama YES + +/* no Display Power Management extension */ +#define BuildDPMSExt NO + +# define BuildXvExt NO +#define OptimizedCDebugFlags -O -fPIC -pipe +#define ExtraLoadFlags -L/usr/X11R6/lib -L@PREFIX@/lib -L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A + +#define BuildExamples YES + +#define StandardDefines -DCERNLIB_LINUX -DCERNLIB_PPC -DCERNLIB_MACOSX \ + -Dunix=unix -D__powerpc__ -D__DARWIN__ +/* -DX_NOT_POSIX -DX_LOCALE */ + +#define HasVoidSignalReturn YES + +#ifndef DependFlags +#define DependFlags -I/usr/include/ansi -I/usr/include/bsd -I@PREFIX@/include +#endif + +#define StandardIncludes -I@PREFIX@/include + +#define InstallCmd install /* unlink old */ + +/* #define ArCmd libtool -a -o */ +#define ArCmd ar -r + +#ifndef RanlibCmd +#define RanlibCmd ranlib -c -s +#endif + +/* see below for ServerDefines */ + +#define PrimaryScreenResolution 95 /* for 17 inch screen */ + +#define ServerCDebugFlags -O -g -pipe + +#undef CcCmd +#undef CplusplusCmd +#ifdef MacOSXArchitecture +#define CcCmd gcc-3.3 -arch "ppc" +#define CplusplusCmd g++-3.3 +#endif +#ifndef CcCmd +#define CcCmd gcc-3.3 +#endif + +#define CppCmd g++-3.3 + +#include +#include +#undef XFree86Server +/* #define GLX_DIRECT_RENDERING */ + +#define f2cFortran YES +#define MakeCmd make +#define FortranCmd g77 +#define XargsCmd xargs +#define FortranSaveFlags /* */ /* Everything static !? */ +#define OptimisedFortranFlags -O -funroll-loops -fomit-frame-pointer +#define DefaultFCOptions -fno-automatic \ + -fno-second-underscore \ + -fno-f90 -fugly-complex -fno-globals \ + -fugly-init -Wno-globals +#define CernlibSystem -DCERNLIB_LINUX -DCERNLIB_UNIX -DCERNLIB_LNX \ + -DCERNLIB_PPC -DCERNLIB_QMGLIBC \ + -DCERNLIB_MACOSX + +#undef CERNLIB_SHIFT + +#define CERNLIB_LINUX +#define CERNLIB_UNIX +#define CERNLIB_LNX +#define CERNLIB_PPC +#define CERNLIB_QMGLIBC +#define CERNLIB_MACOSX + +#define X11Includes -I/usr/X11R6/include + +/* + * Create a Make Variable to allow building with/out Motif + */ +#undef MotifDependantMakeVar +#define MotifDependantMakeVar(variable,value) @@\ +ifneq ($(strip $(HAVE_MOTIF)),) @@\ + variable=value @@\ +endif @@\ +/* End CERNLIB changes */ + + diff -Naur cernlib2003.orig/config/MacOSX.rules cernlib2003.new/config/MacOSX.rules --- cernlib2003.orig/config/MacOSX.rules 1969-12-31 16:00:00.000000000 -0800 +++ cernlib2003.new/config/MacOSX.rules 2003-12-29 11:21:25.000000000 -0800 @@ -0,0 +1,117 @@ +XCOMM $XConsortium: MOSXS.rules,v 1.1 97/12/12 15:34:45 sl Exp $ + +/* + * MacOSX shared library rules + */ + +#define HasSharedLibraries YES + +#define ForceNormalLib NO + +#ifndef SharedDataSeparation +#define SharedDataSeparation YES +#endif +#ifndef SharedCodeDef +#define SharedCodeDef +#endif +#ifndef SharedLibraryDef +#define SharedLibraryDef -fno-common +#endif + +#define ShLibIncludeFile + +#ifndef SharedLibraryLoadFlags +#define SharedLibraryLoadFlags +#endif +#ifndef PositionIndependentCFlags +#define PositionIndependentCFlags +#endif + + + + +/* + * InstallSharedLibrary - generate rules to install the shared library. + */ +#ifndef InstallSharedLibrary +#define InstallSharedLibrary(libname,rev,dest) @@\ +install:: Concat(lib,libname.dylib) @@\ + MakeDir($(DESTDIR)dest) @@\ + $(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.dylib) $(DESTDIR)dest +@@\ + +#endif /* InstallSharedLibrary */ + +/* + * NormalSharedLibraryTarget - generate rules to create a shared library; + * build it into a different name so that the we do not hose people by having + * the library gone for long periods. + */ +#ifndef SharedLibraryTarget +#define SharedLibraryTarget(libname,rev,solist,down,up) @@\ +AllTarget(Concat(lib,libname.dylib)) @@\ + @@\ +Concat(lib,libname.dylib): solist $(EXTRALIBRARYDEPS) @@\ + $(RM) $@~ @@\ + (cd down; $(CC) -I/usr/X11R6/lib -dynamiclib -undefined suppress -install_name /usr/X11R6/lib/$@ -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\ + $(MV) $@~ $@ @@\ + LinkBuildLibrary($@) @@\ + @@\ +clean:: @@\ + $(RM) Concat(lib,libname.dylib) + +#endif /* SharedLibraryTarget */ + +/* + * SharedDepLibraryTarget - generate rules to create a shared library. + */ +#ifndef SharedDepLibraryTarget +#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up) @@\ +AllTarget(Concat(lib,libname.dylib)) @@\ + @@\ +Concat(lib,libname.dylib): deplist $(EXTRALIBRARYDEPS) @@\ + $(RM) $@~ @@\ + (cd down; $(CC) -I/usr/X11R6/lib -dynamiclib -undefined suppress -install_name /usr/X11R6/lib/$@ -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\ + $(RM) $@ @@\ + $(MV) $@~ $@ @@\ + LinkBuildLibrary($@) @@\ + @@\ +clean:: @@\ + $(RM) Concat(lib,libname.dylib) + +#endif /* SharedDepLibraryTarget */ + +/* + * SharedLibraryDataTarget - generate rules to create shlib data file; + */ +#ifndef SharedLibraryDataTarget +#define SharedLibraryDataTarget(libname,rev,salist) +#endif /* SharedLibraryDataTarget */ + +#ifndef InstallSharedLibraryData +#define InstallSharedLibraryData(libname,rev,dest) +#endif /* InstallSharedLibraryData */ + +/* + * SharedLibReferences - variables for shared libraries + */ +#ifndef SharedLibReferences +#define SharedLibReferences(varname,libname,libsource,revname,rev) @@\ +revname = rev @@\ +Concat3(DEP,varname,LIB) = SharedLibDependencies(libname,libsource,revname) @@\ +Concat(varname,LIB) = LoaderLibPrefix Concat(-l,libname) @@\ +LintLibReferences(varname,libname,libsource) +#endif + +/* + * SharedDSLibReferences - variables for shared libraries + */ +#ifndef SharedDSLibReferences +#define SharedDSLibReferences(varname,libname,libsource,revname,rev) @@\ +revname = rev @@\ +Concat3(DEP,varname,LIB) = SharedDSLibDependencies(libname,libsource,revname) @@\ +Concat(varname,LIB) = LoaderLibPrefix Concat(-l,libname) Concat3(Shared,libname,Reqs) @@\ +LintLibReferences(varname,libname,libsource) +#endif + + diff -Naur cernlib2003.orig/config/MacOSX.tmpl cernlib2003.new/config/MacOSX.tmpl --- cernlib2003.orig/config/MacOSX.tmpl 1969-12-31 16:00:00.000000000 -0800 +++ cernlib2003.new/config/MacOSX.tmpl 2003-12-29 11:21:25.000000000 -0800 @@ -0,0 +1,67 @@ +XCOMM $XConsortium: MOSXS.tmpl,v 1.2 97/12/12 19:07:12 sl Exp $ + +/* + * Xnext shared library template + */ + + + +#ifndef SharedXtReqs +#define SharedXtReqs /**/ +#endif +#ifndef SharedXawReqs +#define SharedXawReqs /**/ +#endif +#ifndef SharedXmuReqs +#define SharedXmuReqs $(LDPRELIB) $(XTOOLONLYLIB) $(XONLYLIB) +#endif + +#define SharedLibX11 YES +#define SharedX11Rev F +SharedLibReferences(XONLY,X11,$(XLIBSRC),SOXLIBREV,SharedX11Rev) + +#define SharedLibXau NO /* don't need shared form */ +#define SharedLibXdmcp NO /* don't need shared form */ + +#define SharedLibXmu YES +#define SharedXmuRev F + +#define SharedOldXRev F + +#define SharedLibXext YES +#define SharedXextRev F + +#define SharedLibXt YES +#define SharedXtRev F +SharedDSLibReferences(XTOOLONLY,Xt,$(TOOLKITSRC),SOXTREV,SharedXtRev) + +#define SharedXawRev F + +#define SharedXtfRev A + +#define SharedLibXi YES +#define SharedXiRev F +SharedLibReferences(XI,Xi,$(XILIBSRC),SOXINPUTREV,SharedXiRev) + +#define SharedLibXtst YES +#define SharedXtstRev F +SharedLibReferences(XTEST,Xtst,$(XTESTLIBSRC),SOXTESTREV,SharedXtstRev) + + +#define SharedPexRev F +SharedLibReferences(PEX,PEX5,$(PEXLIBSRC),SOPEXREV,SharedPexRev) + +#define SharedLibXie YES +#define SharedXieRev F + +#define SharedLibICE YES +#define SharedICERev F +SharedLibReferences(ICE,ICE,$(ICESRC),SOICEREV,SharedICERev) + +#define SharedLibSM YES +#define SharedSMRev F +SharedLibReferences(SM,SM,$(SMSRC),SOSMREV,SharedSMRev) + +#define SharedFSRev F +SharedLibReferences(FS,FS,$(FSLIBSRC),SOFSREV,SharedFSRev) + diff -Naur cernlib2003.orig/config/site.def cernlib2003.new/config/site.def --- cernlib2003.orig/config/site.def 2002-04-26 07:46:04.000000000 -0700 +++ cernlib2003.new/config/site.def 2003-12-29 11:21:25.000000000 -0800 @@ -99,9 +99,7 @@ /* if it is already defined and false, undef it! */ /* do not use shift by default #if defined(CERNLIB_UNIX) && !defined(CERNLIB_WINNT) -#if ! defined(CERNLIB_SHIFT) -#define CERNLIB_SHIFT -#elif ! CERNLIB_SHIFT +#if defined(CERNLIB_SHIFT) && !CERNLIB_SHIFT #undef CERNLIB_SHIFT #endif #endif @@ -109,11 +107,7 @@ /* gmake does like ConstructMFLAGS to be YES(?) */ #undef MakeCmd -#ifndef WIN32 -# define MakeCmd gmake -#else -# define MakeCmd make -#endif +#define MakeCmd make #define ConstructMFLAGS YES #ifndef WIN32 diff -Naur cernlib2003.orig/geant321/Imakefile cernlib2003.new/geant321/Imakefile --- cernlib2003.orig/geant321/Imakefile 1998-03-05 03:20:07.000000000 -0800 +++ cernlib2003.new/geant321/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -37,7 +37,11 @@ install.lib:: $(CERN_LIBDIR)/xsneut95.dat $(CERN_LIBDIR)/xsneut95.dat: +#if defined(CERNLIB_MACOSX) + $(CP) -f data/$(@F) $(@D) +#else cd $(@D);$(LN) ../share/lib/$(@F) $(@F) +#endif #endif #if defined(CERNLIB_VAXVMS) diff -Naur cernlib2003.orig/geant321/gxint/Imakefile cernlib2003.new/geant321/gxint/Imakefile --- cernlib2003.orig/geant321/gxint/Imakefile 1997-01-29 08:37:40.000000000 -0800 +++ cernlib2003.new/geant321/gxint/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -30,7 +30,7 @@ gxint321.f: gxint.F RemoveFile($@) - $(CPP) $(FORTRANALLDEFMDEPEND) < $^ | sed -e '/^$$/d' | CppSedMagic >$@ + FortranCmd -E $(FORTRANALLDEFMDEPEND) $^ | sed -e '/^$$/d' | CppSedMagic >$@ install.lib:: $(CERN_LIBDIR)/gxint.f diff -Naur cernlib2003.orig/mathlib/gen/tests/c327m.F cernlib2003.new/mathlib/gen/tests/c327m.F --- cernlib2003.orig/mathlib/gen/tests/c327m.F 1996-04-01 07:01:17.000000000 -0800 +++ cernlib2003.new/mathlib/gen/tests/c327m.F 2003-12-29 11:21:25.000000000 -0800 @@ -92,7 +92,11 @@ #endif ENDIF WRITE(Z,'(2D26.16)') H,T +#if defined(CERNLIB_MACOSX) + READ(Z,'(2(4X,D22.16))') H1,T1 +#else READ(Z,'(2(D22.16,4X))') H1,T1 +#endif IF(IDS .EQ. 1) THEN ERRMAX=MAX(ERRMAX,ABS(H1-T1)) LTEST= LTEST .AND. ERRMAX .LE. TSTERR diff -Naur cernlib2003.orig/mathlib/gen/tests/c342m.F cernlib2003.new/mathlib/gen/tests/c342m.F --- cernlib2003.orig/mathlib/gen/tests/c342m.F 1996-04-01 07:01:19.000000000 -0800 +++ cernlib2003.new/mathlib/gen/tests/c342m.F 2003-12-29 11:21:25.000000000 -0800 @@ -70,7 +70,11 @@ #endif END IF WRITE(Z,'(2D26.16)') R,T +#if defined(CERNLIB_MACOSX) + READ(Z,'(2(4X,D22.16))') R1,T1 +#else READ(Z,'(2(D22.16,4X))') R1,T1 +#endif ERMAX= MAX(ERMAX,ABS(R1-T1)) IF(IDS .EQ. 3 .OR. IDS .EQ. 4) THEN WRITE(LOUT,'(1X,F10.3,2F25.16,1P,D10.1)') SX,R,T,ABS(R1-T1) diff -Naur cernlib2003.orig/mclibs/cojets/data/Imakefile cernlib2003.new/mclibs/cojets/data/Imakefile --- cernlib2003.orig/mclibs/cojets/data/Imakefile 1996-03-27 01:31:06.000000000 -0800 +++ cernlib2003.new/mclibs/cojets/data/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -1,11 +1,11 @@ .SUFFIXES: -CopyFile(cojets.cpp,cojets.cin) +CopyFile(cojets.cpp,cojets.s) CopyFile(decay.cpp,decay.cin) CopyFile(table.cpp,table.cin) -CppFileTarget(cojets.dat,cojets.cin,NullParameter,table.cin decay.cin) +CppFileTarget(cojets.dat,cojets.s,-E -traditional,table.cin decay.cin) PackageDirFileTarget(cojets.dat) diff -Naur cernlib2003.orig/mclibs/isajet/data/Imakefile cernlib2003.new/mclibs/isajet/data/Imakefile --- cernlib2003.orig/mclibs/isajet/data/Imakefile 1996-03-27 01:33:19.000000000 -0800 +++ cernlib2003.new/mclibs/isajet/data/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -1,9 +1,9 @@ .SUFFIXES: -CopyFile(decay.cpp,decay.cin) +CopyFile(decay.cpp,decay.s) -CppFileTarget(isajet.dat,decay.cin,NullParameter,NullParameter) +CppFileTarget(isajet.dat,decay.s,-E -traditional ,NullParameter) PackageDirFileTarget(isajet.dat) diff -Naur cernlib2003.orig/mclibs/jetset/pythia/Imakefile cernlib2003.new/mclibs/jetset/pythia/Imakefile --- cernlib2003.orig/mclibs/jetset/pythia/Imakefile 2001-04-04 07:54:39.000000000 -0700 +++ cernlib2003.new/mclibs/jetset/pythia/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -15,4 +15,8 @@ FDEBUGFLAGS := $(FDEBUGFLAGS) -Nn15000 #endif +#if defined(CERNLIB_PPC) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + SubdirLibraryTarget(NullParameter,NullParameter) diff -Naur cernlib2003.orig/mclibs/pythia/code/Imakefile cernlib2003.new/mclibs/pythia/code/Imakefile --- cernlib2003.orig/mclibs/pythia/code/Imakefile 2002-04-10 09:03:21.000000000 -0700 +++ cernlib2003.new/mclibs/pythia/code/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -36,4 +36,9 @@ FDEBUGFLAGS := $(FDEBUGFLAGS) -Nn15000 #endif +#if defined(CERNLIB_PPC) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + SubdirLibraryTarget(NullParameter,NullParameter) + diff -Naur cernlib2003.orig/packlib/Imakefile cernlib2003.new/packlib/Imakefile --- cernlib2003.orig/packlib/Imakefile 1997-10-02 07:09:19.000000000 -0700 +++ cernlib2003.new/packlib/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -6,11 +6,11 @@ LIBDIRS= cspack epio fatmen ffread hbook hepdb kapack kuip \ @@\ minuit zbook zebra kernlib -SUBDIRS= $(LIBDIRS) +SUBDIRS= $(LIBDIRS) cuserid TopOfPackage(packlib) -SubdirLibraryTarget(packlib,$(LIBDIRS)) +SubdirLibraryTarget(packlib,$(SUBDIRS)) InstallLibrary(packlib,$(CERN_LIBDIR)) InstallLibraryAlias(packlib,packlib-shift,$(CERN_LIBDIR)) diff -Naur cernlib2003.orig/packlib/cspack/sysreq/log.c cernlib2003.new/packlib/cspack/sysreq/log.c --- cernlib2003.orig/packlib/cspack/sysreq/log.c 2003-09-02 09:51:53.000000000 -0700 +++ cernlib2003.new/packlib/cspack/sysreq/log.c 2003-12-29 11:21:25.000000000 -0800 @@ -80,9 +80,9 @@ static int pid; /* process identifier */ static int logfd ; /* logging file descriptor */ #if !defined(SOLARIS) && !defined(linux) && !defined(_AIX) \ - && !defined(IRIX5) && !defined(apollo) + && !defined(IRIX5) && !defined(apollo) && !defined(__DARWIN__) extern int syslog(); -#endif /* !SOLARIS && !IRIX5 && !apollo && !linux && !AIX */ +#endif /* !SOLARIS && !IRIX5 && !apollo && !linux && !AIX && __DARWIN__ */ extern char *getenv(); #else /* VM */ static char *console="CONSOLE";/* VM default console userid */ diff -Naur cernlib2003.orig/packlib/cspack/tcpaw/tcpaw.c cernlib2003.new/packlib/cspack/tcpaw/tcpaw.c --- cernlib2003.orig/packlib/cspack/tcpaw/tcpaw.c 1999-09-15 09:19:46.000000000 -0700 +++ cernlib2003.new/packlib/cspack/tcpaw/tcpaw.c 2003-12-29 11:21:25.000000000 -0800 @@ -2533,7 +2533,7 @@ #if !defined(IBM) && !defined(_WIN32) /* I provide "getpass" myself as standard version truncates to 8 characters */ #include -#ifdef CBREAK +#if defined(CBREAK) || defined(CERNLIB_MACOSX) #define BSDTTY /* First find out if BSD or SYSV terminal handling.. */ #endif @@ -2541,6 +2541,10 @@ #include #else #include +# if defined(CERNLIB_MACOSX) +# define gtty(x,y) ioctl(x,TIOCGETP,y) +# define stty(x,y) ioctl(x,TIOCSETP,y) +# endif #endif #ifndef __convexc__ diff -Naur cernlib2003.orig/packlib/cuserid/Imakefile cernlib2003.new/packlib/cuserid/Imakefile --- cernlib2003.orig/packlib/cuserid/Imakefile 1969-12-31 16:00:00.000000000 -0800 +++ cernlib2003.new/packlib/cuserid/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -0,0 +1,3 @@ +SRCS_C= cuserid.c + +SubdirLibraryTarget(NullParameter,NullParameter) diff -Naur cernlib2003.orig/packlib/cuserid/cuserid.c cernlib2003.new/packlib/cuserid/cuserid.c --- cernlib2003.orig/packlib/cuserid/cuserid.c 1969-12-31 16:00:00.000000000 -0800 +++ cernlib2003.new/packlib/cuserid/cuserid.c 2003-12-29 11:21:25.000000000 -0800 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.1 (the "License"). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. + * + * The Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include + +char * +cuserid(s) + char *s; +{ + register struct passwd *pwd; + + if ((pwd = getpwuid(geteuid())) == NULL) { + if (s) + *s = '\0'; + return (s); + } + if (s) { + (void)strncpy(s, pwd->pw_name, L_cuserid); + return (s); + } + return (pwd->pw_name); +} diff -Naur cernlib2003.orig/packlib/kernlib/kernbit/z268/systems.c cernlib2003.new/packlib/kernlib/kernbit/z268/systems.c --- cernlib2003.orig/packlib/kernlib/kernbit/z268/systems.c 1998-08-25 05:45:56.000000000 -0700 +++ cernlib2003.new/packlib/kernlib/kernbit/z268/systems.c 2003-12-29 11:21:25.000000000 -0800 @@ -200,7 +200,7 @@ || defined(_IBMR2) \ || defined(__convexc__) \ || defined(_OSK) \ -|| defined(__linux) || defined(__FreeBSD__) +|| defined(__linux) || defined(__FreeBSD__) || defined(__DARWIN__) void systems_( command, buf, buflen, l, chars, rc, ovflw ) diff -Naur cernlib2003.orig/packlib/kernlib/kernnum/d704fort/Imakefile cernlib2003.new/packlib/kernlib/kernnum/d704fort/Imakefile --- cernlib2003.orig/packlib/kernlib/kernnum/d704fort/Imakefile 1996-06-12 03:03:53.000000000 -0700 +++ cernlib2003.new/packlib/kernlib/kernnum/d704fort/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -4,6 +4,10 @@ FDEBUGFLAGS=NoOpFortranDebugFlags #endif +#if defined(CERNLIB_MACOSX) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + FORTRANSAVEOPTION=FortranSaveFlags SubdirLibraryTarget(NullParameter,NullParameter) diff -Naur cernlib2003.orig/packlib/kernlib/kernnum/f002fort/Imakefile cernlib2003.new/packlib/kernlib/kernnum/f002fort/Imakefile --- cernlib2003.orig/packlib/kernlib/kernnum/f002fort/Imakefile 1996-06-12 03:04:09.000000000 -0700 +++ cernlib2003.new/packlib/kernlib/kernnum/f002fort/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -10,6 +10,10 @@ FDEBUGFLAGS=NoOpFortranDebugFlags #endif +#if defined(CERNLIB_MACOSX) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + FORTRANSAVEOPTION=FortranSaveFlags SubdirLibraryTarget(NullParameter,NullParameter) diff -Naur cernlib2003.orig/packlib/kernlib/kernnum/f003fort/Imakefile cernlib2003.new/packlib/kernlib/kernnum/f003fort/Imakefile --- cernlib2003.orig/packlib/kernlib/kernnum/f003fort/Imakefile 1996-06-12 03:04:12.000000000 -0700 +++ cernlib2003.new/packlib/kernlib/kernnum/f003fort/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -11,6 +11,10 @@ FDEBUGFLAGS=NoOpFortranDebugFlags #endif +#if defined(CERNLIB_MACOSX) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + FORTRANSAVEOPTION=FortranSaveFlags SubdirLibraryTarget(NullParameter,NullParameter) diff -Naur cernlib2003.orig/packlib/kernlib/kernnum/f004fort/Imakefile cernlib2003.new/packlib/kernlib/kernnum/f004fort/Imakefile --- cernlib2003.orig/packlib/kernlib/kernnum/f004fort/Imakefile 1996-06-12 03:04:16.000000000 -0700 +++ cernlib2003.new/packlib/kernlib/kernnum/f004fort/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -6,6 +6,10 @@ FDEBUGFLAGS=NoOpFortranDebugFlags #endif +#if defined(CERNLIB_MACOSX) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + FORTRANSAVEOPTION=FortranSaveFlags SubdirLibraryTarget(NullParameter,NullParameter) diff -Naur cernlib2003.orig/packlib/kernlib/kernnum/f010fort/Imakefile cernlib2003.new/packlib/kernlib/kernnum/f010fort/Imakefile --- cernlib2003.orig/packlib/kernlib/kernnum/f010fort/Imakefile 1996-06-12 03:04:19.000000000 -0700 +++ cernlib2003.new/packlib/kernlib/kernnum/f010fort/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -7,6 +7,10 @@ FDEBUGFLAGS=NoOpFortranDebugFlags #endif +#if defined(CERNLIB_MACOSX) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + FORTRANSAVEOPTION=FortranSaveFlags diff -Naur cernlib2003.orig/packlib/kernlib/kernnum/f011fort/Imakefile cernlib2003.new/packlib/kernlib/kernnum/f011fort/Imakefile --- cernlib2003.orig/packlib/kernlib/kernnum/f011fort/Imakefile 1996-06-12 03:04:24.000000000 -0700 +++ cernlib2003.new/packlib/kernlib/kernnum/f011fort/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -7,6 +7,10 @@ FDEBUGFLAGS=NoOpFortranDebugFlags #endif +#if defined(CERNLIB_MACOSX) +FDEBUGFLAGS := -O0 $(FDEBUGFLAGS) +#endif + FORTRANSAVEOPTION=FortranSaveFlags SubdirLibraryTarget(NullParameter,NullParameter) diff -Naur cernlib2003.orig/packlib/kuip/kuip/ksys.h cernlib2003.new/packlib/kuip/kuip/ksys.h --- cernlib2003.orig/packlib/kuip/kuip/ksys.h 1997-09-02 07:50:01.000000000 -0700 +++ cernlib2003.new/packlib/kuip/kuip/ksys.h 2003-12-29 11:21:25.000000000 -0800 @@ -188,6 +188,17 @@ #endif +#ifdef CERNLIB_MACOSX +# define MACOSX +# define MACHINE_NAME "MACOSX" +# define UNIX +# define HAVE_MEMMOVE +# define HAVE_STRCASECMP +# define HAVE_SELECT +# define MATCH_RE_COMP /* use re_comp/re_exec */ +#endif + + #ifdef MSDOS # define MACHINE_NAME "IBMPC" # define OS_NAME "MSDOS" diff -Naur cernlib2003.orig/pawlib/comis/code/csaddr.F cernlib2003.new/pawlib/comis/code/csaddr.F --- cernlib2003.orig/pawlib/comis/code/csaddr.F 1996-02-26 09:16:25.000000000 -0800 +++ cernlib2003.new/pawlib/comis/code/csaddr.F 2003-12-29 11:21:25.000000000 -0800 @@ -26,7 +26,11 @@ I=CSLTGP(IPVS) IF(I.GT.0)THEN IF(IFCS.EQ.0)THEN +#if defined(CERNLIB_MACOSX) + IADGP=CS_GET_FUNC('_'//NAME(1:NC)//'_') +#else IADGP=CS_GET_FUNC(NAME(1:NC)//'_') +#endif IF(IADGP.NE.0)THEN IFCS=-2 CALL CSRTGP(I) @@ -35,7 +39,11 @@ ENDIF ENDIF ELSE +#if defined(CERNLIB_MACOSX) + IADGP=CS_GET_FUNC('_'//NAME(1:NC)//'_') +#else IADGP=CS_GET_FUNC(NAME(1:NC)//'_') +#endif IF(IADGP.NE.0)THEN IFCS=-2 ITYPGP=-2 diff -Naur cernlib2003.orig/pawlib/comis/code/cscrexec.F cernlib2003.new/pawlib/comis/code/cscrexec.F --- cernlib2003.orig/pawlib/comis/code/cscrexec.F 2000-09-25 07:16:36.000000000 -0700 +++ cernlib2003.new/pawlib/comis/code/cscrexec.F 2003-12-29 11:21:25.000000000 -0800 @@ -175,10 +175,16 @@ + // NAME(:LN) //'.sl '// NAME(:LN) //'.o' ENDIF #endif -#if defined(CERNLIB_LINUX) +#if defined(CERNLIB_LINUX) && !defined(CERNLIB_MACOSX) CHLINE= 'ld -shared -o ' + // NAME(:LN) //'.sl '// NAME(:LN) //'.o' #endif +#if defined(CERNLIB_MACOSX) + CHLINE= 'g77 -o ' + + // NAME(:LN) //'.sl '// NAME(:LN) //'.o' + + // ' -bundle -bind_at_load' + + // ' -bundle_loader @PREFIX@/bin/pawX11' +#endif #if defined(CERNLIB_ALPHA_OSF) CHLINE= 'ld -shared -o ' + // NAME(:LN) //'.sl '// NAME(:LN) //'.o \\' diff -Naur cernlib2003.orig/pawlib/paw/programs/Imakefile cernlib2003.new/pawlib/paw/programs/Imakefile --- cernlib2003.orig/pawlib/paw/programs/Imakefile 2002-04-25 03:20:11.000000000 -0700 +++ cernlib2003.new/pawlib/paw/programs/Imakefile 2003-12-29 11:21:25.000000000 -0800 @@ -9,7 +9,7 @@ EXTRA_LDOPTIONS=-Wl,-E #endif -#if defined(CERNLIB_LINUX) +#if defined(CERNLIB_LINUX) && !defined(CERNLIB_MACOSX) EXTRA_LDOPTIONS=-Wl,-E #endif diff -Naur cernlib2003.orig/scripts/cernlib cernlib2003.new/scripts/cernlib --- cernlib2003.orig/scripts/cernlib 2003-01-23 06:02:04.000000000 -0800 +++ cernlib2003.new/scripts/cernlib 2003-12-29 11:27:36.000000000 -0800 @@ -31,7 +31,7 @@ - CERNLIB="" + CERNLIB="-L${CERN_ROOT}/lib" liblist=`echo $* | sed -e 's/,/ /g'` for lib in $liblist @@ -44,17 +44,16 @@ val=`echo $lib | sed -e "s?\/? ?g"` set - $val [ $# -eq 2 -a $1 != "graflib" ] && lver=$2 - dir=$CERN/$lver/lib ln=$1 if [ $1 = "kernlib" -o $1 = "packlib" ] ; then _p=1 fi - [ $1 = "genlib" ] && ln="mathlib.a $dir/libphtools" + [ $1 = "genlib" ] && ln="mathlib -lphtools" [ $1 = "bvsl" ] && ln="mathlib" [ $1 = "mpalib" ] && ln="mathlib" - [ $1 = "lapack" ] && ln="lapack3.a $dir/libblas" - [ $1 = "pawlib" ] && ln="pawlib.a $dir/liblapack3.a $dir/libblas" - [ $1 = "pythia" ] && ln="jetset" + [ $1 = "lapack" ] && ln="LAPACK -lBLAS -L/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Versions/A/" + [ $1 = "pawlib" ] && ln="pawlib -lLAPACK -lBLAS -L/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Versions/A/" + [ $1 = "pythia" ] && ln="jetset74" if [ $1 = "GKS" -o $1 = "gks" ] ; then drv="X11" ; glib="$1" ; dir="$CERN/gks/$lver/lib" fi @@ -67,11 +66,11 @@ fi [ $# -eq 3 ] && dir="$CERN/$3/lib" [ $drv = "Motif" ] && drv="X11" - ln="$ln.a $dir/libgraf$drv" + ln="$ln -lgraf$drv" fi - CERNLIB="$CERNLIB $dir/lib$ln.a" + CERNLIB="$CERNLIB -l$ln" done - [ $_p -eq 0 ] && CERNLIB="$CERNLIB $CERN/$gver/lib/libpacklib.a" + [ $_p -eq 0 ] && CERNLIB="$CERNLIB -lpacklib" # get system name [ -d /NextAdmin ] && Msys="NeXT" || Msys=`uname -s` @@ -116,6 +115,9 @@ [ -d /usr/X11R6/lib ] && SYSGMOTIF="-L/usr/X11R6/lib -lXm -lXt -lXp -lXext -lX11" [ `uname -m` = ppc ] && SYSGMOTIF="$SYSGMOTIF -lSM -lICE -lXpm" ;; + Darwin) [ -d /usr/X11R6/lib ] && SYSGX11="-L/usr/X11R6/lib -lX11" + [ -d /usr/X11R6/lib ] && SYSGMOTIF="-L/usr/X11R6/lib -lXm -lXt -lXp -lXext -lX11 -lSM -lICE -lXpm" + ;; NeXT) SYSGX11="/usr/lib/X11/libX11.r" ; SYSGMOTIF="-lXm -lXt /usr/lib/X11/libX11.r" ;; OSF1) SYSGX11="-lX11 -ldnet_stub" ; @@ -209,6 +211,9 @@ if [ "$Msys" = "Linux" ] ; then CERNLIB="$CERNLIB -lnsl -lcrypt -ldl" fi + if [ "$Msys" = "Darwin" ] ; then + CERNLIB="$CERNLIB -lSystem" + fi fi diff -Naur cernlib2003.orig/scripts/gxint cernlib2003.new/scripts/gxint --- cernlib2003.orig/scripts/gxint 1995-05-29 05:18:41.000000000 -0700 +++ cernlib2003.new/scripts/gxint 2003-12-29 11:21:25.000000000 -0800 @@ -78,7 +78,7 @@ fi fi -drv="/X11" ; ver="pro" ; OUT="/tmp/GEANT$$" +drv="/X11" ; ver="" ; OUT="${HOME}/GEANT$$" gxint="" while [ $# -gt 0 ] diff -Naur cernlib2003.orig/packlib/kuip/code_kuip/Imakefile cernlib2003.new/packlib/kuip/code_kuip/Imakefile --- cernlib2003.orig/packlib/kuip/code_kuip/Imakefile 1999-11-24 01:52:07.000000000 -0800 +++ cernlib2003.new/packlib/kuip/code_kuip/Imakefile 2004-01-31 17:31:27.000000000 -0800 @@ -3,7 +3,7 @@ SRCS_C= getline.c kalias.c kbrow.c kedit.c kexec.c khash.c kicon.c \ @@\ kienbr.c kipiaf.c kkern.c kmacro.c kmath.c kmenu.c kmisc.c \ @@\ kmodel.c kmterm.c kuinit.c kutrue.c kuvers.c kuwhag.c \ @@\ - kuwhat.c kvect.c + kuwhat.c kvect.c re.c #ifdef CERNLIB_WINNT SRCS_C :=$(SRCS_C) kmutil0.c diff -Naur cernlib2003.orig/packlib/kuip/code_kuip/re.c cernlib2003.new/packlib/kuip/code_kuip/re.c --- cernlib2003.orig/packlib/kuip/code_kuip/re.c 1969-12-31 16:00:00.000000000 -0800 +++ cernlib2003.new/packlib/kuip/code_kuip/re.c 2004-01-31 17:30:53.000000000 -0800 @@ -0,0 +1,29 @@ +#include +#include + +static regex_t reg; + +char * +re_comp(s) +char *s; +{ + int i; + static char errbuf[81]; + i = regcomp(®, s, REG_BASIC|REG_NOSUB); + + if (!i) return (char *)0; + + regerror(i, ®, errbuf, sizeof(errbuf)); + return errbuf; +} + +int +re_exec(s) +char *s; +{ + int i; + + i = regexec(®, s, (size_t) 0, (regmatch_t *)0, 0); + + return !i; +} diff -Naur cernlib2003.orig/mclibs/lepto63/test/demo.F cernlib2003.new/mclibs/lepto63/test/demo.F --- cernlib2003.orig/mclibs/lepto63/test/demo.F Mon Dec 2 20:05:18 2002 +++ cernlib2003.new/mclibs/lepto63/test/demo.F Wed Jan 14 22:20:23 2004 @@ -42,7 +42,7 @@ DATA PE/20*820.0/ DATA LE/20*-27.5/ C - EXTERNAL LUDATA,PYDATA + EXTERNAL LUDATA,PYDATA,LEPTOD C...Set cuts LST(3)=0 CUT(7)=100. diff -Naur cernlib2003.orig/mclibs/lepto63/test/demo2.F cernlib2003.new/mclibs/lepto63/test/demo2.F --- cernlib2003.orig/mclibs/lepto63/test/demo2.F Mon Dec 2 20:05:19 2002 +++ cernlib2003.new/mclibs/lepto63/test/demo2.F Wed Jan 14 22:20:36 2004 @@ -7,7 +7,7 @@ COMMON/LUJETS/N,K(4000,5),P(4000,5),V(4000,5) DATA NPRINT/10/,NEVENT/100/ C - EXTERNAL LUDATA,PYDATA + EXTERNAL LUDATA,PYDATA,LEPTOD C...Settings CUT(5)=10. CUT(7)=25. --- cernlib2003.orig/scripts/gxint Thu Aug 19 17:49:55 2004 +++ cernlib2003.new/scripts/gxint Fri Aug 27 17:36:48 2004 @@ -156,7 +156,7 @@ $line EoD -$LDN -o $OUT $gxint $pgm $userpath $userlibs `cernlib -v $ver $CLIB`; cc=$? +$LDN -o $OUT $gxint $pgm $userpath $userlibs `cernlib $CLIB`; cc=$? [ $cc -ne 0 ] && exit $cc diff -urN src.orig/config/Amoeba.cf src/config/Amoeba.cf --- src.orig/config/Amoeba.cf 1995-12-20 10:26:47.000000000 -0500 +++ src/config/Amoeba.cf 2005-03-05 20:23:01.427930235 -0500 @@ -309,7 +309,8 @@ #ifndef InstallManPageAliases #define InstallManPageAliases(file,destdir,aliases) @@\ install.man:: @@\ - @(TMP=/tmp/tmp.$$$$; \ @@\ + @(TMP=$(DESTDIR)destdir/file.$(MANSUFFIX).$$$$; \ @@\ + $(MKXDIRHIER) `dirname $${TMP}` ; \ @@\ $(RM) $${TMP}; \ @@\ echo .so `basename destdir`/file.$(MANSUFFIX) > $${TMP}; \ @@\ for i in aliases; do (set -x; \ @@\ diff -urN src.orig/config/Imake.rules src/config/Imake.rules --- src.orig/config/Imake.rules 2000-04-19 06:51:00.000000000 -0400 +++ src/config/Imake.rules 2005-03-05 20:23:01.490921927 -0500 @@ -999,7 +999,8 @@ #ifndef InstallManPageAliases #define InstallManPageAliases(file,destdir,aliases) @@\ install.man:: @@\ - @(TMP=/tmp/tmp.$$$$; \ @@\ + @(TMP=$(DESTDIR)destdir/file.$(MANSUFFIX).$$$$; \ @@\ + $(MKDIRHIER) `dirname $${TMP}` ; \ @@\ RemoveFile($${TMP}); \ @@\ echo .so `basename destdir`/file.$(MANSUFFIX) > $${TMP}; \ @@\ for i in aliases; do (set -x; \ @@\ diff -urN src.orig/config/NetBSD.cf src/config/NetBSD.cf --- src.orig/config/NetBSD.cf 1995-12-20 10:26:45.000000000 -0500 +++ src/config/NetBSD.cf 2005-03-05 20:23:01.508919554 -0500 @@ -99,9 +99,7 @@ file.0:: file.man @@\ @if [ -f file.man ]; \ @@\ then \ @@\ - cat file.man | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >/tmp/$$$$.man; \ @@\ - cp /tmp/$$$$.man file.0; \ @@\ - $(RM) /tmp/$$$$.man; \ @@\ + cat file.man | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >file.0; \ @@\ fi @@\ @@\ file.man:: @@\ @@ -119,9 +117,10 @@ case '${MFLAGS}' in *[i]*) set +e;; esac; \ @@\ for i in list; do \ @@\ (set -x; \ @@\ - cat $$i.suff | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >/tmp/$$$$.suff; \ @@\ - $(INSTALL) -c $(INSTMANFLAGS) /tmp/$$$$.suff $(DESTDIR)dest/$$i.0; \ @@\ - $(RM) /tmp/$$$$.suff); \ @@\ + TMP=$(DESTDIR)dest/$$$$.suff ; \ @@\ + cat $$i.suff | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >$${TMP}; \ @@\ + $(INSTALL) -c $(INSTMANFLAGS) $${TMP} $(DESTDIR)dest/$$i.0; \ @@\ + $(RM) $${TMP} ); \ @@\ done #define InstallMultipleMan(list,dest) @@\ diff -urN src.orig/config/bsdi.cf src/config/bsdi.cf --- src.orig/config/bsdi.cf 1995-12-20 10:26:44.000000000 -0500 +++ src/config/bsdi.cf 2005-03-05 20:23:01.549914147 -0500 @@ -69,9 +69,7 @@ file.0:: file.man @@\ @if [ -f file.man ]; \ @@\ then \ @@\ - cat file.man | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >/tmp/$$$$.man; \ @@\ - cp /tmp/$$$$.man file.0; \ @@\ - $(RM) /tmp/$$$$.man; \ @@\ + cat file.man | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >file.0; \ @@\ fi @@\ @@\ file.man:: @@\ @@ -89,9 +87,10 @@ case '${MFLAGS}' in *[i]*) set +e;; esac; \ @@\ for i in list; do \ @@\ (set -x; \ @@\ - cat $$i.suff | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >/tmp/$$$$.suff; \ @@\ - $(INSTALL) -c $(INSTMANFLAGS) /tmp/$$$$.suff $(DESTDIR)dest/$$i.0; \ @@\ - $(RM) /tmp/$$$$.suff); \ @@\ + TMP=$(DESTDIR)dest/$$$$.suff ; \ @@\ + cat $$i.suff | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >$${TMP}; \ @@\ + $(INSTALL) -c $(INSTMANFLAGS) $${TMP} $(DESTDIR)dest/$$i.0; \ @@\ + $(RM) $${TMP} ); \ @@\ done #define InstallMultipleMan(list,dest) @@\ diff -urN src.orig/config/ncr.cf src/config/ncr.cf --- src.orig/config/ncr.cf 1995-12-20 10:26:42.000000000 -0500 +++ src/config/ncr.cf 2005-03-05 20:23:01.696894762 -0500 @@ -75,11 +75,11 @@ file.z:: file.man @@\ @if [ -f file.man ]; \ @@\ then \ @@\ - cat file.man | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >/tmp/$$$$.man; \ @@\ - $(RM) /tmp/$$$$.man.z; \ @@\ - pack -f /tmp/$$$$.man; \ @@\ - cp /tmp/$$$$.man.z file.z; \ @@\ - $(RM) /tmp/$$$$.man.z; \ @@\ + cat file.man | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >file.$$$$.man; \ @@\ + $(RM) file.$$$$.man.z; \ @@\ + pack -f file.$$$$.man; \ @@\ + cp file.$$$$.man.z file.z; \ @@\ + $(RM) file.$$$$.man.z; \ @@\ fi @@\ @@\ file.man:: @@\ @@ -97,10 +97,11 @@ case '${MFLAGS}' in *[i]*) set +e;; esac; \ @@\ for i in list; do \ @@\ (set -x; \ @@\ - cat $$i.suff | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >/tmp/$$$$.suff; \ @@\ - pack -f /tmp/$$$$.suff; \ @@\ - $(INSTALL) -c $(INSTMANFLAGS) /tmp/$$$$.suff.z $(DESTDIR)dest/$$i.z; \ @@\ - $(RM) /tmp/$$$$.suff.z); \ @@\ + TMP=$(DESTDIR)dest/$$$$.suff ; \ @@\ + cat $$i.suff | $(NEQN) | $(TBL) | $(NROFF) -man | $(COL) >$${TMP}; \ @@\ + pack -f $${TMP}; \ @@\ + $(INSTALL) -c $(INSTMANFLAGS) $${TMP}.z $(DESTDIR)dest/$$i.z; \ @@\ + $(RM) $${TMP}.z); \ @@\ done #define InstallMultipleMan(list,dest) @@\ diff -urN src.orig/config/x386.cf src/config/x386.cf --- src.orig/config/x386.cf 1995-12-20 10:26:43.000000000 -0500 +++ src/config/x386.cf 2005-03-05 20:23:01.759886454 -0500 @@ -107,9 +107,11 @@ #define InstallManPageLong(file,destdir,dest) @@\ install.man:: file.man @@\ $(RM) destdir/dest.$(MANSUFFIX) @@\ - cat file.man | neqn | nroff -man >/tmp/file.man @@\ - $(INSTALL) -c $(INSTMANFLAGS) /tmp/file.man destdir/dest.$(MANSUFFIX) @@\ - $(RM) /tmp/file.man + TMP=destdir/dest.$$$$.$(MANSUFFIX) ; \ @@\ + $(INSTALL) -c $(INSTMANFLAGS) file.man $${TMP} ; \ @@\ + cat file.man | neqn | nroff -man >$${TMP} ; \ @@\ + $(INSTALL) -c $(INSTMANFLAGS) $${TMP} destdir/dest.$(MANSUFFIX) ; \ @@\ + $(RM) $${TMP} #define InstallMultipleMan(list,dest) @@\ install.man:: list @@\ @@ -117,9 +119,11 @@ for i in list; do \ @@\ (set -x; \ @@\ $(RM) dest/$$i; \ @@\ - cat $$i | neqn | nroff -man >/tmp/$$i; \ @@\ - $(INSTALL) -c $(INSTMANFLAGS) /tmp/$$i dest/$$i; \ @@\ - $(RM) /tmp/$$i); \ @@\ + TMP=dest/$$i.$$$$ ; \ @@\ + $(INSTALL) -c $(INSTMANFLAGS) $$i $${TMP} ; \ @@\ + cat $$i | neqn | nroff -man >$${TMP}; \ @@\ + $(INSTALL) -c $(INSTMANFLAGS) $${TMP} dest/$$i; \ @@\ + $(RM) $${TMP} ); \ @@\ done /* If you have trouble with make bombing out in Xlib, try uncommenting this. */ diff -urN src.orig/packlib/cspack/cz/czopen.F src/packlib/cspack/cz/czopen.F --- src.orig/packlib/cspack/cz/czopen.F 1996-03-08 10:44:23.000000000 -0500 +++ src/packlib/cspack/cz/czopen.F 2005-03-05 20:23:01.000000000 -0500 @@ -40,7 +40,7 @@ CHARACTER*80 SERVICE #endif #if (defined(CERNLIB_APOLLO))&&(defined(CERNLIB__LOG)) - CHARACTER*22 CHFILE + CHARACTER*26 CHFILE #endif EXTERNAL CZTCP @@ -82,8 +82,8 @@ CHFILE=' ' CALL DATIME(ND,NT) WRITE(CHFILE,1000)ND,NT - 1000 FORMAT('/tmp/cz',I6,I4,'.log') - DO 10 I=7,19 + 1000 FORMAT('/var/log/cz',I6,I4,'.log') + DO 10 I=11,23 IF(CHFILE(I:I).EQ.' ')CHFILE(I:I)='0' 10 CONTINUE OPEN(UNIT=LUNCZ,FILE=CHFILE,STATUS='UNKNOWN') diff -urN src.orig/packlib/cspack/doc/config/sysreq.txt src/packlib/cspack/doc/config/sysreq.txt --- src.orig/packlib/cspack/doc/config/sysreq.txt 1996-03-08 10:44:18.000000000 -0500 +++ src/packlib/cspack/doc/config/sysreq.txt 2005-03-05 20:23:01.000000000 -0500 @@ -20,8 +20,8 @@ SYSREQ TRACE yes # Trace flag # MSG HOST sun2 # message daemon host name -MSG LOGR /usr/tmp/msgr.log # msgr log file -MSG LOGI /usr/tmp/msgi.log # msgi log file +MSG LOGR /var/log/msgr.log # msgr log file +MSG LOGI /var/log/msgi.log # msgi log file # NET shift1 shift1-u # Use alternate host name NET shd01 shd01-u # Use alternate host name diff -urN src.orig/packlib/cspack/programs/zs/zs.F src/packlib/cspack/programs/zs/zs.F --- src.orig/packlib/cspack/programs/zs/zs.F 1997-10-21 13:11:54.000000000 -0400 +++ src/packlib/cspack/programs/zs/zs.F 2005-03-05 20:23:02.000000000 -0500 @@ -59,7 +59,7 @@ #if !defined(CERNLIB_IBM)||defined(CERNLIB_TCPSOCK) INTEGER STATUS INTEGER SSETUP,SCLOSE - CHARACTER*22 CHFILE + CHARACTER*26 CHFILE #endif #if defined(CERNLIB_IBM) CHARACTER*80 ARGS @@ -88,8 +88,8 @@ CHFILE=' ' CALL DATIME(ND,NT) WRITE(CHFILE,1000)ND,NT - 1000 FORMAT('/tmp/zs',I6,I4,'.log') - DO 1 I=7,19 + 1000 FORMAT('/var/log/zs',I6,I4,'.log') + DO 1 I=11,23 IF(CHFILE(I:I).EQ.' ')CHFILE(I:I)='0' 1 CONTINUE OPEN(UNIT=LUNCZ,FILE=CHFILE,STATUS='UNKNOWN',IOSTAT=ISTAT) diff -urN src.orig/packlib/cspack/tcpaw/tcpaw.c src/packlib/cspack/tcpaw/tcpaw.c --- src.orig/packlib/cspack/tcpaw/tcpaw.c 1999-09-15 12:19:46.000000000 -0400 +++ src/packlib/cspack/tcpaw/tcpaw.c 2005-03-05 20:23:02.000000000 -0500 @@ -27,7 +27,7 @@ /*#define LOGFILE "disk$dd:-ben.socks-serv.log"*/ /* VMS */ /*#define LOGFILE "/user/brun/ben/serv.log" */ /* Apollo */ /*#define LOGFILE "/h0/psh/zs.log" */ /* OS9 */ -/*#define LOGFILE "/tmp/serv.log" */ /* example*/ +/*#define LOGFILE "/var/log/serv.log" */ /* example*/ #if defined(CERNLIB_IBMMVS) #pragma nosequence #pragma options (ALIAS) @@ -351,7 +351,7 @@ #endif /* OSK */ #ifndef LOGFILE #include "cspack/tcplog.h" -/*#define LOGFILE "/tmp/serv.log" */ /* CUSTOMIZE THIS.. */ +/*#define LOGFILE "/var/log/serv.log" */ /* CUSTOMIZE THIS.. */ #endif /* LOGFILE */ #endif /* SERVLOG */ #endif /* DEBUG */ diff -urN src.orig/packlib/cspack/tcpaw/tcpold.c src/packlib/cspack/tcpaw/tcpold.c --- src.orig/packlib/cspack/tcpaw/tcpold.c 1996-03-08 10:44:28.000000000 -0500 +++ src/packlib/cspack/tcpaw/tcpold.c 2005-03-05 20:23:02.000000000 -0500 @@ -12,7 +12,7 @@ /*#define LOGFILE "disk$dd:-ben.socks-serv.log"*/ /* VMS */ /*#define LOGFILE "/user/brun/ben/serv.log" */ /* Apollo */ /*#define LOGFILE "/h0/psh/zs.log" */ /* OS9 */ -/*#define LOGFILE "/tmp/serv.log" */ /* example*/ +/*#define LOGFILE "/var/log/serv.log" */ /* example*/ #if defined(CERNLIB__DOC) /* TCP/IP PACKAGE FOR REMOTE-PAW AND SIMILAR APPLICATIONS. @@ -218,7 +218,7 @@ #endif /* OSK */ #ifndef LOGFILE #include "cspack/tcplog.h" -/*#define LOGFILE "/tmp/serv.log" */ /* CUSTOMIZE THIS.. */ +/*#define LOGFILE "/var/log/serv.log" */ /* CUSTOMIZE THIS.. */ #endif /* LOGFILE */ #endif /* SERVLOG */ #endif /* DEBUG */ diff -urN src.orig/packlib/hepdb/scripts/unix/ctab_root.dat src/packlib/hepdb/scripts/unix/ctab_root.dat --- src.orig/packlib/hepdb/scripts/unix/ctab_root.dat 1996-04-16 06:09:09.000000000 -0400 +++ src/packlib/hepdb/scripts/unix/ctab_root.dat 2005-03-05 20:23:02.000000000 -0500 @@ -20,5 +20,5 @@ # # Special check for cdmove # -30 * * * * /afs/cern.ch/project/hepdb/scripts/cdmovechk >> /tmp/cdmovechk.log 2>&1 +30 * * * * /afs/cern.ch/project/hepdb/scripts/cdmovechk >> /var/log/cdmovechk.log 2>&1 42 8,0 * * * ( /usr/lpp/adsm/scripts/cron_adsm.pl ) >/dev/null 2>&1 diff -urN src.orig/packlib/kuip/code_kuip/kedit.c src/packlib/kuip/code_kuip/kedit.c --- src.orig/packlib/kuip/code_kuip/kedit.c 1997-03-17 11:54:57.000000000 -0500 +++ src/packlib/kuip/code_kuip/kedit.c 2005-03-05 20:23:02.000000000 -0500 @@ -24,6 +24,7 @@ static char *editor_cmd = NULL; /* command which envoked edit server */ static char *editor_file = NULL; /* file which was edited */ +static char editor_tmp[22]; /* file to use as a lock file */ /* @@ -164,8 +165,26 @@ if( use_server && kc_flags.use_server ) { #if defined(UNIX) && !defined(CERNLIB_WINNT) + int fid; + + /* Try to securely create the temporary file for the edit server. + * Has to be done in the parent process because the server has no + * way of passing back the name of a created temp file. */ + strcpy( editor_tmp, "/usr/tmp/kuesvrXXXXXX" ); + fid = mkstemp( editor_tmp ); + if (fid == -1) { + strcpy( editor_tmp, "/tmp/kuesvrXXXXXX" ); + fid = mkstemp( editor_tmp ); + if (fid == -1) { + perror( "mkstemp" ); + return status; + } + } + close( fid ); + line = strdup( "kuesvr -p " ); line = mstricat( line, getpid() ); + line = mstr2cat( line, " -t ", editor_tmp ); line = mstr4cat( line, " -c ", ku_path(), " -e '", kc_value.set_host_editor ); if( (p = strrchr( line, '&' )) != NULL ) @@ -355,6 +374,15 @@ } +void ku_shut() +{ +#ifdef USE_EDIT_SERVER + if( kc_flags.use_server ) + remove( editor_tmp ); +#endif +} + + void F77_ENTRY_C(Kupad,chfile) /* { */ char *file = fstrdup( chfile, len_chfile ); @@ -523,7 +551,7 @@ #ifdef USE_EDIT_SERVER if( kjmpaddr.user_edit_F != NULL && kc_flags.editor_exit != 0 ) { - char lock_file[64]; + char *lock_file = editor_tmp; int fid; int len; int nbytes; @@ -534,27 +562,16 @@ #ifdef UNIX /* /tmp cannot be locked on Sun if allocated on swap space */ - sprintf( lock_file, "/usr/tmp/kuesvr.%d", (int)getpid() ); fid = open( lock_file, O_RDONLY ); if( fid == -1 ) { - /* we could be using an old server writing to /tmp */ - fid = open( &lock_file[4], O_RDONLY ); - if( fid == -1 ) { - perror( "kugsvr: open /tmp read-only" ); - return; - } - close( fid ); - fid = open( &lock_file[4], O_RDWR ); - if( fid == -1 ) { - perror( "kugsvr: open /tmp read-write" ); - return; - } + perror( "kugsvr: open tempfile read-only" ); + return; } else { close( fid ); fid = open( lock_file, O_RDWR ); if( fid == -1 ) { - perror( "kugsvr: open /usr/tmp read-write" ); + perror( "kugsvr: open tempfile read-write" ); return; } } diff -urN src.orig/packlib/kuip/code_kuip/kuwhat.c src/packlib/kuip/code_kuip/kuwhat.c --- src.orig/packlib/kuip/code_kuip/kuwhat.c 1999-03-10 12:11:52.000000000 -0500 +++ src/packlib/kuip/code_kuip/kuwhat.c 2005-03-05 20:23:02.000000000 -0500 @@ -676,18 +676,6 @@ } -void ku_shut() -{ -#ifdef USE_EDIT_SERVER - if( kc_flags.use_server ) { - char lock_file[64]; - sprintf( lock_file, "/usr/tmp/kuesvr.%d", (int)getpid() ); - if( remove( lock_file ) != 0 ) - remove( &lock_file[4] ); /* old kuesvr used /tmp instead of /usr/tmp */ - } -#endif -} - #ifdef WIN32 void fpcheck( void ) { diff -urN src.orig/packlib/kuip/programs/kuesvr/kuesvr.c src/packlib/kuip/programs/kuesvr/kuesvr.c --- src.orig/packlib/kuip/programs/kuesvr/kuesvr.c 1996-03-08 10:33:05.000000000 -0500 +++ src/packlib/kuip/programs/kuesvr/kuesvr.c 2005-03-05 20:23:02.000000000 -0500 @@ -15,6 +15,7 @@ char *editor = "vi"; char *cmd = '\0'; char *file = '\0'; +char *sfile = '\0'; main(int argc, char **argv) @@ -22,7 +23,6 @@ int c, fid; char *arg; char shcmd[512]; - char sfile[128]; char msg[BUFSIZ]; time_t mtime; struct stat buf; @@ -49,8 +49,13 @@ arg = *++argv; cmd = arg; break; + case 't': + if (*++arg == 0) + arg = *++argv; + sfile = arg; + break; default: - fprintf(stderr,"Usage: kuesvr -p pid -c cmd [-e editor] file\n"); + fprintf(stderr,"Usage: kuesvr -p pid -c cmd -t tmpfile [-e editor] file\n"); exit(1); } } else { @@ -59,8 +64,8 @@ } } - if (!pid || !file || !cmd) { - fprintf(stderr,"Usage: kuesvr -p pid -c cmd [-e editor] file\n"); + if (!pid || !file || !cmd || !sfile) { + fprintf(stderr,"Usage: kuesvr -p pid -c cmd -t tmpfile [-e editor] file\n"); exit(1); } @@ -74,31 +79,14 @@ stat(file, &buf); /* open kuip edit server message file */ - sprintf(sfile, "/usr/tmp/kuesvr.%d", pid); - /* - * Try first /usr/tmp and then /tmp for lock file. - * The lockf() call can fail if the directory is NFS mounted and - * the lockd daemon is not running. - */ - again: - fid = open(sfile, O_CREAT|O_APPEND|O_WRONLY, 0644); + fid = open(sfile, O_CREAT|O_APPEND|O_WRONLY, 0600); if (fid == -1) { - if (sfile[1] == 'u') { - strcpy(sfile, sfile+4); - goto again; - } perror("open"); exit(1); } /* lock the file */ if (lockf(fid, F_LOCK, (off_t)0) == -1) { - if (sfile[1] == 'u') { - close(fid); - remove(sfile); - strcpy(sfile, sfile+4); - goto again; - } perror("lockf"); exit(1); } diff -urN src.orig/packlib/kuip/programs/kxterm/kxterm.c src/packlib/kuip/programs/kxterm/kxterm.c --- src.orig/packlib/kuip/programs/kxterm/kxterm.c 1996-03-08 10:33:04.000000000 -0500 +++ src/packlib/kuip/programs/kxterm/kxterm.c 2005-03-05 20:23:02.000000000 -0500 @@ -645,10 +645,9 @@ void exit_kxterm() { /* close transcript file and if it is a tmp file remove it */ + /* (the result of tmpfile() is removed automatically upon being closed) */ if (tfp) { fclose(tfp); - if (tr_tmp_file) - remove(transcript_file); } exit(0); @@ -1168,32 +1167,34 @@ char *file; { /* - * close the tmp file, move it to user specified file and open it again + * copy the temp file to user specified file, close temp file and open + * user specified file again */ if (tfp) { fflush(tfp); if (!strcmp(transcript_file, file)) return; else { - char line[256]; + char line[MAX_FILE_LENGTH + 50]; + FILE *stream; - fclose(tfp); - if (!(tfp = fopen(file, "w"))) { + if (!(stream = fopen(file, "w"))) { sprintf(line, "Cannot open transcript file %s", file); warn_user(kuipIo, line); } else { /* copy current transcript to new file */ - FILE *stream = fopen(transcript_file, "r"); - while( fgets( line, (sizeof line), stream ) != NULL ) - fputs( line, tfp ); - fclose( stream ); - + rewind( tfp ); + while( fgets( line, (sizeof line), tfp ) != NULL ) + fputs( line, stream ); + fclose( stream ); + fclose( tfp ); + tfp = fopen(file, "a+"); + strcpy(transcript_file, file); + if (tr_tmp_file) { - remove(transcript_file); tr_tmp_file = False; - strcpy(transcript_file, file); } fflush(tfp); } @@ -2684,15 +2685,19 @@ init_kuipio(); /* open tmpfile to save transcript pad */ - tmpnam(transcript_file); - if (!(tfp = fopen(transcript_file, "w+"))) { + if (!(tfp = tmpfile())) { insert_string(outputText, "*** Cannot open tmp file to save transcript pad ***\n", False); XtSetSensitive(saveTransButton, False); XtSetSensitive(saveTransAsButton, False); - } else + } + else { tr_tmp_file = True; + /* since we don't know the filename created by tmpfile(), make it + * the null string: */ + strcpy(transcript_file, ""); + } /* unbuffered I/O */ setbuf(stdin, NULL); diff -urN src.orig/patchy/yexpand.script src/patchy/yexpand.script --- src.orig/patchy/yexpand.script 1994-09-26 07:51:09.000000000 -0400 +++ src/patchy/yexpand.script 2005-03-05 20:23:02.000000000 -0500 @@ -26,7 +26,7 @@ # CERN_ROOT=":$CERN_ROOT" ; export CERN_ROOT CERN_ROOT=":$CERN/$CERN_LEVEL" ; export CERN_ROOT - tfile="/tmp/$tfile.yexp" + tfile="$HOME/$tfile.yexp" echo "#!/bin/sh" >$tfile echo " cat <>$tfile cat <$ifile >>$tfile diff -urN src.orig/pawlib/comis/code/csinit.F src/pawlib/comis/code/csinit.F --- src.orig/pawlib/comis/code/csinit.F 2002-06-19 10:27:59.000000000 -0400 +++ src/pawlib/comis/code/csinit.F 2005-03-05 20:23:02.000000000 -0500 @@ -82,6 +82,7 @@ ITA=0 IDP=0 IFORS=1 + ITMPLEN=0 NCBARR=0 NTRACE=1 NPARAM=1 @@ -163,17 +164,17 @@ JKUVBS=-1 #endif #if (defined(CERNLIB_HPUX))&&(defined(CERNLIB_SHL)) - CHPATH='/tmp/' + ITMPLEN=CSTMPD(CHPATH, 256) CHF77 ='f77 -c +z +ppu' CHCC ='cc -c +z' #endif #if (defined(CERNLIB_IBMRT))&&(defined(CERNLIB_SHL)) - CHPATH='/tmp/' + ITMPLEN=CSTMPD(CHPATH, 256) CHF77 ='xlf -qextname -qrndsngl -qcharlen=32767 -c' CHCC ='cc -c' #endif #if (defined(CERNLIB_SUN))&&(defined(CERNLIB_SOLARIS))&&(defined(CERNLIB_SHL)) - CHPATH='/tmp/' + ITMPLEN=CSTMPD(CHPATH, 256) # if defined(CERNLIB_QFAPOGEE) CHF77 ='apf77 -c -pic' CHCC ='apcc -c -pic' @@ -201,22 +202,22 @@ # endif #endif #if (defined(CERNLIB_SUN))&&(!defined(CERNLIB_SOLARIS))&&(defined(CERNLIB_SHL)) - CHPATH='/tmp/' + ITMPLEN=CSTMPD(CHPATH, 256) CHF77 ='f77 -c -pic' CHCC ='cc -c -pic' #endif #if (defined(CERNLIB_LINUX)) - CHPATH='/tmp/' + ITMPLEN=CSTMPD(CHPATH, 256) CHF77 ='g77 -c' CHCC ='cc -c' #endif #if (defined(CERNLIB_SGI))&&(defined(CERNLIB_SHL)) - CHPATH='/tmp/' + ITMPLEN=CSTMPD(CHPATH, 256) CHF77 ='f77 -c' CHCC ='cc -cckr -c' #endif #if (defined(CERNLIB_ALPHA_OSF))&&(defined(CERNLIB_SHL)) - CHPATH='/tmp/' + ITMPLEN=CSTMPD(CHPATH, 256) CHF77 ='f77 -c' CHCC ='cc -c' #endif diff -urN src.orig/pawlib/comis/deccc/Imakefile src/pawlib/comis/deccc/Imakefile --- src.orig/pawlib/comis/deccc/Imakefile 1999-11-15 08:36:23.000000000 -0500 +++ src/pawlib/comis/deccc/Imakefile 2005-03-05 20:23:02.000000000 -0500 @@ -19,6 +19,10 @@ SRCS_C := $(SRCS_C) cscald.c cscali.c cscalr.c cstrcmp.c ccopys.c #endif +#if defined(CERNLIB_UNIX) +SRCS_C := $(SRCS_C) cstmpd.c +#endif + #if defined(CERNLIB_HPUX) && defined(CERNLIB_SHL) SRCS_C := $(SRCS_C) cs_shl_get.c cs_shl_load.c cs_shl_symbols.c \ @@\ cs_shl_unload.c cs_get_func.c diff -urN src.orig/pawlib/comis/deccc/cstmpd.c src/pawlib/comis/deccc/cstmpd.c --- src.orig/pawlib/comis/deccc/cstmpd.c 1969-12-31 19:00:00.000000000 -0500 +++ src/pawlib/comis/deccc/cstmpd.c 2005-03-05 20:18:29.000000000 -0500 @@ -0,0 +1,180 @@ +/* + * cs_mktmpdir.c + * Author: Kevin McCarty, March 4, 2005 + * Purpose: safely create a temporary directory in UNIX for COMIS to use. + */ + +#if defined(CERNLIB_UNIX) + +# include "comis/pilot.h" +# include +# include +# include +# include +# include +# include +# include + +# if defined(CERNLIB_LINUX) || defined(CERNLIB_BSD) +# define mksafetemp mkdtemp +# else + +/* reimplement mkdtemp() for systems without it */ +static char *mksafetemp(char *template) +{ + int i, len; + char * tempcopy; + FILE * randomfile = fopen("/dev/urandom", "r"); + if (!randomfile) + randomfile = fopen("/dev/random", "r"); + if (!randomfile) + return NULL; + + len = strlen(template); + if (len < 6 || strncmp("XXXXXX", template + len - 6, 6)) { + fclose(randomfile); + errno = EINVAL; + return NULL; + } + + again: + tempcopy = strdup(template); + + for (i = 0; i < 6; i++) { + unsigned char randomchar; + fread(&randomchar, 1, 1, randomfile); + randomchar %= 62; + if (randomchar < 10) + randomchar += '0'; + else if (randomchar < 36) + randomchar += ('A' - 10); + else + randomchar += ('a' - 36); + tempcopy[i + len - 6] = randomchar; + } + + if (mkdir(tempcopy, 0700)) { + free(tempcopy); + if (errno == EEXIST) + goto again; + else { + fclose(randomfile); + return NULL; + } + } + + strcpy(template, tempcopy); + fclose(randomfile); + free(tempcopy); + return template; +} +# endif + + +/* CSTMPD: securely creates a temporary directory for use by COMIS and + * returns the path in "result", a string of available size "length". + * Any initial value in "result" is ignored. + * The return value is the actual length of the directory path. + * + * If a temporary directory previously created in the lifetime of the + * program still exists and has the right owner and permissions (0700), + * it is used instead. + */ + +#if defined(CERNLIB_QX_SC) +# define Cstmpd cstmpd_ +#endif +#if defined(CERNLIB_QXNO_SC) +# define Cstmpd cstmpd +#endif +#if defined(CERNLIB_QXCAPT) +# define Cstmpd CSTMPD +#endif +int type_of_call Cstmpd(char * result, int * length) +{ + static char * current_dir = 0; + int i, mknewdir = 1; + + /* by default (if something goes wrong) return a blank string */ + memset(result, ' ', *length); + + if (current_dir && strlen(current_dir) < *length) { + /* Check whether cached value of current_dir is still a usable + * existing directory. */ + struct stat buf; + + if (lstat(current_dir, &buf) == 0) { + if (buf.st_uid == geteuid() && S_ISDIR(buf.st_mode) + && !S_ISLNK(buf.st_mode) && !(buf.st_mode & S_IWGRP) + && !(buf.st_mode & S_IWOTH)) + mknewdir = 0; + } + } + + /* Create a new temporary directory if necessary. */ + if (mknewdir) { + char * template; + char * tmpdir; + + free(current_dir); + current_dir = malloc(*length); + template = malloc(*length); + if ((tmpdir = getenv("TMPDIR")) && *length > strlen(tmpdir) + 12) + strcpy(template, tmpdir); + else if (*length > 16) + strcpy(template, "/tmp"); + else { + free(template); + free(current_dir); + current_dir = 0; + errno = ENAMETOOLONG; + return 0; + } + strcat(template, "/comisXXXXXX"); + + if (!mksafetemp(template)) { + free(template); + free(current_dir); + current_dir = 0; + return 0; + } + + strcpy(current_dir, template); + } + + /* Put current_dir into result and make sure result is in FORTRAN format + * (no nul, ends with blanks), plus add a trailing slash. */ + strncpy(result, current_dir, *length - 1); + result[strlen(current_dir)] = '/'; + for (i = strlen(current_dir) + 1; i < *length; i++) + result[i] = ' '; + return strlen(current_dir) + 1; +} + +#if 0 +/* test routine */ +int main() +{ + char tmp[26]; + int length, len2; + + for (length = 25; length > 0; length--) { + len2 = Cstmpd(tmp, &length); + tmp[length] = 0; + printf("length %d, tmpdir: `%s'\n", len2, tmp); + tmp[len2] = 0; + rmdir(tmp); + } + + for (length = 25; length > 0; length--) { + len2 = Cstmpd(tmp, &length); + tmp[length] = 0; + printf("length %d, tmpdir: `%s'\n", len2, tmp); + tmp[len2] = 0; + } + + return 0; +} +#endif + +#endif /* CERNLIB_UNIX */ diff -urN src.orig/pawlib/paw/cpaw/bugrep.c src/pawlib/paw/cpaw/bugrep.c --- src.orig/pawlib/paw/cpaw/bugrep.c 1997-03-14 09:06:44.000000000 -0500 +++ src/pawlib/paw/cpaw/bugrep.c 2005-03-05 20:23:02.000000000 -0500 @@ -61,9 +61,10 @@ int ku_edit( char *, int); int ku_npar(); - -#define R_OK 0 -#define R_ERROR 1 +/* changed from R_OK, which already exists in unistd.h and is used for + * something else... */ +#define MAIL_OK 0 +#define MAIL_ERROR 1 static char *br_uname_sysname; @@ -236,24 +237,74 @@ 0 }; +#if defined(CERNLIB_UNIX) && !defined(CERNLIB_WINNT) && !defined(CERNLIB_VAX) +#include +#endif + +/* new function to create a temporary file without having a race condition + * (currently only on UNIX) */ +static char * +br_create_tempfile(void) +{ + static char * result = 0; +#if defined(CERNLIB_UNIX) && !defined(CERNLIB_WINNT) && !defined(CERNLIB_VAX) + int fd; + char *tempdir = getenv("TMPDIR"); + char filename[] = "/bugrepXXXXXX"; + + if ( tempdir && *tempdir ) { + result = (char *)calloc( strlen( tempdir ) + strlen( filename ) + 1, 1 ); + sprintf( result, "%s%s", tempdir, filename ); + } + else { + result = (char *)calloc( strlen( "/tmp" ) + strlen( filename ) + 1, 1 ); + sprintf( result, "/tmp%s", filename ); + } + + if ( (fd = mkstemp(result)) < 0 ) { + /* no need to print an error here as it will be done by other functions */ + free( result ); + result = 0; + } + else + /* don't want to leave open file descriptors about. + * unlike tmpfile(), mkstemp() doesn't delete the file automatically + * when no one is using it, so it's ok to do this */ + close( fd ); + +#else + /* don't know if mkstemp() exists on non-Unix operating systems, and in + * any case the above code won't work because directory separators, etc. + * are different (at least on Windows and VMS) */ + result = (char *)calloc( L_tmpnam, 1 ); + if ( ! tmpnam( result ) /* INSECURE!!! */ ) { + free( result ); + result = 0; + } + +#endif /* defined(CERNLIB_UNIX) */ + + /* note that the file with filename "result" must be remove()d and the + * string "result" free()d by the calling function */ + return result; +} static int -br_create_template( char tmp_file[ L_tmpnam ], char mode ) +br_create_template( char *tmp_file, char mode ) { FILE *fp; char **s; - tmpnam( tmp_file ); - if ( *tmp_file == 0 ) { + if ( tmp_file == 0 || *tmp_file == 0 ) { /* report error */ printf( "BUGREPORT: cannot get temporary file\n" ); - return R_ERROR; + return MAIL_ERROR; } fp = fopen( tmp_file, "w" ); if ( fp == NULL ) { printf( "BUGREPORT: cannot open temporary file\n" ); - return R_ERROR; + return MAIL_ERROR; } for( s = br_tmpl_user; *s ; s++ ) { @@ -273,63 +324,72 @@ fclose( fp ); - return R_OK; + return MAIL_OK; } static int -br_edit_file( int first, char tmp_file[ L_tmpnam ] ) +br_edit_file( int first, char * tmp_file ) { int r, ist; - char buf[L_tmpnam + 1]; + char * buf; + + if ( tmp_file == 0 || *tmp_file == 0 ) + return MAIL_ERROR; /* suppress the adding of .kumac by prepending a - ... */ - + buf = (char *)malloc( strlen(tmp_file) + 2 ); buf[0] = '-'; - strncpy( &buf[1], tmp_file, L_tmpnam ); + strcpy( &buf[1], tmp_file ); ist = ku_edit( buf, 0 ); switch( ist ) { case 0: /* all ok */ - r = R_OK; + r = MAIL_OK; break; case 1: /* user abort */ if ( first ) { printf("BUGREPORT: user abort of editing bugreport\n"); - r = R_ERROR; + r = MAIL_ERROR; } else { - r = R_OK; /* second edit needs not to modify */ + r = MAIL_OK; /* second edit needs not to modify */ } break; case 2: /* error */ printf( "BUGREPORT: problem editing bugreport\n" ); - r = R_ERROR; + r = MAIL_ERROR; break; default: printf( "BUGREPORT: ku_edit returned %d ??\n", ist ); - r = R_OK; + r = MAIL_OK; break; } + free( buf ); return r; } static int -br_add_config( char tmp_file[ L_tmpnam ] ) +br_add_config( char * tmp_file ) { FILE *fp; char *k_OS; char *k_MACHINE; char *s, *buginfo(); + if ( tmp_file == 0 || *tmp_file == 0 ) { + printf( "BUGREPORT: problem adding version info to bugreport\n" ); + return MAIL_ERROR; + } + fp = fopen( tmp_file, "a" ); if ( fp == NULL ) { printf( "BUGREPORT: problem adding version info to bugreport\n" ); - return R_ERROR; + return MAIL_ERROR; } s = buginfo(); @@ -360,7 +420,7 @@ free( k_OS ); free( k_MACHINE ); - return R_OK; + return MAIL_OK; } @@ -376,7 +436,7 @@ fp = fopen( file, "r" ); if ( fp == NULL ) { printf( "BUGREPORT: cannot (re)open temporary file\n" ); - return R_ERROR; + return MAIL_ERROR; } cuserid( my_addr ); @@ -386,7 +446,7 @@ if ( mfp == NULL ) { printf( "BUGREPORT: cannot run sendmail\n" ); - return R_ERROR; + return MAIL_ERROR; } @@ -407,7 +467,7 @@ pclose( mfp ); - return R_OK; + return MAIL_OK; } #endif #if defined(CERNLIB_VAX) @@ -419,7 +479,7 @@ system( line ); - return R_OK; + return MAIL_OK; } #endif #if (defined(CERNLIB_IBM))&&(!defined(CERNLIB_IBMMVS))&&(!defined(CERNLIB_NEWLIB)) @@ -436,17 +496,17 @@ rc = system(line); - return rc == 0 ? R_OK : R_ERROR; + return rc == 0 ? MAIL_OK : MAIL_ERROR; } #endif void bugreprt() { - char tmp_file[ L_tmpnam ], *s, *ku_proc(), *ku_getc(), mode, *addr; + char *tmp_file, *s, *ku_proc(), *ku_getc(), mode, *addr; int r, first; - r = R_OK; + r = MAIL_OK; /* determine mode B or C */ @@ -460,28 +520,30 @@ mode = *s; } else { printf( "BUGREPORT: Illegal option(s).\n" ); - r = R_ERROR; + r = MAIL_ERROR; } break; default: /* huh ? */ printf( "BUGREPORT: Illegal option(s).\n" ); - r = R_ERROR; + r = MAIL_ERROR; break; } /* create temp file */ - if ( r == R_OK ) + if ( r == MAIL_OK ) { + tmp_file = br_create_tempfile(); r = br_create_template( tmp_file, mode ); + } /* have the user edit the temp file */ for( first = 1 ; ; ) { - if ( first || (strcmp( "EDIT", s ) == 0) ) { + if ( (r == MAIL_OK) && (first || (strcmp( "EDIT", s ) == 0)) ) { r = br_edit_file( first, tmp_file ); first = 0; - if ( r == R_OK ) { + if ( r == MAIL_OK ) { s = ku_proc( "Type 'send' to submit, 'edit' to re-edit or 'abort' to cancel: ", NULL ); @@ -490,10 +552,10 @@ break; } } else if ( strcmp( "SEND", s ) == 0 ) { - r = R_OK; + r = MAIL_OK; break; } else if ( strcmp( "ABORT", s ) == 0 ) { - r = R_ERROR; + r = MAIL_ERROR; break; } else { s = @@ -503,12 +565,12 @@ /* add config info */ - if ( r == R_OK ) + if ( r == MAIL_OK ) r = br_add_config( tmp_file ); /* send the temp file */ - if ( r == R_OK ) { + if ( r == MAIL_OK ) { s = mode == 'B' ? "PAW Bug Report" : "PAW Comment"; addr = getenv( "PAWSUPPORT" ); @@ -518,7 +580,7 @@ r = br_mail_file( addr, s , tmp_file ); } - if ( r == R_OK ) { + if ( r == MAIL_OK ) { printf( "BUGREPORT: Report sent\n" ); } else { printf( "BUGREPORT: No report sent\n" ); @@ -526,7 +588,9 @@ /* clean up */ - remove( tmp_file ); + if ( tmp_file && *tmp_file ) + remove( tmp_file ); + free( tmp_file ); } @@ -573,21 +637,23 @@ br_mail_motif( char mode, char *name, char *inst, char *phone, char *email, char *message) { - char tmp_file[ L_tmpnam ], **s, *st, *addr; + char *tmp_file, **s, *st, *addr; FILE *fp; int r; - tmpnam( tmp_file ); - if ( *tmp_file == 0 ) { + tmp_file = br_create_tempfile(); + if ( tmp_file == 0 || *tmp_file == 0 ) { /* report error */ printf( "BUGREPORT: cannot get temporary file\n" ); - return R_ERROR; + free( tmp_file ); + return MAIL_ERROR; } fp = fopen( tmp_file, "w" ); if ( fp == NULL ) { printf( "BUGREPORT: cannot open temporary file\n" ); - return R_ERROR; + free( tmp_file ); + return MAIL_ERROR; } for( s = br_tmpl_user; *s ; s++ ) { @@ -611,7 +677,7 @@ r = br_add_config( tmp_file ); - if ( r == R_OK ) { + if ( r == MAIL_OK ) { st = mode == 'B' ? "PAW Bug Report" : "PAW Comment"; addr = getenv( "PAWSUPPORT" ); @@ -620,11 +686,15 @@ } r = br_mail_file( addr, st , tmp_file ); - if ( r == R_OK ) + if ( r == MAIL_OK ) printf( "BUGREPORT: Report sent\n" ); } - + /* clean up */ + if ( tmp_file && *tmp_file ) + remove( tmp_file ); + free( tmp_file ); + return r; } #endif diff -urN src.orig/pawlib/paw/stagerd/child.c src/pawlib/paw/stagerd/child.c --- src.orig/pawlib/paw/stagerd/child.c 1996-04-02 17:00:15.000000000 -0500 +++ src/pawlib/paw/stagerd/child.c 2005-03-05 20:23:02.000000000 -0500 @@ -65,16 +65,21 @@ fname = dir; fdir = (char *)0; } - + +#if 0 strcpy(tmp,tmppath); strcat(tmp,TMP_TEMPLATE); mktemp(tmp); +#endif /* builtin ftp client */ - + /* Fixed to use tmpfile() rather than the insecure mktemp() + -- Kevin McCarty, for Debian, 24 April 2003 */ + if (bftp.bf_bufsize > 0) { - if (!(f = fopen(tmp,"w"))) { - errlog(LOG_ERR,"c_ftp_client() : can't open %s",tmp); + if (!(f = tmpfile())) { + errlog(LOG_ERR,"c_ftp_client() : tmpfile() failed : %s", + strerror(errno);); return SGD_RET_FOPEN; } ret = ftp_ftp(f,cl_dat,st_dat,fdir,fname); @@ -142,15 +147,20 @@ FILE *f; char tmp[PATH_MAX + 1], *s; +#if 0 strcpy(tmp,tmppath); strcat(tmp,TMP_TEMPLATE); mktemp(tmp); +#endif /* builtin ftp client */ + /* Fixed to use tmpfile() rather than the insecure mktemp() + -- Kevin McCarty, for Debian, 24 April 2003 */ if (bftp.bf_bufsize > 0) { - if (!(f = fopen(tmp,"w"))) { - errlog(LOG_ERR,"c_stage_tape() : can't open %s",tmp); + if (!(f = tmpfile())) { + errlog(LOG_ERR,"c_stage_tape() : tmpfile() failed : %s", + strerror(errno)); return SGD_RET_FOPEN; } ret = ftp_clio(f,cl_dat,st_dat,volid,fseqid,lbltyp,volser);