qmail-local代码分析[5]

[入库:2005年9月21日] [更新:2007年3月24日]

本文简介:

   return -1;
  }
 return 0;
}
//qme文件存在且是一般文件返回1,否则为0
int qmeexists(fd,cutable)
int *fd;
int *cutable;
{
  struct stat st;

  if (!stralloc_0(&qme)) temp_nomem();

  *fd = open_read(qme.s);
  if (*fd == -1) {
    if (error_temp(errno)) temp_qmail(qme.s);
    if (errno == error_perm) temp_qmail(qme.s);
    if (errno == error_acces) temp_qmail(qme.s);
    return 0;
  }

  if (fstat(*fd,&st) == -1) temp_qmail(qme.s);
//S_IFREG表示一般文件  
  if ((st.st_mode & S_IFMT) == S_IFREG) {
    if (st.st_mode & auto_patrn)
      strerr_die1x(111,"Uh-oh:; .qmail file is writable. (#4.7.0)");
    *cutable = !!(st.st_mode & 0100);//看文件的owner权限是否为可执行的。是*cutable = 1,不是*cutable = 0
    return 1;
  }
  close(*fd);
  return 0;
}

/* "" "":; "" */
/* "-/" "":; "-/" "-/default" */
/* "-/" "a":; "-/a" "-/default" */
/* "-/" "a-":; "-/a-" "-/a-default" "-/default" */
/* "-/" "a-b":; "-/a-b" "-/a-default" "-/default" */
/* "-/" "a-b-":; "-/a-b-" "-/a-b-default" "-/a-default" "-/default" */
/* "-/" "a-b-c":; "-/a-b-c" "-/a-b-default" "-/a-default" "-/default" */
//打开文件&qme,如是一般文件再看是否为default,如果是,"DEFAULT"+*(ext+i)结合加入
void qmesearch(fd,cutable)
int *fd;
int *cutable;
{
  int i;

  if (!stralloc_copys(&qme,".qmail")) temp_nomem();
  if (!stralloc_cats(&qme,dash)) temp_nomem();
  if (!stralloc_cat(&qme,&safeext)) temp_nomem();
  if (qmeexists(fd,cutable)) {
    if (safeext.len >= 7) {
      i = safeext.len - 7;
      if (!byte_diff("default",7,safeext.s + i))
if (i <= str_len(ext)) /* paranoia */
  if (!env_put2("DEFAULT",ext + i)) temp_nomem();
    }
    return;
  }

  for (i = safeext.len;i >= 0;--i)
    if (!i || (safeext.s[i - 1] == '-')) {
      if (!stralloc_copys(&qme,".qmail")) temp_nomem();
      if (!stralloc_cats(&qme,dash)) temp_nomem();
      if (!stralloc_catb(&qme,safeext.s,i)) temp_nomem();
      if (!stralloc_cats(&qme,"default")) temp_nomem();
      if (qmeexists(fd,cutable)) {
if (i <= str_len(ext)) /* paranoia */
  if (!env_put2("DEFAULT",ext + i)) temp_nomem();
        return;
      }
    }

  *fd = -1;
}

本文关键:qmail-local代码分析
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top