Exemplo n.º 1
0
int authenticate(char *subdir) {   // "" or "oerjan/"
/* Only client which wrote its pid to server's 
VMEWORKDIR/WORK/miclockid file is allowed to change the clock
rc: 0:ok  !=0 -client is not allowed to change the clock
*/
int ix,rc;
//FILE *con; char line[80]=""; 
char *envwd, *vmesite;
char procid[80]; char fname[80]; char hname[31]="";
envwd= getenv("VMEWORKDIR"); sprintf(fname, "%s/WORK/%smiclockid",envwd,subdir);
rc= dis_get_client(procid);
for(ix=0; ix<80; ix++) {
  if(procid[ix]=='@') {
    procid[ix]='\0';
    strncpy(hname, &procid[ix+1],30); hname[30]='\0';
    break;
  };
};
if(( strncmp(hname,"ALIDCSCOM779",12)==0) ||
   ( strncmp(hname,"ALIDCSCOM779.cern.ch",20)==0)) {
  rc=0; goto OK;
}; 
// do not check when debug or lab:
vmesite= getenv("VMESITE"); if(strcmp(vmesite,"PRIVATE")==0) { rc=0; goto OK; };
if( (strncmp(hname,"alidcscom835",12)==0) ||
    (strncmp(hname,"avmes",12)==0) ||
    (strncmp(hname,"pcalicebhm10",12)==0)) {
  rc=0; goto OK;
};
rc=3;
/*
if(( strncmp(hname,"alidcscom835",12)==0) 
   || ( strncmp(hname,"avmes",12)==0)
   || ( strncmp(hname,"pcalicebhm10",12)==0)) {
  rc=0; goto OK;    // clock shift also from pydimserver!
};
if((con=fopen(fname,"r")) == NULL){
  printf("Cannot read %s file. \n", fname);
  return(1);
};
if(fgets(line, 80, con)==NULL) {fclose(con); return(2);};
fclose(con);
for(ix=0; ix<80; ix++) {
  if(line[ix]=='\n') line[ix]='\0';
};
if(strcmp(procid,line)==0) {
  rc=0;
} else {
  rc=3;
};
*/
OK:
//printf("procid:%s wd:%s line:%s< hname:%s rc:%d\n", procid, envwd,line, hname, rc);
printf("procid:%s wd:%s hname:%s rc:%d\n", procid, envwd, hname, rc);
fflush(stdout);
return(rc);
}
Exemplo n.º 2
0
/*----------------------------------------------------------- CNAMEScaba
*/
void CNAMEScaba(void *tag, void **msgpv, int *size, int *blabla) {
char **msgp= (char **)msgpv;
int cid; char cidname[MAXCIDAT];
char *cs;
//char msg[100];
//sprintf(msg,"INFO CNAMEScaba size:%d msg:%20.20s\n",*size, *msgp ); prtLog(msg); 
//updateNMCclients(&......); we do not keep track of CS clients
cid=dis_get_client(cidname);
cs= CNAMESString; // cs= readCS();
if(cs==NULL) {
  *msgp= CNAMESString; *size=0;
} else {
  *msgp= cs; *size= strlen(cs);
};
//printf("INFO CNAMEScaba size:%d cs:%30.30s \n", *size, cs); cannot (NLs!)
printf("INFO CNAMEScaba cid:%d client:%s size:%d\n", cid, cidname, *size);
// free(cs)
}
Exemplo n.º 3
0
int  getclientid(char *procid){
return(dis_get_client(procid));
}