- Fixed a bug in conman.c which could cause a core dump when terminating
a connection during an active run. - Added an additional output mode for the connection in order to support the batch run editor. - Made clientput send everything with eWarning mode in order to support the batch run editor. - Added a better NetReadTillTerm - Fixed a problem in synchronize.c - Fixed an issue with reading empty line on normal connection sockets. - Added a psi scan mode to mesure.c for TRICS - Made motor print warnings when trying to reposition. - Fixed abug in hkl.c which cause wrong signs. SKIPPED: psi/el734driv.c psi/el734hp.c psi/el737driv.c psi/el737hpdriv.c psi/nextrics.c psi/nxamor.c psi/psi.c psi/slsmagnet.c psi/swmotor2.c psi/tasscan.c psi/tasutil.c
This commit is contained in:
84
macro.c
84
macro.c
@@ -2,7 +2,7 @@
|
||||
|
||||
All you need to evaluate macros with SICS.
|
||||
|
||||
The implmentation fo the macro stuff is complex and non intuitive.
|
||||
The implmentation for the macro stuff is complex and non intuitive.
|
||||
This is the price to pay for adding the extremly powerful and
|
||||
strong Tcl-interpreter to SICS. The problem is that Tcl does not
|
||||
know anything about connections and our error handling. We have
|
||||
@@ -22,6 +22,8 @@
|
||||
Mark Koennecke, December 1999
|
||||
InternalFileEval added
|
||||
|
||||
Mark Koennecke, May 2004
|
||||
Added protected exec called sys.
|
||||
|
||||
Copyright:
|
||||
|
||||
@@ -68,6 +70,7 @@
|
||||
#include "ifile.h"
|
||||
#include "Dbg.h"
|
||||
#include "servlog.h"
|
||||
#include "stringdict.h"
|
||||
|
||||
#define SICSERROR "005567SICS"
|
||||
/*----------------------------------------------------------------------------
|
||||
@@ -213,6 +216,77 @@
|
||||
free(pData);
|
||||
pUnbekannt = NULL;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
Implementation of a protected exec command
|
||||
--------------------------------------------------------------------------*/
|
||||
static pStringDict allowedCommands = NULL;
|
||||
/*----------------------------------------------------------------------*/
|
||||
int AllowExec(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: not enough arguments to allowexec",eError);
|
||||
return 0;
|
||||
}
|
||||
if(!SCMatchRights(pCon,usInternal))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(allowedCommands == NULL)
|
||||
{
|
||||
allowedCommands = CreateStringDict();
|
||||
if(allowedCommands == NULL)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: not enough memory for list of allowed system commands",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
StringDictAddPair(allowedCommands,argv[1],"Allowed!");
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
static void KillExec(ClientData data)
|
||||
{
|
||||
if(allowedCommands != NULL)
|
||||
{
|
||||
DeleteStringDict(allowedCommands);
|
||||
allowedCommands = NULL;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
This is in the Tcl sources
|
||||
*/
|
||||
extern int Tcl_ExecObjCmd(ClientData data, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[]);
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
char *test = NULL;
|
||||
|
||||
if(objc < 2)
|
||||
{
|
||||
return Tcl_ExecObjCmd(clientData,interp,objc, objv);
|
||||
}
|
||||
|
||||
test = Tcl_GetStringFromObj(objv[1],NULL);
|
||||
if(allowedCommands != NULL)
|
||||
{
|
||||
if(StringDictExists(allowedCommands,test))
|
||||
{
|
||||
return Tcl_ExecObjCmd(clientData,interp,objc, objv);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if we are here, we are not allowed to invoke this command
|
||||
*/
|
||||
Tcl_AppendResult(interp,"System command NOT allowed!",NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
initialises a Tcl-Interpreter, installs SICS unknown mechanism and kills
|
||||
a few dangerous commands from the normal Tcl command set
|
||||
@@ -252,6 +326,7 @@
|
||||
Tcl_DeleteCommand(pInter,"socket");
|
||||
Tcl_DeleteCommand(pInter,"vwait");
|
||||
Tcl_DeleteCommand(pInter,"exec");
|
||||
Tcl_CreateObjCommand(pInter,"exec",ProtectedExec,NULL,KillExec);
|
||||
|
||||
return pInter;
|
||||
}
|
||||
@@ -377,7 +452,6 @@
|
||||
{
|
||||
sprintf(pBueffel," Failed to open file -> %s <- ",argv[1]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
/* SCSetInterrupt(pCon,eAbortBatch); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -453,7 +527,7 @@
|
||||
fclose(fp);
|
||||
Tcl_DStringFree(&command);
|
||||
SCWrite(pCon,"ERROR: batch processing interrupted",eError);
|
||||
SetStatus(eOld);
|
||||
SetStatus(eEager);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@@ -549,7 +623,7 @@
|
||||
int ClientPut(SConnection *pCon, SicsInterp *pInter, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
OutCode eOut = eStatus;
|
||||
OutCode eOut = eWarning;
|
||||
int i = 0, iCode, iLen;
|
||||
int iMacro;
|
||||
char *ppCode;
|
||||
@@ -617,7 +691,7 @@
|
||||
eOut = eError;
|
||||
break;
|
||||
default:
|
||||
eOut = eStatus;
|
||||
eOut = eWarning;
|
||||
iCode = argc;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user