开发者社区> 问答> 正文

php怎样调用应用程序?

我按照网上说的编译了程序,在我本地可以通过网页调用了,但是ecs上还是不行?

/* # ScriptName: transeuid.c

Author: JH Gao gaopenghigh@gmail.com

Create Date: 2012-06-05

Function: transmit euid and egid to other scripts

since shell/python/... scripts can't get suid permission in Linux

usage: transeuid xxx.sh par1 par2 par3

xxx.sh will get the euid and egid from transeuid

*/

include

include

include

define BUFFSIZE 1024

/*

  • usually euid is the uid who run the program
  • but when stick is setted to the program
  • euid is the uid or the program's owner
    */

int main(int argc, char *argv[]) {

char *cmd = malloc(BUFFSIZE);
// set uid and gid to euid and egid
setuid(geteuid());
setgid(getegid());
cmd = argv[1];
int i = 0;
for(i = 0;i < argc - 1;i++) {
    argv[i] = argv[i+1];
}

argv[argc-1] = NULL;

// search $PATH find this cmd and run it with pars:argv
if (execvp(cmd, argv)) {
    printf("error");
    free(cmd);
    exit(1);
}
free(cmd);

}

展开
收起
kkaca 2016-02-18 20:45:22 2230 0
1 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
PHP安全开发:从白帽角度做安全 立即下载
PHP 2017.北京 全球开发者大会——高可用的PHP 立即下载
复杂PHP系统性能瓶颈排查及优化 立即下载