Пример #1
0
int
qldap_get_dotmode(qldap *q, stralloc *dm)
{
	int	r;

	/* get and check the status of the account */
	r = qldap_get_attr(q, LDAP_DOTMODE, &ldap_attr, SINGLE_VALUE);
	if (r == NOSUCH) {
		if (!stralloc_copy(dm, &dotmode)) return ERRNO;
		return OK;
	}
	if (r != OK)
		return r;

	if (!case_diffs(DOTMODE_LDAPONLY, ldap_attr.s)) {
		if (!stralloc_copys(dm, DOTMODE_LDAPONLY)) return ERRNO;
	} else if (!str_diff(DOTMODE_LDAPWITHPROG, ldap_attr.s)) {
		if (!stralloc_copys(dm, DOTMODE_LDAPWITHPROG)) return ERRNO;
	} else if (!str_diff(DOTMODE_DOTONLY, ldap_attr.s)) {
		if (!stralloc_copys(dm, DOTMODE_DOTONLY)) return ERRNO;
	} else if (!str_diff(DOTMODE_BOTH, ldap_attr.s)) {
		if (!stralloc_copys(dm, DOTMODE_BOTH)) return ERRNO;
	} else if (!str_diff(DOTMODE_NONE, ldap_attr.s)) {
		if (!stralloc_copys(dm, DOTMODE_NONE)) return ERRNO;
	} else {
		return ILLVAL;
	}
	if (!stralloc_0(dm)) return ERRNO;
	return OK;
}
Пример #2
0
int ltGetCgiValue(char *filename,ltCgiConfInfo *psCgiConf){
	xmlDocPtr doc;
	xmlNodePtr  node;
	xmlNodePtr  childnode;
  xmlNodePtr  tempRootNode;
	char *nodeValue;
	char *nodeName;
	char *nodeType;
	char *tempValue;
	doc=xmlParseFile(filename); 
	if(doc==NULL){
		return -1;
	}
	tempRootNode=xmlDocGetRootElement(doc);
	for(node = tempRootNode->children; node != NULL; node = node->next) {
		if(node->type==1){	
			
			if(!case_diffs(node->name,"server")){
				for(childnode=node->children;childnode!=NULL;childnode=childnode->next){
				 if(childnode->type==1){
         if(!case_diffs(childnode->name,"parameter")){
					nodeName=xmlGetProp(childnode,"name");
					nodeValue=xmlGetProp(childnode,"value");
					if(!case_diffs(nodeName,"ipaddr")){
						snprintf(psCgiConf->ipAddr,sizeof(psCgiConf->ipAddr),"%s",	nodeValue);
					}else if(!case_diffs(nodeName,"port")){
						psCgiConf->nPort=atol(nodeValue);
					}else if(!case_diffs(nodeName,"timeout")){
						psCgiConf->lTimeOut=atol(nodeValue);	
				        }else if(!case_diffs(nodeName,"uploadpath")){
						sprintf(psCgiConf->upLoadPath,"%s",	nodeValue);
					}else if(!case_diffs(nodeName,"msgcode")){
						psCgiConf->lMsgCode=atol(nodeValue);
					}else if(!case_diffs(nodeName,"maxmsg")){
						psCgiConf->lMaxMsgPkg=atol(nodeValue);
					}else{
						xmlFreeDoc(doc);
						return -1;
					}
				}
				}
				}
			}else{
				xmlFreeDoc(doc);
				return -1;
			}
		break;
		}
  }
	xmlFreeDoc(doc);
	return 0;
} 
Пример #3
0
int
qldap_get_status(qldap *q, int *status)
{
	int	r;
	
	/* default value */
	*status = STATUS_UNDEF;
	/* get and check the status of the account */
	r = qldap_get_attr(q, LDAP_ISACTIVE, &ldap_attr, SINGLE_VALUE);
	if (r == NOSUCH) {
		return OK;
	} else if (r == OK) {
		if (!case_diffs(ldap_attr.s, ISACTIVE_BOUNCE))
			*status = STATUS_BOUNCE;
		else if (!case_diffs(ldap_attr.s, ISACTIVE_DELETE))
			*status = STATUS_DELETE;
		else if (!case_diffs(ldap_attr.s, ISACTIVE_NOACCESS))
			*status = STATUS_NOACCESS;
		else	*status = STATUS_OK; /* default to OK */
		/* perhaps we should spill out a warning for unknown settings */
		return OK;
	}
	return r;
}
Пример #4
0
void main(int argc,char **argv)
{
  char *dir;
  char *action;
  char *dtline;
  char *nhost;
  const char *err;
  unsigned int i;
  int match;
  int opt;

  sig_pipeignore();

  while ((opt = getopt(argc,argv,"dDvV")) != opteof) {
    switch (opt) {
    case 'd': flagdo = 1; break;
    case 'D': flagdo = 0; break;
    case 'v':
    case 'V':
      strerr_die2x(0, "ezmlm-split version: ",auto_version);
    default:
      die_usage();
    }
  }

  startup(dir = argv[optind++]);
  load_config(dir);
  if (!(split = argv[optind]))
    split = "split";

  if (flagdo) {
    sender = env_get("SENDER");
    if (!sender) strerr_die2x(100,FATAL,ERR_NOSENDER);
    if (!*sender)
      strerr_die2x(100,FATAL,ERR_BOUNCE);
    if (!sender[str_chr(sender,'@')])
      strerr_die2x(100,FATAL,ERR_ANONYMOUS);
    if (str_equal(sender,"#@[]"))
      strerr_die2x(100,FATAL,ERR_BOUNCE);

    action = env_get("DEFAULT");
    if (!action) strerr_die2x(100,FATAL,ERR_NODEFAULT);
    if (!stralloc_copys(&target,sender)) die_nomem();
    if (action[0]) {
      i = str_chr(action,'-');
      if (action[i]) {
        action[i] = '\0';
        if (!stralloc_copys(&target,action + i + 1)) die_nomem();
        i = byte_rchr(target.s,target.len,'=');
        if (i < target.len)
	  target.s[i] = '@';
      }
    }
    if (!stralloc_0(&target)) die_nomem();

    if (case_diffs(action,ACTION_SUBSCRIBE) &&
      case_diffs(action,ALT_SUBSCRIBE) &&
      case_diffs(action,ACTION_UNSUBSCRIBE) &&
      case_diffs(action,ALT_UNSUBSCRIBE))
    _exit(0);			/* not for us */

    if (findname()) {
				/* new sender */
      if (!stralloc_copy(&from,&outlocal)) die_nomem();
      if (!stralloc_cats(&from,"-return-@")) die_nomem();
      if (!stralloc_cat(&from,&outhost)) die_nomem();
      if (!stralloc_0(&from)) die_nomem();
      nhost = name.s + str_rchr(name.s,'@');		/* name must have '@'*/
      *(nhost++) = '\0';
      if (!stralloc_copys(&to,name.s)) die_nomem();	/* local */
      if (!stralloc_append(&to,"-")) die_nomem();	/* - */
      if (!stralloc_cats(&to,action)) die_nomem();	/* subscribe */
      if (!stralloc_append(&to,"-")) die_nomem();	/* - */
      if (target.s[i = str_rchr(target.s,'@')])
	target.s[i] = '=';
      if (!stralloc_cats(&to,target.s)) die_nomem();	/* target */
      if (!stralloc_append(&to,"@")) die_nomem();	/* - */
      if (!stralloc_cats(&to,nhost)) die_nomem();	/* host */
      if (!stralloc_0(&to)) die_nomem();
      dtline = env_get("DTLINE");
      if (!dtline) strerr_die2x(100,FATAL,ERR_NODTLINE);

      if (qmail_open(&qq,(stralloc *) 0) == -1)
        strerr_die2sys(111,FATAL,ERR_QMAIL_QUEUE);
      qmail_puts(&qq,dtline);				/* delivered-to */
      if (qmail_copy(&qq,subfdin,0) != 0)
        strerr_die2sys(111,FATAL,ERR_READ_INPUT);
      qmail_from(&qq,from.s);
      qmail_to(&qq,to.s);

      if (*(err = qmail_close(&qq)) != '\0')
        strerr_die3x(111,FATAL,ERR_TMP_QMAIL_QUEUE,err + 1);

      strnum[fmt_ulong(strnum,qmail_qp(&qq))] = 0;
      strerr_die3x(99,INFO,"qp ",strnum);
    }
    _exit(0);
  } else {

    for (;;) {
      if (getln(subfdin,&line,&match,'\n') == -1)
	  strerr_die2sys(111,FATAL,ERR_READ_INPUT);
      if (!match) break;
      if (line.len == 1) continue;	/* ignore blank lines */
      if (line.s[0] == '#') continue;	/* ignore comments */
      if (!stralloc_copy(&target,&line)) die_nomem();
      target.s[target.len - 1] = '\0';
      (void) findname();
      if (!stralloc_cats(&name,": ")) die_nomem();
      if (!stralloc_cats(&name,target.s)) die_nomem();
      if (!stralloc_append(&name,"\n")) die_nomem();
      if (substdio_put(subfdout,name.s,name.len) == -1)
	strerr_die2sys(111,ERR_WRITE,"output: ");
    }
    if (substdio_flush(subfdout) == -1)
      strerr_die2sys(111,ERR_FLUSH,"output: ");
    _exit(0);
  }
  (void)argc;
}
Пример #5
0
int main(int argc,char **argv)
{
  char strnum[FMT_ULONG];
  char *action;
  char *dtline;
  char *nhost;
  const char *err;
  unsigned int i;
  int match;
  int opt;

  sig_pipeignore();

  opt = getconfopt(argc,argv,options,1,0);
  if (!(split = argv[opt]))
    split = "split";

  if (flagdo) {
    sender = get_sender();
    if (!sender) die_sender();
    if (!*sender)
      strerr_die2x(100,FATAL,MSG(ERR_BOUNCE));
    if (!sender[str_chr(sender,'@')])
      strerr_die2x(100,FATAL,MSG(ERR_ANONYMOUS));
    if (str_equal(sender,"#@[]"))
      strerr_die2x(100,FATAL,MSG(ERR_BOUNCE));

    action = env_get("DEFAULT");
    if (!action) strerr_die2x(100,FATAL,MSG(ERR_NODEFAULT));
    if (!stralloc_copys(&target,sender)) die_nomem();
    if (action[0]) {
      i = str_chr(action,'-');
      if (action[i]) {
        action[i] = '\0';
        if (!stralloc_copys(&target,action + i + 1)) die_nomem();
        i = byte_rchr(target.s,target.len,'=');
        if (i < target.len)
	  target.s[i] = '@';
      }
    }
    if (!stralloc_0(&target)) die_nomem();

    if (case_diffs(action,ACTION_SUBSCRIBE) &&
      case_diffs(action,ALT_SUBSCRIBE) &&
      case_diffs(action,ACTION_UNSUBSCRIBE) &&
      case_diffs(action,ALT_UNSUBSCRIBE))
    _exit(0);			/* not for us */

    if (findname()) {
				/* new sender */
      if (!stralloc_copy(&from,&outlocal)) die_nomem();
      if (!stralloc_cats(&from,"-return-@")) die_nomem();
      if (!stralloc_cat(&from,&outhost)) die_nomem();
      if (!stralloc_0(&from)) die_nomem();
      nhost = name.s + str_rchr(name.s,'@');		/* name must have '@'*/
      *(nhost++) = '\0';
      if (!stralloc_copys(&to,name.s)) die_nomem();	/* local */
      if (!stralloc_append(&to,'-')) die_nomem();	/* - */
      if (!stralloc_cats(&to,action)) die_nomem();	/* subscribe */
      if (!stralloc_append(&to,'-')) die_nomem();	/* - */
      if (target.s[i = str_rchr(target.s,'@')])
	target.s[i] = '=';
      if (!stralloc_cats(&to,target.s)) die_nomem();	/* target */
      if (!stralloc_append(&to,'@')) die_nomem();	/* - */
      if (!stralloc_cats(&to,nhost)) die_nomem();	/* host */
      if (!stralloc_0(&to)) die_nomem();
      dtline = env_get("DTLINE");
      if (!dtline) strerr_die2x(100,FATAL,MSG(ERR_NODTLINE));

      if (qmail_open(&qq) == -1)
        strerr_die2sys(111,FATAL,MSG(ERR_QMAIL_QUEUE));
      qmail_puts(&qq,dtline);				/* delivered-to */
      if (qmail_copy(&qq,subfdin,0) != 0)
        strerr_die2sys(111,FATAL,MSG(ERR_READ_INPUT));
      qmail_from(&qq,from.s);
      qmail_to(&qq,to.s);

      if (*(err = qmail_close(&qq)) != '\0')
        strerr_die4x(111,FATAL,MSG(ERR_TMP_QMAIL_QUEUE),": ",err + 1);

      strnum[fmt_ulong(strnum,qmail_qp(&qq))] = 0;
      strerr_die3x(99,INFO,"qp ",strnum);
    }
    _exit(0);
  } else {

    for (;;) {
      if (getln(subfdin,&line,&match,'\n') == -1)
	  strerr_die2sys(111,FATAL,MSG(ERR_READ_INPUT));
      if (!match) break;
      if (line.len == 1) continue;	/* ignore blank lines */
      if (line.s[0] == '#') continue;	/* ignore comments */
      if (!stralloc_copy(&target,&line)) die_nomem();
      target.s[target.len - 1] = '\0';
      (void) findname();
      if (!stralloc_cats(&name,": ")) die_nomem();
      if (!stralloc_cats(&name,target.s)) die_nomem();
      if (!stralloc_append(&name,'\n')) die_nomem();
      if (substdio_put(subfdout,name.s,name.len) == -1)
	strerr_die2sys(111,FATAL,MSG(ERR_WRITE_STDOUT));
    }
    if (substdio_flush(subfdout) == -1)
      strerr_die2sys(111,FATAL,MSG(ERR_FLUSH_STDOUT));
    _exit(0);
  }
  (void)argc;
}
Пример #6
0
int ltFunListInit(char *funconffile){
    
  xmlDocPtr doc;
    xmlNodePtr  node;
    xmlNodePtr  childnode;
  xmlNodePtr  tempRootNode;
    char *nodeMaxTime;
    char *nodeName;
    char *nodeDesc;
    char *nodeUrl;
    char *nodeType;
    char *nodeActive;
    char *nodeRightCheck;
    uint32 lFunCode;
    unsigned int i;
    unsigned int j;
    funList tmpFunList;

    
    for(i=0;i<NAS_MAX_FUNNUM;i++){
            _ltfunList[i].lFunCode=0;
            _ltfunList[i].funFlag=0;
            sprintf(_ltfunList[i].strFunName,"%s","");
            sprintf(_ltfunList[i].strFunUrl,"%s","");
            _ltfunList[i].maxruntime=NAS_DEFAULT_FUNTIME;
            _ltfunList[i].op=NULL;
    }
    
            _ltfunList[0].lFunCode=ltMd5Code("ltsSysCheck",strlen("ltsSysCheck"),"LT");;
            _ltfunList[0].funFlag=0;
            sprintf(_ltfunList[0].strFunName,"%s","ltsSysCheck");
            sprintf(_ltfunList[0].strFunUrl,"%s","");
            _ltfunList[0].maxruntime=60;
            _ltfunList[0].op=ltsSysCheck;
            

            
            
            
    doc=xmlParseFile(funconffile); 
    if(doc==NULL){
        return -1;
    }
    i=1;
    tempRootNode=xmlDocGetRootElement(doc);
    for(node = tempRootNode->children; node != NULL; node = node->next) {
      if(node->name!=NULL){
        /*begin core fun*/
            if(!case_diffs(node->name,"corefun")){
                for(childnode=node->children;childnode!=NULL;childnode=childnode->next){
                    nodeType=childnode->name;
                    nodeName=xmlGetProp(childnode,"name");
                    nodeMaxTime=xmlGetProp(childnode,"maxtime");
                    nodeDesc=xmlGetProp(childnode,"desc");
                    nodeUrl=xmlGetProp(childnode,"url");
                    nodeActive=xmlGetProp(childnode,"activeflag");
                    nodeRightCheck=xmlGetProp(childnode,"rightflag");
                    if(nodeType!=NULL && nodeName!=NULL && nodeMaxTime!=NULL && nodeDesc!=NULL && nodeUrl!=NULL && nodeActive!=NULL && nodeRightCheck!=NULL ){
                            for(j=0;j<NAS_MAX_COREFUNNUM;j++){
                                if(strcmp(_ltcorefunList[j].strFunName,nodeName)==0){
                                      lFunCode=ltMd5Code(nodeName,strlen(nodeName),"LT");
                                        _ltfunList[i].lFunCode=lFunCode;
                                        _ltfunList[i].funFlag=0;
                                        snprintf(_ltfunList[i].strFunName,63,"%s",nodeName);
                                        sprintf(_ltfunList[i].strFunUrl,"%s","");
                                        _ltfunList[i].maxruntime=atol(nodeMaxTime);
                                        _ltfunList[i].rightflag=atol(nodeRightCheck);
                                        _ltfunList[i].activeflag=atol(nodeActive);
                                        _ltfunList[i].op=_ltcorefunList[j].op;
                                        i++;
                                        break;
                            	}
                            }	
                    }
                }
            }
            /*end core fun*/
            /*begin sofun*/
            if(!case_diffs(node->name,"sofun")){
                for(childnode=node->children;childnode!=NULL;childnode=childnode->next){
                    nodeType=childnode->name;
                    nodeName=xmlGetProp(childnode,"name");
                    nodeMaxTime=xmlGetProp(childnode,"maxtime");
                    nodeDesc=xmlGetProp(childnode,"desc");
                    nodeUrl=xmlGetProp(childnode,"url");
                    nodeActive=xmlGetProp(childnode,"activeflag");
                    nodeRightCheck=xmlGetProp(childnode,"rightflag");
                    if(nodeType!=NULL && nodeName!=NULL && nodeMaxTime!=NULL && nodeDesc!=NULL && nodeUrl!=NULL && nodeActive!=NULL && nodeRightCheck!=NULL ){
                                      lFunCode=ltMd5Code(nodeName,strlen(nodeName),"LT");
                                        _ltfunList[i].lFunCode=lFunCode;
                                        _ltfunList[i].funFlag=1;
                                        snprintf(_ltfunList[i].strFunName,63,"%s",nodeName);
                                        snprintf(_ltfunList[i].strFunUrl,127,"%s",nodeUrl);
                                        _ltfunList[i].maxruntime=atol(nodeMaxTime);
                                        _ltfunList[i].rightflag=atol(nodeRightCheck);
                                        _ltfunList[i].activeflag=atol(nodeActive);
                                        _ltfunList[i].op=NULL;
                                        i++;
                    }
                }
            }
            /*end sofun*/
            /*begin appfun*/
            if(!case_diffs(node->name,"appfun")){
                for(childnode=node->children;childnode!=NULL;childnode=childnode->next){
                    nodeType=childnode->name;
                    nodeName=xmlGetProp(childnode,"name");
                    nodeMaxTime=xmlGetProp(childnode,"maxtime");
                    nodeDesc=xmlGetProp(childnode,"desc");
                    nodeUrl=xmlGetProp(childnode,"url");
                    nodeActive=xmlGetProp(childnode,"activeflag");
                    nodeRightCheck=xmlGetProp(childnode,"rightflag");
                    if(nodeType!=NULL && nodeName!=NULL && nodeMaxTime!=NULL && nodeDesc!=NULL && nodeUrl!=NULL && nodeActive!=NULL && nodeRightCheck!=NULL ){
                                      lFunCode=ltMd5Code(nodeName,strlen(nodeName),"LT");
                                        _ltfunList[i].lFunCode=lFunCode;
                                        _ltfunList[i].funFlag=3;
                                        snprintf(_ltfunList[i].strFunName,63,"%s",nodeName);
                                        snprintf(_ltfunList[i].strFunUrl,127,"%s",nodeUrl);
                                        _ltfunList[i].maxruntime=atol(nodeMaxTime);
                                        _ltfunList[i].rightflag=atol(nodeRightCheck);
                                        _ltfunList[i].activeflag=atol(nodeActive);
                                        _ltfunList[i].op=NULL;
                                        i++;
                    }
                }
            }
            /*end appfun*/
        }               
  }
  
  _ltPubInfo->maxfuntonnum=i;
  /*排序 按照lFunCode升序排列*/
  

  //模块注册
    ltSetFunListN("msasTestApp3",msasTestApp3);
    ltSetFunListN("msasTestApp4",msasTestApp4);
    ltSetFunListN("msasReportList",msasReportList);
  	ltSetFunListN("msasreportproc1",msasreportproc1);
  	ltSetFunListN("msasreportproc2",msasreportproc2);
  	ltSetFunListN("msasreportproc3",msasreportproc3);
  	ltSetFunListN("msasreportproc4",msasreportproc4);
  	ltSetFunListN("msasreportproc5",msasreportproc5);
  	ltSetFunListN("nasCvtLongTime",nasCvtLongTime);
  	ltSetFunListN("nasCvtStime",nasCvtStime);
  i=_ltPubInfo->maxfuntonnum;
  //printf("iiiiii:%d\n",i);
  //qsort(_ltfunList,i,sizeof(funList),nasSortFunList);
  
    xmlFreeDoc(doc);
    
    
    for(i=0;i<_ltPubInfo->maxfuntonnum-1;i++){
        for(j=_ltPubInfo->maxfuntonnum-1;j>i;j--){
            if( _ltfunList[j].lFunCode< _ltfunList[j-1].lFunCode){
                memcpy(&tmpFunList,&_ltfunList[j],sizeof(funList));
                memcpy(&_ltfunList[j],&_ltfunList[j-1],sizeof(funList));
                memcpy(&_ltfunList[j-1],&tmpFunList,sizeof(funList));
            }
        }
    }

    
//  for(i=0;i<_ltPubInfo->maxfuntonnum;i++){
//      printf("%d lFunCode==%u %s\n",i,_ltfunList[i].lFunCode, _ltfunList[i].strFunName);
//  }
    
    
    
    return 0;   
}
Пример #7
0
int ltFunListInit(char *funconffile){
	
  xmlDocPtr doc;
	xmlNodePtr  node;
	xmlNodePtr  childnode;
  xmlNodePtr  tempRootNode;
	char *nodeMaxTime;
	char *nodeName;
	char *nodeDesc;
	char *nodeUrl;
	char *nodeType;
	char *nodeActive;
	char *nodeRightCheck;
	uint32 lFunCode;
	unsigned int i;
	unsigned int j;
	funList tmpFunList;

	
	for(i=0;i<NAS_MAX_FUNNUM;i++){
			_ltfunList[i].lFunCode=0;
			_ltfunList[i].funFlag=0;
			sprintf(_ltfunList[i].strFunName,"%s","");
			sprintf(_ltfunList[i].strFunUrl,"%s","");
			_ltfunList[i].maxruntime=NAS_DEFAULT_FUNTIME;
			_ltfunList[i].op=NULL;
	}
	
			_ltfunList[0].lFunCode=ltMd5Code("ltsSysCheck",strlen("ltsSysCheck"),"LT");;
			_ltfunList[0].funFlag=0;
			sprintf(_ltfunList[0].strFunName,"%s","ltsSysCheck");
			sprintf(_ltfunList[0].strFunUrl,"%s","");
			_ltfunList[0].maxruntime=60;
			_ltfunList[0].op=ltsSysCheck;
			

			
			
			
	doc=xmlParseFile(funconffile); 
	if(doc==NULL){
		return -1;
	}
	i=1;
	tempRootNode=xmlDocGetRootElement(doc);
	for(node = tempRootNode->children; node != NULL; node = node->next) {
	  if(node->name!=NULL){
	  	/*begin core fun*/
			if(!case_diffs(node->name,"corefun")){
				for(childnode=node->children;childnode!=NULL;childnode=childnode->next){
					nodeType=childnode->name;
					nodeName=xmlGetProp(childnode,"name");
					nodeMaxTime=xmlGetProp(childnode,"maxtime");
					nodeDesc=xmlGetProp(childnode,"desc");
					nodeUrl=xmlGetProp(childnode,"url");
					nodeActive=xmlGetProp(childnode,"activeflag");
					nodeRightCheck=xmlGetProp(childnode,"rightflag");
					if(nodeType!=NULL && nodeName!=NULL && nodeMaxTime!=NULL && nodeDesc!=NULL && nodeUrl!=NULL && nodeActive!=NULL && nodeRightCheck!=NULL ){
							for(j=0;j<NAS_MAX_COREFUNNUM;j++){
								if(strcmp(_ltcorefunList[j].strFunName,nodeName)==0){
									  lFunCode=ltMd5Code(nodeName,strlen(nodeName),"LT");
										_ltfunList[i].lFunCode=lFunCode;
										_ltfunList[i].funFlag=0;
										snprintf(_ltfunList[i].strFunName,63,"%s",nodeName);
										sprintf(_ltfunList[i].strFunUrl,"%s","");
										_ltfunList[i].maxruntime=atol(nodeMaxTime);
										_ltfunList[i].rightflag=atol(nodeRightCheck);
										_ltfunList[i].activeflag=atol(nodeActive);
										_ltfunList[i].op=_ltcorefunList[j].op;
										i++;
										break;
								}
							}	
					}
				}
			}
			/*end core fun*/
			/*begin sofun*/
			if(!case_diffs(node->name,"sofun")){
				for(childnode=node->children;childnode!=NULL;childnode=childnode->next){
					nodeType=childnode->name;
					nodeName=xmlGetProp(childnode,"name");
					nodeMaxTime=xmlGetProp(childnode,"maxtime");
					nodeDesc=xmlGetProp(childnode,"desc");
					nodeUrl=xmlGetProp(childnode,"url");
					nodeActive=xmlGetProp(childnode,"activeflag");
					nodeRightCheck=xmlGetProp(childnode,"rightflag");
					if(nodeType!=NULL && nodeName!=NULL && nodeMaxTime!=NULL && nodeDesc!=NULL && nodeUrl!=NULL && nodeActive!=NULL && nodeRightCheck!=NULL ){
									  lFunCode=ltMd5Code(nodeName,strlen(nodeName),"LT");
										_ltfunList[i].lFunCode=lFunCode;
										_ltfunList[i].funFlag=1;
										snprintf(_ltfunList[i].strFunName,63,"%s",nodeName);
										snprintf(_ltfunList[i].strFunUrl,127,"%s",nodeUrl);
										_ltfunList[i].maxruntime=atol(nodeMaxTime);
										_ltfunList[i].rightflag=atol(nodeRightCheck);
										_ltfunList[i].activeflag=atol(nodeActive);
										_ltfunList[i].op=NULL;
										i++;
					}
				}
			}
			/*end sofun*/
			/*begin appfun*/
			if(!case_diffs(node->name,"appfun")){
				for(childnode=node->children;childnode!=NULL;childnode=childnode->next){
					nodeType=childnode->name;
					nodeName=xmlGetProp(childnode,"name");
					nodeMaxTime=xmlGetProp(childnode,"maxtime");
					nodeDesc=xmlGetProp(childnode,"desc");
					nodeUrl=xmlGetProp(childnode,"url");
					nodeActive=xmlGetProp(childnode,"activeflag");
					nodeRightCheck=xmlGetProp(childnode,"rightflag");
					if(nodeType!=NULL && nodeName!=NULL && nodeMaxTime!=NULL && nodeDesc!=NULL && nodeUrl!=NULL && nodeActive!=NULL && nodeRightCheck!=NULL ){
									  lFunCode=ltMd5Code(nodeName,strlen(nodeName),"LT");
										_ltfunList[i].lFunCode=lFunCode;
										_ltfunList[i].funFlag=3;
										snprintf(_ltfunList[i].strFunName,63,"%s",nodeName);
										snprintf(_ltfunList[i].strFunUrl,127,"%s",nodeUrl);
										_ltfunList[i].maxruntime=atol(nodeMaxTime);
										_ltfunList[i].rightflag=atol(nodeRightCheck);
										_ltfunList[i].activeflag=atol(nodeActive);
										_ltfunList[i].op=NULL;
										i++;
					}
				}
			}
			/*end appfun*/
		}				
  }
  
  _ltPubInfo->maxfuntonnum=i;
  /*排序 按照lFunCode升序排列*/
  ltSetFunListN("msasReportList",msasReportList);
  ltSetFunListN("msasDataCenetrDownLoad",msasDataCenetrDownLoad);
  ltSetFunListN("msasShowAdminLogon",msasShowAdminLogon);
  ltSetFunListN("msasAdminLogon",msasAdminLogon);
	ltSetFunListN("msasAdminLogout",msasAdminLogout);
	ltSetFunListN("msaShowTopview",msaShowTopview);
	
	/*srv-group.c*/
	ltSetFunListN("msasGroupTree",msasGroupTree);
	ltSetFunListN("msasGroupAction",msasGroupAction);
	ltSetFunListN("msasShowAddClient",msasShowAddClient);
	ltSetFunListN("msasTerminfoAdd",msasTerminfoAdd);
	ltSetFunListN("msasTermInfoUpdate",msasTermInfoUpdate);
	ltSetFunListN("msasTermInfoView",msasTermInfoView);
	ltSetFunListN("msasShowClientList",msasShowClientList);
	ltSetFunListN("msasClientList",msasClientList);
	ltSetFunListN("msasAdminUserList",msasAdminUserList);
	ltSetFunListN("msasAdminAction",msasAdminAction);
	ltSetFunListN("msasCheckOutAdmin",msasCheckOutAdmin);
	ltSetFunListN("msasAdmuserList",msasAdmuserList);
	ltSetFunListN("vpnonlineuser",vpnonlineuser);
	ltSetFunListN("tovpnsetting",tovpnsetting);
	ltSetFunListN("vpnsetting",vpnsetting);
	
	/*srv-now.c*/
	ltSetFunListN("msasAdmlog",msasAdmlog);
	ltSetFunListN("msasSysReset",msasSysReset);
	ltSetFunListN("msasSysShutdown",msasSysShutdown);
	ltSetFunListN("msasShowXTZY",msasShowXTZY);
	ltSetFunListN("msasZaixianInfo",msasZaixianInfo);
	ltSetFunListN("msasHostList",msasHostList);
	ltSetFunListN("msasSrvInfo",msasSrvInfo);
	ltSetFunListN("msasShowHostList",msasShowHostList);
	ltSetFunListN("msasGetAlertNow",msasGetAlertNow);
	ltSetFunListN("msasShowClientSrv",msasShowClientSrv);
	
	/*srv-data.c*/
	ltSetFunListN("msasRealIdList",msasRealIdList);
	ltSetFunListN("msasNetIdList",msasNetIdList);
	ltSetFunListN("msasNetIdTrackList",msasNetIdTrackList);
	ltSetFunListN("msasClientOnOff",msasClientOnOff);
	ltSetFunListN("msasShowAccessList",msasShowAccessList);
	ltSetFunListN("msasAccessList",msasAccessList);
	ltSetFunListN("msasSearchTree",msasSearchTree);
	ltSetFunListN("msasShowAccessSearch",msasShowAccessSearch);
	ltSetFunListN("msasIpbackSearch",msasIpbackSearch);
	ltSetFunListN("msasNewSearchList",msasNewSearchList);
	ltSetFunListN("msasAccesssCmdSet",msasAccesssCmdSet);
	ltSetFunListN("msasYunSearchList",msasYunSearchList);
	ltSetFunListN("msasShowYunSearch",msasShowYunSearch);
	ltSetFunListN("msasYunSearchCMDList",msasYunSearchCMDList);
	ltSetFunListN("msasYunSearchDel",msasYunSearchDel);
	ltSetFunListN("msasSearchShowList",msasSearchShowList);
	ltSetFunListN("msasGetInfoByKey",msasGetInfoByKey);
	ltSetFunListN("msasSearchShowListt",msasSearchShowListt);
	ltSetFunListN("msasShKeyList",msasShKeyList);
	ltSetFunListN("msasShKeySearch",msasShKeySearch);
	ltSetFunListN("msasShowjson",msasShowjson);
  ltSetFunListN("msasShowYunSearchPage",msasShowYunSearchPage);
	
	/*srv-rule.c*/
	ltSetFunListN("msasAnjianAction",msasAnjianAction);
	ltSetFunListN("msasAlertAnJianAction",msasAlertAnJianAction);
	ltSetFunListN("msasRuleListAction",msasRuleListAction);
	ltSetFunListN("msasShowRule",msasShowRule);
	ltSetFunListN("msasAlertRuleAction",msasAlertRuleAction);
	ltSetFunListN("msasRuleAnJianAction",msasRuleAnJianAction);
	ltSetFunListN("msasRuleTypeAction",msasRuleTypeAction);

	ltSetFunListN("msasAnjianTree",msasAnjianTree);
	ltSetFunListN("msasShowAnJian",msasShowAnJian);
	ltSetFunListN("msasShowanjianPage",msasShowanjianPage);
	ltSetFunListN("msasAddanjianAction",msasAddanjianAction);
	ltSetFunListN("msasUpdateanjianAction",msasUpdateanjianAction);
	ltSetFunListN("msasAddAction",msasAddAction);
  ltSetFunListN("msasShowRulePage",msasShowRulePage);
	ltSetFunListN("msasAlertRuleLsit",msasAlertRuleLsit);
	
	/*srv-report.c*/
	ltSetFunListN("msasreportproc",msasreportproc);
	ltSetFunListN("msasreportproc1",msasreportproc1);

	
  i=_ltPubInfo->maxfuntonnum;
  //printf("iiiiii:%d\n",i);
  //qsort(_ltfunList,i,sizeof(funList),nasSortFunList);
  
	xmlFreeDoc(doc);
	
	
	for(i=0;i<_ltPubInfo->maxfuntonnum-1;i++){
		for(j=_ltPubInfo->maxfuntonnum-1;j>i;j--){
			if(	_ltfunList[j].lFunCode< _ltfunList[j-1].lFunCode){
				memcpy(&tmpFunList,&_ltfunList[j],sizeof(funList));
				memcpy(&_ltfunList[j],&_ltfunList[j-1],sizeof(funList));
				memcpy(&_ltfunList[j-1],&tmpFunList,sizeof(funList));
			}
		}
	}

	
//	for(i=0;i<_ltPubInfo->maxfuntonnum;i++){
//		printf("%d lFunCode==%u %s\n",i,_ltfunList[i].lFunCode, _ltfunList[i].strFunName);
//	}
	
	
	
	return 0;	
}
Пример #8
0
int main(int argc, char **argv)
{
	enum { unset, uid, mail, filter } mode = unset;
	qldap	*q, *qpw;
	struct passwd *pw;
	char	*passwd = 0, *value = 0;
	char	*bindpw = 0, *binddn = 0;
	char	*f, *s;
	int	opt, r, done, status, id;
	unsigned int j, slen;
	unsigned long size, count, maxsize;
	
	const char *attrs[] = { LDAP_MAIL,
				LDAP_MAILALTERNATE,
				LDAP_UID,
				LDAP_QMAILUID,
				LDAP_QMAILGID,
				LDAP_ISACTIVE,
				LDAP_MAILHOST,
				LDAP_MAILSTORE,
				LDAP_HOMEDIR,
				LDAP_QUOTA_SIZE,
				LDAP_QUOTA_COUNT,
				LDAP_FORWARDS,
				LDAP_PROGRAM,
				LDAP_MODE,
				LDAP_REPLYTEXT,
				LDAP_DOTMODE,
				LDAP_MAXMSIZE,
				LDAP_OBJECTCLASS,
#if 0
				LDAP_GROUPCONFIRM,
				LDAP_GROUPMEMONLY,
				LDAP_GROUPCONFRIMTEXT,
				LDAP_GROUPMODERATTEXT,
				LDAP_GROUPMODERATDN,
				LDAP_GROUPMODERAT822,
				LDAP_GROUPMEMBERDN,
				LDAP_GROUPMEMBER822,
				LDAP_GROUPMEMBERFILTER,
#endif
				LDAP_PASSWD,
				0};

	while ((opt = getopt(argc, argv, "d:D:u:m:p:f:w:")) != opteof)
		switch (opt) {
		case 'd':
			if (env_put2("LOGLEVEL", optarg) == 0)
				strerr_die2sys(1, FATAL, "setting loglevel: ");
			break;
		case 'D':
			binddn = optarg;
			break;
		case 'u':
			if (value != 0)
				usage();
			value = optarg;
			mode = uid;
			break;
		case 'm':
			if (value != 0)
				usage();
			value = optarg;
			mode = mail;
			break;
		case 'f':
			if (value != 0)
				usage();
			value = optarg;
			mode = filter;
			break;
		case 'p':
			if (geteuid() != 0)
				strerr_die2x(1, FATAL,
				    "only the superuser may comapre passwords");
			passwd = optarg;
			break;
		case 'w':
			bindpw = optarg;
			break;
		default:
			usage();
		}
	if (argc != optind) usage();
	if (bindpw && !binddn) usage();
	
	log_init(STDERR, -1, 0);

	if (read_controls(ctrls) != 0)
		strerr_die2sys(111, FATAL, "unable to read controls: ");
	
	q = qldap_new();
	if (q == 0)
		strerr_die2sys(111, FATAL, "qldap_new failed: ");
	qpw = qldap_new();
	if (qpw == 0)
		strerr_die2sys(111, FATAL, "qldap_new failed: ");
	
	r = qldap_open(q);
	if (r != OK) fail(q, "qldap_open", r);
	r = qldap_open(qpw);
	if (r != OK) fail(qpw, "qldap_open", r);
	r = qldap_bind(q, binddn, bindpw);
	if (r != OK) fail(q, "qldap_bind", r);

	if (passwd == 0 || mode != uid || qldap_need_rebind() != 0)
		attrs[sizeof(attrs)/4 - 2] = 0; /* password */
	done = 0;
	f = 0;
	do {
		switch (mode) {
		case mail:
			f = filter_mail(value, &done);
			if (value == 0)
				strerr_die2sys(1, FATAL, "building filter: ");
			break;
		case uid:
			f = filter_uid(value);
			done = 1;
			if (value == 0)
				strerr_die2sys(1, FATAL, "building filter: ");
			break;
		case filter:
			f = value;
			break;
		default:
			usage();
		}
		output(subfdout, "Searching ldap for: %s\nunder dn: %s\n",
		    f, qldap_basedn());
		r = qldap_filter(q, f, attrs, qldap_basedn(), SCOPE_SUBTREE);
		if (r != OK) fail(q, "qldap_filter", r);

		r = qldap_count(q);
		switch (r) {
		case -1:
			fail(q, "qldap_count", FAILED);
		case 0:
			output(subfdout, "No entries found.\n");
			qldap_free(q);
			/* TODO hook for local lookups. */
			return 0;
		case 1:
			output(subfdout, "Found %i entry:\n", r);
			break;
		default:
			output(subfdout, "Found %i entries:\n", r);
			if (mode == uid || mode == uid) {
				output(subfdout,
				    "Uh-oh: multiple entries found but "
				    "should be unique!\n");
				passwd = 0;
			}
			break;
		}
		output(subfdout, "\n");
	} while (r == 0 && !done);

	r = qldap_first(q);
	if (r != OK) fail(q, "qldap_first", r);;
	do {
		r = qldap_get_dn(q, &dn);
		if (r != OK) fail(q, "qldap_get_dn", r);
		output(subfdout, "dn: %s\n"
		    "-------------------------------------------------------\n",
		    dn.s);
		
		r = qldap_get_attr(q, LDAP_OBJECTCLASS, &foo, MULTI_VALUE);
		if (r != OK) fail(q, "qldap_get_attr(" LDAP_OBJECTCLASS ")", r);
		unescape(foo.s, &bar);
		s = bar.s;
		slen = bar.len-1;
		for(;;) {
			output(subfdout, "%s: %s\n",LDAP_OBJECTCLASS ,s);
			j = byte_chr(s,slen,0);
			if (j++ >= slen) break;
			s += j; slen -= j;
		}
		
		r = qldap_get_attr(q, LDAP_MAIL, &foo, SINGLE_VALUE);
		if (r != OK) fail(q, "qldap_get_attr(" LDAP_MAIL ")", r);
		output(subfdout, "%s: %s\n", LDAP_MAIL, foo.s);

		r = qldap_get_attr(q, LDAP_MAILALTERNATE, &foo, MULTI_VALUE);
		if (r != OK && r != NOSUCH)
			fail(q, "qldap_get_attr(" LDAP_MAILALTERNATE ")", r);
		if (r == OK) {
			unescape(foo.s, &bar);
			s = bar.s;
			slen = bar.len-1;
			for(;;) {
				output(subfdout, "%s: %s\n",
				    LDAP_MAILALTERNATE, s);
				j = byte_chr(s,slen,0);
				if (j++ >= slen) break;
				s += j; slen -= j;
			}
		}
		
		r = qldap_get_user(q, &foo);
		if (r != OK && r != NOSUCH) fail(q, "qldap_get_user", r);
		if (r == OK)
			output(subfdout, "%s: %s\n", LDAP_UID, foo.s);
		else
			output(subfdout, "%s: undefined "
			    "(forward only account required)\n", LDAP_UID);

		r = qldap_get_status(q, &status);
		if (r != OK) fail(q, "qldap_get_status", r);
		switch (status) {
		case STATUS_BOUNCE:
			output(subfdout, "%s: %s\n",
			    LDAP_ISACTIVE, ISACTIVE_BOUNCE);
			break;
		case STATUS_NOACCESS:
			output(subfdout, "%s: %s\n",
			    LDAP_ISACTIVE, ISACTIVE_NOACCESS);
			break;
		case STATUS_OK:
			output(subfdout, "%s: %s\n",
			    LDAP_ISACTIVE, ISACTIVE_ACTIVE);
			break;
		case STATUS_UNDEF:
			output(subfdout, "%s: %s\n", LDAP_ISACTIVE,
			    "undefined -> active");
			break;
		default:
			strerr_warn2(WARN,
			    "qldap_get_status returned unknown status", 0);
		}
		
		r = qldap_get_attr(q, LDAP_MAILHOST, &foo, SINGLE_VALUE);
		if (r != OK && r != NOSUCH)
			fail(q, "qldap_get_attr(" LDAP_MAILHOST ")", r);
		if (r == OK) {
			output(subfdout, "%s: %s\n", LDAP_MAILHOST, foo.s);
			/*
			 * TODO we could check if we are in cluster mode and 
			 * if we would redirect to a differnet host
			 */
		} else
			output(subfdout, "%s: undefined\n", LDAP_MAILHOST);

		/* get the path of the maildir or mbox */
		r = qldap_get_mailstore(q, &foo, &bar);
		switch (r) {
		case OK:
			output(subfdout, "homeDirectory: %s\n", foo.s);
			if (bar.len > 0)
				output(subfdout, "aliasEmpty: %s\n", bar.s);
			else
				output(subfdout, "aliasEmpty: using default\n");
			break;
		case NEEDED:
			output(subfdout,
			    "forward only delivery via alias user\n");
			pw = getpwnam(auto_usera);
			if (!pw)
				strerr_die4x(100, FATAL,
				    "Aiiieeeee, now alias user '",
				    auto_usera, "'found in /etc/passwd.");
			output(subfdout, "alias user: %s\n", pw->pw_name);
			output(subfdout, "alias user uid: %i\n", pw->pw_uid);
			output(subfdout, "alias user gid: %i\n", pw->pw_gid);
			output(subfdout, "alias user home: %s\n", pw->pw_dir);
			output(subfdout, "alias user aliasempty: %s\n",
			    ALIASDEVNULL);
			/* get the forwarding addresses */
			r = qldap_get_attr(q, LDAP_FORWARDS, &foo, MULTI_VALUE);
			if (r != OK)
				fail(q, "qldap_get_attr("
				    LDAP_FORWARDS ") for forward only user", r);
			unescape(foo.s, &bar);
			s = bar.s;
			slen = bar.len-1;
			for(;;) {
				output(subfdout, "%s: %s\n", LDAP_FORWARDS, s);
				j = byte_chr(s,slen,0);
				if (j++ >= slen) break;
				s += j; slen -= j;
			}
			goto next;
		default:
			fail(q, "qldap_get_mailstore", r);
		}
		
		r = qldap_get_dotmode(q, &foo);
		if (r != OK) fail(q, "qldap_get_dotmode", r);
		output(subfdout, "%s: %s\n", LDAP_DOTMODE, foo.s);

		r = qldap_get_uid(q, &id);
		if (r != OK) fail(q, "qldap_get_uid", r);
		output(subfdout, "%s: %i\n", LDAP_QMAILUID, id);
		
		r = qldap_get_gid(q, &id);
		if (r != OK) fail(q, "qldap_get_gid", r);
		output(subfdout, "%s: %i\n", LDAP_QMAILGID, id);
		
		r = qldap_get_quota(q, &size, &count, &maxsize);
		if (r != OK) fail(q, "qldap_get_quota", r);
		output(subfdout, "%s: %u%s\n", LDAP_QUOTA_SIZE, size,
		    size==0?" (unlimited)":"");
		output(subfdout, "%s: %u%s\n", LDAP_QUOTA_COUNT, count,
		    count==0?" (unlimited)":"");
		output(subfdout, "%s: %u%s\n", LDAP_MAXMSIZE, maxsize,
		    maxsize==0?" (unlimited)":"");

		r = qldap_get_attr(q, LDAP_MODE, &foo, MULTI_VALUE);
		if (r != OK && r != NOSUCH)
			fail(q, "qldap_get_attr(" LDAP_MODE ")", r);
		if (r == OK) {
			unescape(foo.s, &bar);
			s = bar.s;
			slen = bar.len-1;
			for(;;) {
				if (case_diffs(MODE_FORWARD, s) &&
				    case_diffs(MODE_REPLY, s) &&
				    case_diffs(MODE_NOLOCAL, s) &&
				    case_diffs(MODE_NOMBOX, s) &&
				    case_diffs(MODE_NOFORWARD, s) &&
				    case_diffs(MODE_NOPROG, s) &&
				    case_diffs(MODE_LOCAL, s) &&
				    case_diffs(MODE_FORWARD, s) &&
				    case_diffs(MODE_PROG, s) &&
				    case_diffs(MODE_NOREPLY, s))
					strerr_warn4(WARN,
					    "undefined mail delivery mode: ",
					    s," (ignored).", 0);
				else if (!case_diffs(MODE_FORWARD, s))
					strerr_warn4(WARN,
					    "mail delivery mode: ",
					    s," should not be used "
					    "(used internally).", 0);
				output(subfdout, "%s: %s\n", LDAP_MODE, s);
				j = byte_chr(s,slen,0);
				if (j++ >= slen) break;
				s += j; slen -= j;
			}
		}

		r = qldap_get_attr(q, LDAP_FORWARDS, &foo, MULTI_VALUE);
		if (r != OK && r != NOSUCH)
			fail(q, "qldap_get_attr(" LDAP_FORWARDS ")", r);
		if (r == OK) {
			unescape(foo.s, &bar);
			s = bar.s;
			slen = bar.len-1;
			for(;;) {
				output(subfdout, "%s: %s\n", LDAP_FORWARDS, s);
				j = byte_chr(s,slen,0);
				if (j++ >= slen) break;
				s += j; slen -= j;
			}
		}

		r = qldap_get_attr(q, LDAP_PROGRAM, &foo, MULTI_VALUE);
		if (r != OK && r != NOSUCH)
			fail(q, "qldap_get_attr(" LDAP_PROGRAM ")", r);
		if (r == OK) {
			unescape(foo.s, &bar);
			s = bar.s;
			slen = bar.len-1;
			for(;;) {
				output(subfdout, "%s: %s\n", LDAP_PROGRAM, s);
				j = byte_chr(s,slen,0);
				if (j++ >= slen) break;
				s += j; slen -= j;
			}
		}

		r = qldap_get_attr(q, LDAP_REPLYTEXT, &foo, SINGLE_VALUE);
		if (r != OK && r != NOSUCH)
			fail(q, "qldap_get_attr(" LDAP_REPLYTEXT ")", r);
		if (r == OK)
			output(subfdout, "%s:\n=== begin ===\n%s\n"
			    "=== end ===\n", LDAP_REPLYTEXT, foo.s);
		else
			output(subfdout, "%s: undefined\n", LDAP_REPLYTEXT);

		if (mode == uid && passwd != 0) {
			if (qldap_need_rebind() == 0) {
				r = qldap_get_attr(q, LDAP_PASSWD,
				    &foo, SINGLE_VALUE);
				if (r != OK) fail(q, "qldap_get_attr("
				    LDAP_PASSWD ")", r);
				r = cmp_passwd(passwd, foo.s);
			} else {
				r = qldap_rebind(qpw, dn.s, passwd);
				switch (r) {
				case OK:
					r = OK;
					break;
				case LDAP_BIND_AUTH:
					r = BADPASS;
					break;
				default:
					break;
				}
			}
			output(subfdout, "\nPASSWORD COMPARE was %s.\n",
			    r == OK?"successful":"NOT successful");
			if (r != OK)
				output(subfdout, "\terror was: %s\n",
				    qldap_err_str(r));
		}

next:
		r = qldap_next(q);
		output(subfdout, "\n\n");
	} while (r == OK);
	if (r != NOSUCH) fail(q, "qldap_next", r);
	qldap_free(q);
	return 0;
}