README.conffile completed, paranoid_check() used by read_conffiles(),

policy.h will be removed by "make distclean".
This commit is contained in:
luethje 1997-03-07 23:34:47 +00:00
parent 8f5ca2eb2b
commit 3beb5afbfa
4 changed files with 113 additions and 8 deletions

View File

@ -69,7 +69,7 @@ clean:
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
distclean: clean distclean: clean
-rm -f .depend -rm -f .depend policy.h
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i distclean; done set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i distclean; done
install: depend all install: depend all

View File

@ -186,5 +186,50 @@ werden.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Funktion:
section *write_file(section *Section, const char *FileName, char *Program,
char* Version)
Erzeugt eine Datei mit der bekannten Syntax zurueck. Dabei wird ein Datei-
header erzeugt.
Diese Datei laesst sich auch sehr sinnvoll fuer Debuggingzwecke nutzen.
Section: Beinhaltet den Pointer auf die Struktur, die zurueckgeschrieben
wertden soll.
FileName: Beinhaltet den Dateinamen, in der die Struktur abgelegt werden soll.
Besteht diese Datei, wird sie ohne Warnung ueberschrieben.
Programm: Name des Programm, das diese Datei anlegen soll.
Version: Version des Programmes, das diese Datei anlegen soll.
Rueckgabewert:
Bei erfolgreicher Erstellung der Datei wird Section zurueckgeliefert.
Im Fehlerfall NULL.
-----------------------------------------------------------------------------
Funktion:
void free_section(section *Ptr)
Loescht eine Section mit ihrer ganzen Unterstruktur. Es wird also die gesamte
verkettete Liste (inklusive ihrer Subsections) geloescht.
Ptr: Pointer auf eine Struktur, die geloescht werden soll.
Rueckgabewert:
Keiner.
-----------------------------------------------------------------------------
Da noch nicht mehr dokumentiert ist, verweise ich mal frech auf die Dateien Da noch nicht mehr dokumentiert ist, verweise ich mal frech auf die Dateien
lib/conffile.c und vboxgetty/vboxlib.c ;-((( lib/conffile.c ;-(((

View File

@ -27,6 +27,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@ -92,7 +93,7 @@ section *write_file(section *Section, const char *FileName, char *Program, char*
Write_Lines(Section,fp,FileName,0); Write_Lines(Section,fp,FileName,0);
fclose(fp); fclose(fp);
return NULL; return Section;
} }
/****************************************************************************/ /****************************************************************************/
@ -158,7 +159,7 @@ static const char *Pre_String(int Level)
section *read_file(section *Section, const char *FileName, int Flags) section *read_file(section *Section, const char *FileName, int Flags)
{ {
int Line = 0; int Line = 0;
FILE *fp; FILE *fp = NULL;
section *RetCode = NULL; section *RetCode = NULL;
@ -699,6 +700,54 @@ static int Compare_Sections(section* sec1, section *sec2, char ***variables)
/****************************************************************************/ /****************************************************************************/
#if 0
/* IN PROGRESS!!!!!! */
static int Compare_Sections(section* sec1, section *sec2, char **variables)
{
int i;
char **array;
if (sec1 == NULL || sec2 == NULL)
return -1;
if (variables == NULL)
{
if (!strcmp(sec1->name,sec2->name))
return 0;
}
else
{
for (i=0; variables[i] != NULL; i++)
{
if ((array = String_to_Array(Path,C_SLASH)) == NULL)
return NULL;
if (Compare_Section_From_Path(sec1,sec2,array) == 0)
{
del_Array(array);
return 0;
}
del_Array(array);
}
}
return -1;
}
/****************************************************************************/
static int Compare_Section_From_Path(section* sec1, section *sec2, char **array)
{
if (!strcmp(sec1->name,array[0]) &&
!strcmp(sec1->name,sec2->name) )
}
#endif
/****************************************************************************/
static int Merge_Sections(section **main_sec, section **ins_sec, char ***variables, int flags) static int Merge_Sections(section **main_sec, section **ins_sec, char ***variables, int flags)
{ {
if (main_sec == NULL) if (main_sec == NULL)

View File

@ -1,4 +1,4 @@
/* $Id: isdntools.c,v 1.3 1997/03/06 20:36:34 luethje Exp $ /* $Id: isdntools.c,v 1.4 1997/03/07 23:34:49 luethje Exp $
* *
* ISDN accounting for isdn4linux. (Utilities) * ISDN accounting for isdn4linux. (Utilities)
* *
@ -19,6 +19,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Log: isdntools.c,v $ * $Log: isdntools.c,v $
* Revision 1.4 1997/03/07 23:34:49 luethje
* README.conffile completed, paranoid_check() used by read_conffiles(),
* policy.h will be removed by "make distclean".
*
* Revision 1.3 1997/03/06 20:36:34 luethje * Revision 1.3 1997/03/06 20:36:34 luethje
* Problem in create_runfie() fixed. New function paranoia_check() implemented. * Problem in create_runfie() fixed. New function paranoia_check() implemented.
* *
@ -652,9 +656,15 @@ int read_conffiles(section **Section, char *groupfile)
if (!read_again) if (!read_again)
{ {
sprintf(s[0], "%s%c%s", confdir(), C_SLASH, CONFFILE); sprintf(s[0], "%s%c%s", confdir(), C_SLASH, CONFFILE);
append_element(&files,s[0]);
sprintf(s[1], "%s%c%s", confdir(), C_SLASH, CALLERIDFILE); sprintf(s[1], "%s%c%s", confdir(), C_SLASH, CALLERIDFILE);
if (paranoia_check(s[0]))
return -1;
if (paranoia_check(s[1]))
return -1;
append_element(&files,s[0]);
append_element(&files,s[1]); append_element(&files,s[1]);
if (groupfile != NULL) if (groupfile != NULL)
@ -723,7 +733,8 @@ int paranoia_check(char *cmd)
return -1; return -1;
} }
if (stbuf.st_mode & (S_IWGRP | S_IWOTH)) if ((stbuf.st_gid != 0 && (stbuf.st_mode & S_IWGRP)) ||
(stbuf.st_mode & S_IWOTH) )
{ {
print_msg("File `%s' is writable by group or world!\n", cmd); print_msg("File `%s' is writable by group or world!\n", cmd);
return -1; return -1;