isdnlog: evaluate the variable PATH for program starts.
This commit is contained in:
parent
e1d10fddbf
commit
343a6f81ab
|
@ -1,4 +1,4 @@
|
|||
## $Id: Makefile.in,v 1.43 1998/10/03 18:05:48 akool Exp $
|
||||
## $Id: Makefile.in,v 1.44 1998/10/13 22:17:09 luethje Exp $
|
||||
##
|
||||
## ISDN accounting for isdn4linux.
|
||||
##
|
||||
|
@ -19,6 +19,9 @@
|
|||
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
##
|
||||
## $Log: Makefile.in,v $
|
||||
## Revision 1.44 1998/10/13 22:17:09 luethje
|
||||
## isdnlog: evaluate the variable PATH for program starts.
|
||||
##
|
||||
## Revision 1.43 1998/10/03 18:05:48 akool
|
||||
## - processor.c, takt_at.c : Patch from Michael Reinelt <reinelt@eunet.at>
|
||||
## try to guess the zone of the calling/called party
|
||||
|
@ -345,7 +348,7 @@ SERVICEFILE = /etc/services
|
|||
# DON'T EDIT BELOW THIS LINE
|
||||
######################################################################
|
||||
|
||||
VERSION = 2.99.33
|
||||
VERSION = 2.99.34
|
||||
|
||||
ifeq ($(POSTGRES),1)
|
||||
DEFS += -DPOSTGRES
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: start_prog.c,v 1.10 1997/06/22 23:03:28 luethje Exp $
|
||||
/* $Id: start_prog.c,v 1.11 1998/10/13 22:17:15 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -20,6 +20,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: start_prog.c,v $
|
||||
* Revision 1.11 1998/10/13 22:17:15 luethje
|
||||
* isdnlog: evaluate the variable PATH for program starts.
|
||||
*
|
||||
* Revision 1.10 1997/06/22 23:03:28 luethje
|
||||
* In subsection FLAGS it will be checked if the section name FLAG is korrect
|
||||
* isdnlog recognize calls abroad
|
||||
|
@ -235,7 +238,7 @@ int Ring(info_args *Cmd, char *Opts[], int Die, int Async)
|
|||
dup2(filedes[1],STDOUT_FILENO);
|
||||
dup2(filedes[1],STDERR_FILENO);
|
||||
|
||||
execvp(Args[0], Args);
|
||||
execvp(Pathfind(Args[0],NULL,NULL), Args);
|
||||
print_msg(PRT_ERR, "Can't start \"%s\" with execvp().\n", Args[0]);
|
||||
/* Alarm(); */
|
||||
exit(-1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: libtools.c,v 1.7 1998/10/13 21:53:36 luethje Exp $
|
||||
/* $Id: libtools.c,v 1.8 1998/10/13 22:17:22 luethje Exp $
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
* Copyright 1996 by Stefan Luethje (luethje@sl-gw.lake.de)
|
||||
|
@ -18,6 +18,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: libtools.c,v $
|
||||
* Revision 1.8 1998/10/13 22:17:22 luethje
|
||||
* isdnlog: evaluate the variable PATH for program starts.
|
||||
*
|
||||
* Revision 1.7 1998/10/13 21:53:36 luethje
|
||||
* isdnrep and lib: bugfixes
|
||||
*
|
||||
|
@ -47,6 +50,7 @@
|
|||
#include <malloc.h>
|
||||
#include <fnmatch.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libtools.h"
|
||||
|
||||
|
@ -678,3 +682,62 @@ char *Strncpy(char *dest, const char *src, int len)
|
|||
|
||||
/****************************************************************************/
|
||||
|
||||
const char *Pathfind(const char *path, const char *name, char *mode)
|
||||
{
|
||||
static char file[PATH_MAX];
|
||||
char _path[PATH_MAX];
|
||||
int _mode = 0;
|
||||
char *ptr = _path;
|
||||
|
||||
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
|
||||
if (path == NULL)
|
||||
{
|
||||
if ((ptr = getenv(PATH_ENV)) == NULL)
|
||||
return NULL;
|
||||
|
||||
Strncpy(_path,ptr,PATH_MAX);
|
||||
ptr = _path;
|
||||
_mode = X_OK;
|
||||
}
|
||||
else
|
||||
Strncpy(_path,path,PATH_MAX);
|
||||
|
||||
if (mode != NULL)
|
||||
while (*mode)
|
||||
{
|
||||
switch(*mode++)
|
||||
{
|
||||
case 'x': _mode |= X_OK;
|
||||
break;
|
||||
case 'w': _mode |= W_OK;
|
||||
break;
|
||||
case 'r': _mode |= R_OK;
|
||||
break;
|
||||
default :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (strchr(name,C_SLASH) != NULL)
|
||||
if (!access(name,_mode))
|
||||
return name;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
while((ptr = strtok(ptr,":")) != NULL)
|
||||
{
|
||||
snprintf(file,PATH_MAX-1,"%s/%s",ptr,name);
|
||||
if (!access(file,_mode))
|
||||
return file;
|
||||
|
||||
ptr = NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: libtools.h,v 1.7 1998/10/13 21:53:37 luethje Exp $
|
||||
/* $Id: libtools.h,v 1.8 1998/10/13 22:17:25 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: libtools.h,v $
|
||||
* Revision 1.8 1998/10/13 22:17:25 luethje
|
||||
* isdnlog: evaluate the variable PATH for program starts.
|
||||
*
|
||||
* Revision 1.7 1998/10/13 21:53:37 luethje
|
||||
* isdnrep and lib: bugfixes
|
||||
*
|
||||
|
@ -56,6 +59,10 @@ extern char *basename __P((__const char *__name));
|
|||
# define TMPDIR P_tmpdir
|
||||
#endif
|
||||
|
||||
#ifndef PATH_ENV
|
||||
# define PATH_ENV "PATH"
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define SHORT_STRING_SIZE 256
|
||||
|
@ -110,6 +117,7 @@ _EXTERN char *Replace_Variable(char *String);
|
|||
_EXTERN char *int2str(int value, int prec);
|
||||
_EXTERN char *Strncpy(char *dest, const char *src, int len);
|
||||
_EXTERN char *Strncat(char *dest, const char *src, int len);
|
||||
_EXTERN const char *Pathfind(const char *path, const char *name, char *mode);
|
||||
|
||||
#undef _EXTERN
|
||||
|
||||
|
|
Loading…
Reference in New Issue