Но когда для su не выделен pty, возникает ошибка:
Код: Выделить всё
su: must be run from a terminal
Код: Выделить всё
#include
#include
#include
#include
int main (int argc, char *argv[])
{
int fd;
char* args[] = {"/bin/su", "-l", "anotheruser", NULL };
char name[16] = {0};
int pid ;
pid = forkpty(&fd, name, NULL, NULL);
if (pid != -1) {
printf("\n pty: [%s]\n", name);
if (execve(args[0], args, NULL) == -1) {
printf("\n execve: failed\n");
}
} else {
printf("\n forkpty: failed \n");
}
return 0;
}
Я что-то упускаю, но не могу понять.. нужно ли мне
перенаправить стандартный ввод/ stdout перед execve()?
Подробнее здесь: https://stackoverflow.com/questions/788 ... u-in-a-pty
Мобильная версия