Esempio n. 1
0
String CTestResource::FileName() const
{
  String strHost;
  int nPort;
  CeCosSocket::ParseHostPort(HostPort(),strHost,nPort);
  return String::SFormat(_T("%s-%d"),(LPCTSTR)strHost,nPort);
}
Esempio n. 2
0
CeCosTest::ServerStatus CTestResource::Query() 
{
  CeCosTest::ExecutionParameters e(CeCosTest::ExecutionParameters::QUERY,m_Target);
  CeCosSocket *pSock=0;
  CeCosTest::ServerStatus s=CeCosTest::Connect(HostPort(),pSock,e,m_strInfo);
  delete pSock;
  return s;
}
Esempio n. 3
0
const String CTestResource::Image() const
{
  String str;
  str.Format(_T("%10s %20s %8s"),(LPCTSTR)HostPort(),(LPCTSTR)Target(),(LPCTSTR)Serial());
  if(IsLocked()){
    str+=_T(" [RL]");
  }
  return str;
}
Esempio n. 4
0
CResetAttributes::ResetResult CTestResource::RemoteReset(LogFunc *pfnLog, void *pfnLogparam)
{
  String strHost;
  int nPort;
  CeCosSocket::ParseHostPort(HostPort(),strHost,nPort);
  String strCmd;
  strCmd.Format(_T("rsh %s x10reset %s\n"),(LPCTSTR)strHost,ResetString());
  pfnLog(pfnLogparam,strCmd);

  CSubprocess sp;
  sp.Run(pfnLog,pfnLogparam,strCmd);
  return CResetAttributes::RESET_OK; // FIXME
}
Esempio n. 5
0
static int setACL(Connection *Conn,int add,PCStr(aclID),PCStr(user),PCStr(url),FILE *cfp,FILE *tc,void *env,sFUNCP ckfunc)
{	CStr(ctl,2048);
	CStr(com,2048);
	CStr(arg,2048);
	CStr(ac1,2048);
	CStr(Ver,256);
	CStr(AdmClass,128);
	CStr(Base,1024);
	int len;
	int errors = 0;
	int nl,cnl;
	FILE *acl;
	CStr(admid,2048);
	const char *xp;
	CStr(xmbox,128);
	int off;
	const char *cp;
	CStr(stime,64);
	const char *err;
	int bytes;

	cnl = 0;
	bytes = 0;
	Ver[0] = 0;
	AdmClass[0] = 0;
	Base[0] = 0;
	StrftimeLocal(AVStr(stime),sizeof(stime),"%Y/%m/%d-%H:%M:%S",time(0),0);

	sprintf(admid,"<%s>",aclID);

	for( nl = 1; fgets(ctl,sizeof(ctl),cfp) != NULL; nl++ ){
		bytes += strlen(ctl);
		if( ACL_MAXBYTES < bytes ){
fprintf(tc,"[WARNING] your ACL should be smaller than %d bytes.\r\n",
ACL_MAXBYTES);
			fprintf(tc,"[WARNING] remaining list is ignored.\r\n");
			errors++;
			break;
		}

		if( cp = strchr(ctl,'#') )
			truncVStr(cp);
		if( ctl[0] == 0 )
			continue;

		com[0] = arg[0] = 0;
		Xsscanf(ctl,"%[^: \t\r\n]%*[: \t\r\n]%[^\r\n]",AVStr(com),AVStr(arg));
		if( com[0] == 0 )
			continue;

		if( strcaseeq(com,"ACL-Version") ){
			strcpy(Ver,arg);
			continue;
		}
		if( strcaseeq(com,"Admin-Class") ){
			if( !strcaseeq(arg,"anonymous") ){
				fprintf(tc,"[FATAL: unknown Admin-Class] %s\r\n",arg);
				return -1;
			}
			strcpy(AdmClass,arg);
			continue;
		}
		if( strcaseeq(com,"Base-URL") ){
			CStr(proto,128);
			CStr(login,128);
			CStr(path,128);
			CStr(clogin,128);

			decomp_absurl(arg,AVStr(proto),AVStr(login),AVStr(path),sizeof(path));
			HostPort(AVStr(clogin),DST_PROTO,DST_HOST,DST_PORT);
			if( strcmp(proto,DST_PROTO) || hostcmp(login,clogin) ){

fprintf(tc,"[FATAL: Base-URL arrogation] <%s> should be <%s://%s>\r\n",
arg,DST_PROTO,clogin);

				return -1;
			}
			strcpy(Base,arg);
			continue;
		}

		if( Ver[0] == 0 ){
			fprintf(tc,"[FATAL: no ACL-Version specified]\r\n");
			return -1;
		}
		if( AdmClass[0] == 0 ){
			strcpy(AdmClass,"anonymous");
			fprintf(tc,"[WARNING: no Admin-Class specified] assumed %s\r\n",
				AdmClass);
		}
		if( ACL_MAXLINES < nl ){
fprintf(tc,"[WARNING] your ACL should be less than %d lines.\r\n",
ACL_MAXLINES);
			fprintf(tc,"[WARNING] remaining list is ignored.\r\n");
			errors++;
			break;
		}

		if( strcaseeq(com,"On") || strcaseeq(com,"Off") ){
			++cnl;

			if( add && ACLMAX < cnl ){
fprintf(tc,"[WARNING] you cannot control ACLs for more than %d newsgroups.\r\n",
ACLMAX);
				fprintf(tc,"[WARNING] remaining list is ignored.\r\n");
				errors++;
				break;
			}
			if( add && (err = (*ckfunc)(env,Base,arg)) ){
				fprintf(tc,"[ERROR] %d:[%s] %s: %s\r\n",
					nl,err,com,arg);
				errors++;
				continue;
			}

			acl = openAclFile(1,DST_PROTO,DST_HOST,DST_PORT,arg);
			fseek(acl,0,0);
			for(;;){
				off = ftell(acl);
				if( fgets(ac1,sizeof(ac1),acl) == NULL )
					break;
				if( xp = strstr(ac1,admid) ){
					if( add )
					fprintf(tc,"[UPDATE] %d: %s: %s\r\n",nl,com,arg);
					fseek(acl,off,0);
					break;
				}
			}
			if( add ){
				fprintf(acl,"%s %-10s %-10s %-10s %s\r\n",
					stime,com,user,AdmClass,admid);
			}else{
				int fsize,rcc;
				const char *buff;

				fsize = file_size(fileno(acl));
				buff = (char*)malloc(fsize);
				rcc = fread((char*)buff,1,fsize,acl);
				fseek(acl,off,0);
				fwrite(buff,1,rcc,acl);
				free((char*)buff);
				Ftruncate(acl,off,0);
			}
			fclose(acl);
			continue;
		}
	}
	return errors;
}