Accepting request 70915 from home:elvigia:branches:Base:System

- Open all file descriptors with O_CLOEXEC
- handle out-of-disk-space situations somewhat better.

OBS-URL: https://build.opensuse.org/request/show/70915
OBS-URL: https://build.opensuse.org/package/show/Base:System/fillup?expand=0&rev=12
This commit is contained in:
Dirk Mueller 2011-06-02 09:40:42 +00:00 committed by Git OBS Bridge
parent f05fe125e4
commit dda254d2ee
5 changed files with 112 additions and 26 deletions

20
fillup-1.42-cloexec.patch Normal file
View File

@ -0,0 +1,20 @@
--- SRC/services.c.orig
+++ SRC/services.c
@@ -342,7 +342,7 @@ openFileForReading
{
Service_t returnValue;
- *filePointer = fopen( filename, "r" );
+ *filePointer = fopen( filename, "re" );
if( *filePointer == NULL )
{
fillup_exception( __FILE__, __LINE__, ServiceException,
@@ -368,7 +368,7 @@ openFileForWriting
{
Service_t returnValue;
- *filePointer = fopen( filename, "w" );
+ *filePointer = fopen( filename, "we" );
if( *filePointer == NULL )
{
fillup_exception( __FILE__, __LINE__, ServiceException,

View File

@ -1,6 +1,6 @@
--- SRC/consume.c --- SRC/consume.c.orig
+++ SRC/consume.c 2005-09-02 12:44:00.000000000 +0200 +++ SRC/consume.c
@@ -140,7 +140,7 @@ @@ -140,7 +140,7 @@ consumeUptoBreak
{ {
break; /* line break detected */ break; /* line break detected */
} }
@ -9,9 +9,9 @@
{ {
break; /* End-Of-File detected */ break; /* End-Of-File detected */
} }
--- SRC/file.c --- SRC/file.c.orig
+++ SRC/file.c 2005-09-02 12:44:00.000000000 +0200 +++ SRC/file.c
@@ -35,18 +35,34 @@ @@ -35,18 +35,34 @@ readFile
File_t returnValue; File_t returnValue;
FILE * filePointer; FILE * filePointer;
long fileLength; long fileLength;
@ -52,9 +52,9 @@
addToWatchdog( fileLength ); addToWatchdog( fileLength );
associateBuffer( fileSpecifier, fileLength, &buffer ); associateBuffer( fileSpecifier, fileLength, &buffer );
returnValue = FileOperationsSuccessful; returnValue = FileOperationsSuccessful;
--- SRC/parameters.c --- SRC/parameters.c.orig
+++ SRC/parameters.c 2005-09-02 12:44:00.000000000 +0200 +++ SRC/parameters.c
@@ -368,6 +368,13 @@ @@ -368,6 +368,13 @@ queryParameter
} }
break; break;
@ -68,9 +68,18 @@
case IgnoreDefinites: case IgnoreDefinites:
if( parameterIgnoreDefinites == IsSet ) if( parameterIgnoreDefinites == IsSet )
{ {
--- SRC/parser.c --- SRC/parser.c.orig
+++ SRC/parser.c 2005-09-02 12:44:00.000000000 +0200 +++ SRC/parser.c
@@ -296,6 +296,7 @@ @@ -19,7 +19,7 @@
/*--------------------------------- IMPORTS ----------------------------------*/
#include <ctype.h>
-
+#include <unistd.h>
#include "portab.h"
#include "variableblock.h"
#include "parameters.h"
@@ -296,6 +296,7 @@ createAdministrationInfo
unsigned long Size; unsigned long Size;
char * delimiterString; char * delimiterString;
char delimiterChar; char delimiterChar;
@ -78,7 +87,7 @@
queryStringParameter( Delimiter, &delimiterString ); queryStringParameter( Delimiter, &delimiterString );
delimiterChar = delimiterString[ 0 ]; delimiterChar = delimiterString[ 0 ];
@@ -305,23 +306,25 @@ @@ -305,23 +306,25 @@ createAdministrationInfo
countDelimiters( delimiterChar, baseFileBuffer, baseFileBufferLength ); countDelimiters( delimiterChar, baseFileBuffer, baseFileBufferLength );
baseFileBlocksLength++; /* add possible trailing comment */ baseFileBlocksLength++; /* add possible trailing comment */
Size = baseFileBlocksLength * sizeof( VariableBlock_t ); Size = baseFileBlocksLength * sizeof( VariableBlock_t );
@ -106,7 +115,7 @@
if( queryParameter( ForbiddenFile ) == TRUE ) if( queryParameter( ForbiddenFile ) == TRUE )
{ {
@@ -329,12 +332,13 @@ @@ -329,12 +332,13 @@ createAdministrationInfo
delimiterChar, forbiddenFileBuffer, forbiddenFileBufferLength ); delimiterChar, forbiddenFileBuffer, forbiddenFileBufferLength );
forbiddenFileBlocksLength++; /* add possible trailing comment */ forbiddenFileBlocksLength++; /* add possible trailing comment */
Size = forbiddenFileBlocksLength * sizeof( VariableBlock_t ); Size = forbiddenFileBlocksLength * sizeof( VariableBlock_t );
@ -121,7 +130,7 @@
} }
} }
@@ -477,8 +481,8 @@ @@ -477,8 +481,8 @@ getVariable
getVBeginOfBlock( outputBuffer, &Line ); getVBeginOfBlock( outputBuffer, &Line );
Line = Line + getVLength( outputBuffer ); Line = Line + getVLength( outputBuffer );
LinePointer = Line; LinePointer = Line;
@ -132,9 +141,29 @@
lineIndex++ ) lineIndex++ )
{ {
LinePointer++; /* concerns only the current line */ LinePointer++; /* concerns only the current line */
--- SRC/services.c @@ -1768,6 +1772,8 @@ writeOutput
+++ SRC/services.c 2005-09-02 12:44:00.000000000 +0200 }
@@ -444,8 +444,9 @@ listPointer++;
}
+ if(fflush( filePointer ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream");
+ if(fdatasync ( fileno(filePointer) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream");
closeFile( filePointer );
}
}
@@ -1830,7 +1836,9 @@ writeOutput
default: break;
}
listPointer++;
- }
+ }
+ if(fflush( filePointer ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream");
+ if(fdatasync ( fileno(filePointer) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream");
closeFile( filePointer );
}
}
--- SRC/services.c.orig
+++ SRC/services.c
@@ -444,8 +444,9 @@ readFileToBuffer
if( 0 == fseek( filePointer, 0L, SEEK_SET ) ) if( 0 == fseek( filePointer, 0L, SEEK_SET ) )
{ {
@ -146,7 +175,7 @@
{ {
returnValue = Success; returnValue = Success;
} }
@@ -558,23 +559,22 @@ @@ -558,23 +559,22 @@ dumpBlock
Service_t Service_t
allocateBuffer allocateBuffer
( (
@ -174,3 +203,24 @@
returnValue = Success; returnValue = Success;
} }
--- SRC/metadata.c.orig
+++ SRC/metadata.c
@@ -17,7 +17,7 @@
/*--------------------------------- IMPORTS ----------------------------------*/
#include <stdio.h>
-
+#include <unistd.h>
#include "variableblock.h"
#include "services.h"
#include "parser.h"
@@ -392,7 +392,8 @@ setMetadataInfo
logfile );
fprintf( logfile, ">\n\n" );
}
-
+ if(fflush( logfile ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream");
+ if(fdatasync( fileno(logfile) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream");
closeFile( logfile );
}
}

View File

@ -1,6 +1,15 @@
--- fillup-1.42/SRC/Makefile --- SRC/Makefile.orig
+++ fillup-1.42/SRC/Makefile +++ SRC/Makefile
@@ -46,24 +46,23 @@ @@ -37,7 +37,7 @@ ARCHIVE = ${PROJDIR}/ARCHIVE
WARNINGS = -Wall -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes
# WARNINGS = -Wunused -Wswitch -Wformat -Wreturn-type -Wimplicit -Wmissing-prototypes -Wmissing-declarations
-DEFINES =
+DEFINES = -D_GNU_SOURCE
# LINUX system
OPTISPLUS =
@@ -46,24 +46,23 @@ INC = -I/usr/include
COMPILER = -DGCC=1 COMPILER = -DGCC=1
# Set OPTIS to the following values # Set OPTIS to the following values
@ -11,7 +20,7 @@
ifeq ($(COMPILE_OPTION),DEBUG) ifeq ($(COMPILE_OPTION),DEBUG)
# compile for debugging # compile for debugging
- COMPILE = gcc -fsigned-char -DDEBUG -ansi -g -c ${WARNINGS} -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} - COMPILE = gcc -fsigned-char -DDEBUG -ansi -g -c ${WARNINGS} -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES}
+ COMPILE = gcc -DDEBUG -ansi -g -c $(OPTIS) ${WARNINGS} -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} + COMPILE = gcc -DDEBUG -std=gnu99 -g -c $(OPTIS) ${WARNINGS} -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES}
LINK = gcc -g LINK = gcc -g
endif endif
@ -19,7 +28,7 @@
# compile with all optimizations # compile with all optimizations
- COMPILE = gcc -fsigned-char -ansi -c $(OPTIS) $(WARNINGS) -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} - COMPILE = gcc -fsigned-char -ansi -c $(OPTIS) $(WARNINGS) -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES}
- LINK = gcc -O -s - LINK = gcc -O -s
+ COMPILE = gcc -ansi -c $(OPTIS) $(WARNINGS) -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} + COMPILE = gcc -std=gnu99 -c $(OPTIS) $(WARNINGS) -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES}
+ LINK = gcc + LINK = gcc
endif endif

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Sat May 21 20:34:06 UTC 2011 - crrodriguez@opensuse.org
- Open all file descriptors with O_CLOEXEC
- handle out-of-disk-space situations somewhat better.
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jun 28 06:38:35 UTC 2010 - jengelh@medozas.de Mon Jun 28 06:38:35 UTC 2010 - jengelh@medozas.de

View File

@ -32,6 +32,7 @@ Patch1: fillup-warnings.dif
Patch2: fillup-%{version}.dif Patch2: fillup-%{version}.dif
Patch3: fillup-retval.dif Patch3: fillup-retval.dif
Patch4: fillup-nodate.patch Patch4: fillup-nodate.patch
Patch5: fillup-1.42-cloexec.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
%define fillup_info_entry * fillup: (fillup) fillup. SuSE-fillup-tool. %define fillup_info_entry * fillup: (fillup) fillup. SuSE-fillup-tool.
@ -49,12 +50,12 @@ Authors:
%prep %prep
%setup -q %setup -q
%patch -p1 %patch
%patch1 -p1 %patch1 -p1
%patch2 -p0 %patch2 -p0
%patch3 -p0 %patch3 -p0
%patch4 -p0 %patch4 -p0
%patch5
%build %build
# #
# Be sure that the tests for fillup are run in # Be sure that the tests for fillup are run in