allows the character `"' in the program argument like the shell.

some bugfixes.
This commit is contained in:
luethje 1997-04-15 22:36:58 +00:00
parent e4aba8ad46
commit a95ea83b2e
6 changed files with 274 additions and 23 deletions

View File

@ -1,4 +1,4 @@
## $Id: Makefile.in,v 1.12 1997/04/15 00:19:53 luethje Exp $
## $Id: Makefile.in,v 1.13 1997/04/15 22:36:58 luethje Exp $
##
## ISDN accounting for isdn4linux.
##
@ -19,6 +19,10 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Log: Makefile.in,v $
## Revision 1.13 1997/04/15 22:36:58 luethje
## allows the character `"' in the program argument like the shell.
## some bugfixes.
##
## Revision 1.12 1997/04/15 00:19:53 luethje
## replace variables: some bugfixes, README comleted
##
@ -169,7 +173,7 @@ SERVICEFILE = /etc/services
# DON'T EDIT BELOW THIS LINE
######################################################################
VERSION = 2.99.8
VERSION = 2.99.9
ifeq ($(POSTGRES),1)
DEFS += -DPOSTGRES

View File

@ -807,6 +807,30 @@ eine Variable verwendet werden soll, so muss diese mit "\$" geqoutet werden:
ALIAS = \$PATH # -> "$PATH"
...
Wenn eine Variable mehrfach gesetzt wird, so wird sie ueberschrieben. Die
Regel fuer das ueberschreiben entspricht der Reihenfolge, in der die
Konfigurationsdateien gelesen werden:
1. isdn.conf
2. callerid.conf
3. ~/.isdn
Wenn eine Variable "FRED" in "isdn.conf" und "~/.isdn" gesetzt werden, so wird
der Wert von "isdn.conf" durch den Wert der zweiten Datei ueberschrieben.
Die Variablen werden zuerst aus allen drei Dateien gelesen, bevor die
Ersetzung stattfindet. Das bedeutet also, das z. B. eine Variable, die
in "~/.isdn" gesetzt wurde, in der isdn.conf verwendet werden kann.
Dieses mag im ersten Augenblick als ein Sicherheitsloch erscheinen, aber
wenn als root ein Programm gestartet wurde, muessen alle drei Dateien
auf readonly fuer group und world gesetzt sein. Andersherum kann ein Benutzer,
der ein Programm startet auf diese Dateien nur lesend zugreifen.
ACHTUNG:
Es ist allerdings davon abzuraten, weder den isdnlog, noch den isdnrep oder den
isdnconf mit dem sticky-Bit auszustatten!!!!
Es gibt bestimmte Regeln, nachdem Eintraege aus der Datei "~/.isdn" die
Eintraege der "callerid.conf" ueberschreiben:

View File

@ -1,5 +1,5 @@
#!/bin/sh
## $Id: genconf,v 1.2 1997/04/08 21:20:02 luethje Exp $
## $Id: genconf,v 1.3 1997/04/15 22:37:05 luethje Exp $
##
## ISDN accounting for isdn4linux.
##
@ -20,6 +20,10 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Log: genconf,v $
## Revision 1.3 1997/04/15 22:37:05 luethje
## allows the character `"' in the program argument like the shell.
## some bugfixes.
##
## Revision 1.2 1997/04/08 21:20:02 luethje
## primitive changes
##
@ -28,12 +32,12 @@
##
CONFFILE=$1
RESFILE=/tmp/`basename $0`.res.$$
setentry() {
SECTION=$1
ENTRY=$2
VALUE=$3
RESFILE=/tmp/`basename $0`.res.$$
AWKFILE=/tmp/`basename $0`.$$
grep $ENTRY $CONFFILE >/dev/null 2>&1
@ -85,4 +89,8 @@ setentry "[ISDNLOG]" "OLABEL" "$OLABEL"
setentry "[ISDNLOG]" "ILABEL" "$ILABEL"
setentry "[ISDNLOG]" "LOGFILE" "$LOGFILE"
sed -e "s/\([^\]\)\$\([0-9][ ]\)/\1\\\\$\2/g" $CONFFILE >$RESFILE
cp $RESFILE $CONFFILE
rm -f $RESFILE
echo " Ready."

View File

@ -1,4 +1,4 @@
/* $Id: start_prog.c,v 1.3 1997/04/10 23:32:19 luethje Exp $
/* $Id: start_prog.c,v 1.4 1997/04/15 22:37:10 luethje Exp $
*
* ISDN accounting for isdn4linux.
*
@ -20,6 +20,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: start_prog.c,v $
* Revision 1.4 1997/04/15 22:37:10 luethje
* allows the character `"' in the program argument like the shell.
* some bugfixes.
*
* Revision 1.3 1997/04/10 23:32:19 luethje
* Added the feature, that environment variables are allowed in the config files.
*
@ -45,6 +49,18 @@
/*************************************************************************/
#define C_SET_TAB 1
#define C_SET_SPACE 2
#define SET_BEGIN_VAR 1
/*************************************************************************/
#define C_TAB '\t'
#define C_SPACE ' '
/*************************************************************************/
static interval *RootIntervall = NULL;
/** Prototypes ***********************************************************/
@ -54,6 +70,8 @@ static int GetArgs(char *, char *[], char *[], int);
static interval *Next_Interval(void);
static int set_user(char *User);
static int set_group(char *Group);
static char *StrToArg(char* string);
static char *Replace_Opts(char *String, char *Opts[], int MaxOpts);
/****************************************************************************/
@ -149,10 +167,7 @@ int Ring(info_args *Cmd, char *Opts[], int Die, int Async)
case -1: print_msg(PRT_ERR, "%s\n", "Can't start fork()!");
return 0;
break;
case 0: if (paranoia_check(Args[0]) < 0)
exit(-1);
if (set_group(Cmd->group) < 0)
case 0: if (set_group(Cmd->group) < 0)
{
print_msg(PRT_ERR, "Can not set group %s: %s\n",Cmd->group,strerror(errno));
exit(-1);
@ -164,6 +179,9 @@ int Ring(info_args *Cmd, char *Opts[], int Die, int Async)
exit(-1);
}
if (paranoia_check(Args[0]) < 0)
exit(-1);
dup2(filedes[1],STDOUT_FILENO);
dup2(filedes[1],STDERR_FILENO);
@ -224,7 +242,6 @@ static int GetArgs(char *Line, char *Args[], char *Opts[], int MaxArgs)
int MaxOpts= 0;
int i = 0;
int j = 0;
int Num = 0;
char HelpString[SHORT_STRING_SIZE];
static char **MemPtr = NULL;
@ -241,10 +258,19 @@ static int GetArgs(char *Line, char *Args[], char *Opts[], int MaxArgs)
while (Opts[MaxOpts] != NULL)
MaxOpts++;
while ((Org_Arg = Arg = strtok(Use, " \t")))
while ((Org_Arg = Arg = StrToArg(Use)))
{
Use = NULL;
if ((Ptr = Replace_Opts(Arg,Opts,MaxOpts)) != NULL)
{
Arg = strdup(Ptr);
MemPtr = (char**) realloc(MemPtr,sizeof(char*)*(j+2));
MemPtr[j++] = Arg;
MemPtr[j] = NULL;
}
if (*Arg == '@')
{
FILE *fp = fopen(Arg+1,"r");
@ -266,9 +292,6 @@ static int GetArgs(char *Line, char *Args[], char *Opts[], int MaxArgs)
else
Arg = NULL;
}
else
if (*Arg == '$' && Opts != NULL && (Num = atoi(Arg+1)) > 0 && Num <= MaxOpts)
Arg = Opts[Num-1];
if (Arg == NULL || *Arg == '\0')
{
@ -278,9 +301,11 @@ static int GetArgs(char *Line, char *Args[], char *Opts[], int MaxArgs)
Arg = "?";
}
/*
Ptr = Arg;
while((Ptr = Check_Quote(Ptr, S_QUOTES, QUOTE_DELETE)) != NULL && Ptr[0] != '\0')
Ptr++;
*/
if (i < MaxArgs) Args[i++] = Arg;
}
@ -290,6 +315,180 @@ static int GetArgs(char *Line, char *Args[], char *Opts[], int MaxArgs)
return(i);
}
/*************************************************************************/
static char *StrToArg(char* string)
{
static char *Ptr = NULL;
int in = 0;
int begin = 1;
char *Start;
if (string != NULL)
{
Ptr = string;
begin = 1;
}
Start = Ptr;
if (Ptr == NULL)
return NULL;
while(*Ptr != '\0')
{
if (*Ptr == '\"')
{
if (begin != 1 && Ptr[-1] == C_QUOTE_CHAR)
{
memmove(Ptr-1,Ptr,strlen(Ptr)+1);
Ptr--;
}
else
{
in = !in;
memmove(Ptr,Ptr+1,strlen(Ptr));
Ptr--;
}
}
else
if (!in && isspace(*Ptr))
{
*Ptr++ = '\0';
break;
}
begin = 0;
Ptr++;
}
if (in)
print_msg(PRT_WARN,"Warning: Missing second char `\"'! in string `%s'!\n",Start);
if (*Start == '\0')
Start = NULL;
return Start;
}
/****************************************************************************/
static char *Replace_Opts(char *String, char *Opts[], int MaxOpts)
{
static char *RetCode = NULL;
char *Begin = NULL;
char *Var = NULL;
char *End = NULL;
char *Value = NULL;
char *Ptr = String;
int cnt = 0;
int num = 0;
int Num = 0;
if (Opts == NULL)
return String;
while ((Ptr = strchr(Ptr,C_BEGIN_VAR)) != NULL)
{
cnt++;
Ptr++;
}
if (!cnt)
return String;
if (RetCode != NULL)
free(RetCode);
if ((RetCode = strdup(String)) == NULL ||
(Var = strdup(RetCode)) == NULL ||
(End = strdup(RetCode)) == NULL )
{
print_msg(PRT_ERR,"%s!\n","Error: Can not allocate memory!\n");
return NULL;
}
while ((Ptr = strchr(RetCode,C_BEGIN_VAR)) != NULL)
{
if (Ptr != RetCode && Ptr[-1] == C_QUOTE_CHAR)
{
*Ptr = SET_BEGIN_VAR;
memmove(Ptr-1,Ptr,strlen(RetCode)-(Ptr-RetCode-1));
cnt--;
}
else
if ((num = sscanf(Ptr+1,"%[0-9]%[^\n]",Var,End)) >= 1 ||
(num = sscanf(Ptr+1,"{%[0-9]}%[^\n]",Var,End)) >= 1 )
{
if ((Num = atoi(Var)) > 0 && Num <= MaxOpts)
{
free(Begin);
if ((Begin = strdup(RetCode)) == NULL)
{
print_msg(PRT_ERR,"%s!\n","Error: Can not allocate memory!\n");
return NULL;
}
Begin[Ptr-RetCode] = '\0';
if ((RetCode = (char*) realloc(RetCode,sizeof(char)*strlen(RetCode)+strlen(Value)-strlen(Var))) == NULL)
{
print_msg(PRT_ERR,"%s!\n","Error: Can not allocate memory!\n");
return NULL;
}
if (num == 1)
*End = '\0';
sprintf(RetCode,"%s%s%s",Begin,Opts[Num-1],End);
free(Var);
free(End);
if ((Var = strdup(RetCode)) == NULL ||
(End = strdup(RetCode)) == NULL )
{
print_msg(PRT_ERR,"%s!\n","Error: Can not allocate memory!\n");
return NULL;
}
cnt--;
}
else
{
*Ptr = SET_BEGIN_VAR;
cnt--;
print_msg(PRT_WARN,"Warning: Unknown variable `%s'!\n",Var);
}
}
else
*Ptr = SET_BEGIN_VAR;
}
if (cnt)
print_msg(PRT_WARN,"Warning: Invalid token in string `%s'!\n",String);
free(Begin);
free(Var);
free(End);
if ((Ptr = RetCode) != NULL)
{
while (*Ptr != '\0')
{
if (*Ptr == SET_BEGIN_VAR)
*Ptr = C_BEGIN_VAR;
Ptr++;
}
}
return RetCode;
}
/*************************************************************************
** KillCommand(-) - Beendet ein Programm anhand seiner PID. **
*************************************************************************/

View File

@ -1,4 +1,4 @@
/* $Id: tools.h,v 1.9 1997/04/03 22:40:21 luethje Exp $
/* $Id: tools.h,v 1.10 1997/04/15 22:37:13 luethje Exp $
*
* ISDN accounting for isdn4linux.
*
@ -20,6 +20,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: tools.h,v $
* Revision 1.10 1997/04/15 22:37:13 luethje
* allows the character `"' in the program argument like the shell.
* some bugfixes.
*
* Revision 1.9 1997/04/03 22:40:21 luethje
* some bugfixes.
*
@ -531,6 +535,7 @@ typedef struct {
double duration;
double dm;
char num[2][NUMSIZE];
char who[2][NUMSIZE];
long ibytes;
long obytes;
char version[10];

View File

@ -1,4 +1,4 @@
/* $Id: conffile.c,v 1.14 1997/04/15 00:20:13 luethje Exp $
/* $Id: conffile.c,v 1.15 1997/04/15 22:37:20 luethje Exp $
*
* ISDN accounting for isdn4linux.
*
@ -19,6 +19,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: conffile.c,v $
* Revision 1.15 1997/04/15 22:37:20 luethje
* allows the character `"' in the program argument like the shell.
* some bugfixes.
*
* Revision 1.14 1997/04/15 00:20:13 luethje
* replace variables: some bugfixes, README comleted
*
@ -1547,17 +1551,24 @@ int Replace_Variables(section *Section)
while(Entry != NULL)
{
if (Entry->value != NULL && (Ptr = Replace_Variable(Entry->value)) != NULL)
if (Entry->value != NULL)
{
if ((Ptr = strdup(Ptr)) == NULL)
if ((Ptr = Replace_Variable(Entry->value)) != NULL)
{
print_msg("%s","Can not allocate memory!\n");
return -1;
}
if ((Ptr = strdup(Ptr)) == NULL)
{
print_msg("%s","Can not allocate memory!\n");
return -1;
}
free(Entry->value);
Entry->value = Ptr;
free(Entry->value);
Entry->value = Ptr;
}
}
else
if (Entry->subsection != NULL)
if (Replace_Variables(Entry->subsection) != 0)
return -1;
Entry = Entry->next;
}