- moved IFServerOption to ifile.c
- moved PWSicsUser to passwd.c - moved back InitObjectCommands to ofac.c
This commit is contained in:
28
ifile.c
28
ifile.c
@ -43,6 +43,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <sics.h>
|
||||||
#include "ifile.h"
|
#include "ifile.h"
|
||||||
|
|
||||||
/*====================== Locals ============================================*/
|
/*====================== Locals ============================================*/
|
||||||
@ -208,6 +209,33 @@ void IFDeleteOptions(IPair * pList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------- Server options creation -------------------------*/
|
||||||
|
int IFServerOption(SConnection * pCon, SicsInterp * pSics,
|
||||||
|
void *pData, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char pBueffel[512];
|
||||||
|
|
||||||
|
assert(pSics);
|
||||||
|
assert(pCon);
|
||||||
|
|
||||||
|
/* check authorisation */
|
||||||
|
if (!SCMatchRights(pCon, usMugger)) {
|
||||||
|
SCWrite(pCon, "Insufficient privilege to set options", eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test if sufficient arguments */
|
||||||
|
if (argc < 3) {
|
||||||
|
snprintf(pBueffel,sizeof(pBueffel)-1, "Syntax: %s name value ", argv[0]);
|
||||||
|
SCWrite(pCon, pBueffel, eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* just do it */
|
||||||
|
pSICSOptions = IFAddOption(pSICSOptions, argv[1], argv[2]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*===========================================================================
|
/*===========================================================================
|
||||||
Testcode: Define MAIN to activate it. Needs a file test.txt
|
Testcode: Define MAIN to activate it. Needs a file test.txt
|
||||||
as input
|
as input
|
||||||
|
66
ofac.c
66
ofac.c
@ -7,14 +7,17 @@
|
|||||||
* heavy modifications to separate PSI specific commands into a
|
* heavy modifications to separate PSI specific commands into a
|
||||||
* separate library. Mark Koennecke, June 2003
|
* separate library. Mark Koennecke, June 2003
|
||||||
*
|
*
|
||||||
* moved all staff except command and initialization list to sicsutil.c
|
* moved some functions to sicsutil.c
|
||||||
* Markus Zolliker Jan 2010
|
* Markus Zolliker Jan 2010
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ofac.h"
|
#include "ofac.h"
|
||||||
|
#include "exeman.h"
|
||||||
|
#include "statusfile.h"
|
||||||
|
#include "site.h"
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
void InitGeneral(void)
|
static void InitGeneral(void)
|
||||||
{
|
{
|
||||||
#define INIT(F) { void F(void); F(); }
|
#define INIT(F) { void F(void); F(); }
|
||||||
|
|
||||||
@ -38,7 +41,7 @@ void InitGeneral(void)
|
|||||||
INIT(SiteInit); /* site specific initializations */
|
INIT(SiteInit); /* site specific initializations */
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitIniCommands(SicsInterp * pInter)
|
static void InitIniCommands(SicsInterp * pInter)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* declare and add permanent command */
|
/* declare and add permanent command */
|
||||||
@ -165,4 +168,59 @@ void InitIniCommands(SicsInterp * pInter)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* all other content moved to sicsutil.c - M.Zolliker Jan 2010 */
|
/*--------------------------------------------------------------------------*/
|
||||||
|
int InitObjectCommands(pServer pServ, char *file)
|
||||||
|
{
|
||||||
|
SConnection *pCon = NULL;
|
||||||
|
char pBueffel[1024];
|
||||||
|
int iRet;
|
||||||
|
SicsInterp *pSics;
|
||||||
|
pExeList pExe;
|
||||||
|
pEnvMon pEnv = NULL;
|
||||||
|
pSite site = NULL;
|
||||||
|
|
||||||
|
pSics = pServ->pSics;
|
||||||
|
assert(pSics);
|
||||||
|
|
||||||
|
InitGeneral();
|
||||||
|
|
||||||
|
/* general initialization */
|
||||||
|
/* create a connection */
|
||||||
|
pCon = SCCreateDummyConnection(pSics);
|
||||||
|
if (!pCon) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
MakeExeManager(pCon, pSics, NULL, 1, NULL);
|
||||||
|
|
||||||
|
pExe = CreateExeList(pServ->pTasker);
|
||||||
|
pServ->pExecutor = pExe;
|
||||||
|
pEnv = CreateEnvMon();
|
||||||
|
|
||||||
|
assert(pExe);
|
||||||
|
assert(pEnv);
|
||||||
|
|
||||||
|
InitIniCommands(pSics);
|
||||||
|
/*
|
||||||
|
install site specific commands
|
||||||
|
*/
|
||||||
|
site = getSite();
|
||||||
|
if (site != NULL) {
|
||||||
|
site->AddSiteCommands(pServ->pSics);
|
||||||
|
}
|
||||||
|
|
||||||
|
InstallBckRestore(pCon, pSics);
|
||||||
|
|
||||||
|
|
||||||
|
/* evaluate the file */
|
||||||
|
snprintf(pBueffel,sizeof(pBueffel)-1, "fileeval %s", file);
|
||||||
|
iRet = InterpExecute(pSics, pCon, pBueffel);
|
||||||
|
|
||||||
|
/* done */
|
||||||
|
SCDeleteConnection(pCon);
|
||||||
|
if (site != NULL && site->RemoveSiteCommands != NULL) {
|
||||||
|
site->RemoveSiteCommands(pSics);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveStartupCommands();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
14
ofac.h
14
ofac.h
@ -3,6 +3,14 @@
|
|||||||
*
|
*
|
||||||
* copyright: see file COPYRIGHT
|
* copyright: see file COPYRIGHT
|
||||||
*
|
*
|
||||||
|
* SICS is a highly configurable system. This function implements
|
||||||
|
* the configurable. Configuration is meant to happen via a Tcl-
|
||||||
|
* configuration script. This module will initialize commands which
|
||||||
|
* create SICS-objects. Than an initialization file is evaluated
|
||||||
|
* via the macro facility. As most of the initialization commands
|
||||||
|
* will no longer be needed after this, they will be deleted.
|
||||||
|
* All this will be run with a higly privileged connection which
|
||||||
|
* prints to stdout/stdin.
|
||||||
*
|
*
|
||||||
* Mark Koennecke 1996 - ?
|
* Mark Koennecke 1996 - ?
|
||||||
* Markus Zolliker Jan 2010
|
* Markus Zolliker Jan 2010
|
||||||
@ -12,10 +20,6 @@
|
|||||||
#define OBJECTFACTORY
|
#define OBJECTFACTORY
|
||||||
#include "sics.h"
|
#include "sics.h"
|
||||||
|
|
||||||
/* module initialisation calls */
|
int InitObjectCommands(pServer pServ, char *file);
|
||||||
void InitGeneral(void);
|
|
||||||
|
|
||||||
/* module initialisation calls */
|
|
||||||
void InitIniCommands(SicsInterp * pInter);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
37
passwd.c
37
passwd.c
@ -44,6 +44,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "passwd.h"
|
#include "passwd.h"
|
||||||
#include "splitter.h"
|
#include "splitter.h"
|
||||||
|
#include "sics.h"
|
||||||
|
|
||||||
typedef struct __PENTRY {
|
typedef struct __PENTRY {
|
||||||
char *name;
|
char *name;
|
||||||
@ -152,3 +153,39 @@ int InitPasswd(char *filename)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
return iRes;
|
return iRes;
|
||||||
}
|
}
|
||||||
|
/*----------------------- Password database update -------------------------*/
|
||||||
|
int PWSicsUser(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char pBueffel[512];
|
||||||
|
TokenList *pList = NULL;
|
||||||
|
|
||||||
|
assert(pSics);
|
||||||
|
assert(pCon);
|
||||||
|
|
||||||
|
/* check authorisation */
|
||||||
|
if (SCGetRights(pCon) > usMugger) {
|
||||||
|
SCWrite(pCon, "Insufficient privilege to set users", eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* analyse commandlist */
|
||||||
|
pList = SplitArguments(argc - 1, &argv[1]);
|
||||||
|
if ((!pList) || (!pList->pNext) || (!pList->pNext->pNext)) {
|
||||||
|
snprintf(pBueffel,sizeof(pBueffel)-1, "Invalid Passwd Entry ::\n %s %s %s\n", argv[1],
|
||||||
|
argv[2], argv[3]);
|
||||||
|
SCWrite(pCon, pBueffel, eError);
|
||||||
|
DeleteTokenList(pList);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
if (pList->pNext->pNext->Type != eInt) {
|
||||||
|
SCWrite(pCon, "Need integer rights code", eError);
|
||||||
|
DeleteTokenList(pList);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
AddUser(pList->text, pList->pNext->text, pList->pNext->pNext->iVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DeleteTokenList(pList);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user