23,121
社区成员
发帖
与我相关
我的任务
分享
switch (pid = fork()) {
case -1:
perror("fork");
goto fatal;
case 0:
/* child */
if (setgid(MY_GID(pw)) < 0) {
perror("setgid(getgid())");
exit(ERROR_EXIT);
}
if (setuid(MY_UID(pw)) < 0) {
perror("setuid(getuid())");
exit(ERROR_EXIT);
}
if (chdir(_PATH_TMP) < 0) {
perror(_PATH_TMP);
exit(ERROR_EXIT);
}
if (!glue_strings(q, sizeof q, editor, Filename, ' ')) {
fprintf(stderr, "%s: editor command line too long\n",
ProgramName);
exit(ERROR_EXIT);
}
execlp(_PATH_BSHELL, _PATH_BSHELL, "-c", q, (char *)0);
perror(editor);
exit(ERROR_EXIT);
/*NOTREACHED*/
default:
/* parent */
break;
}