From owner-freebsd-questions Thu May 31 12:22:36 2001 Delivered-To: freebsd-questions@freebsd.org Received: from cal30b054.student.utwente.nl (cal30b054.student.utwente.nl [130.89.229.25]) by hub.freebsd.org (Postfix) with ESMTP id EDA5537B42C for ; Thu, 31 May 2001 12:22:32 -0700 (PDT) (envelope-from havoc@cal30b054.student.utwente.nl) Received: (from havoc@localhost) by cal30b054.student.utwente.nl (8.11.3/8.11.3) id f4VJMVl10610 for freebsd-questions@freebsd.org; Thu, 31 May 2001 21:22:31 +0200 (CEST) (envelope-from havoc) Date: Thu, 31 May 2001 21:22:30 +0200 From: Theo van Klaveren To: freebsd-questions@freebsd.org Subject: SU and PTYs Message-ID: <20010531212230.A10596@phoenix.student.utwente.nl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I'm trying to let a program get super-user rights by calling su in a pseudo-terminal (the attached program demonstrates this). This however does not work, because su gets stuck in ttywait. Can anyone tell me what I'm doing wrong, or at least provide me with a program that does do the trick? Thanks in advance, Theo P.S. Please reply to me directly. I am not subscribed. -- Theo van Klaveren http://home.student.utwente.nl/t.vanklaveren --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="test.c" #include #include #include #include #include int main (int argc, char **argv) { int fd, fds; pid_t pid; if ((pid = forkpty(&fd, NULL, NULL, NULL)) < 0) { perror ("fork"); exit (-1); } if (pid > 0) { write (fds, "mypasswd\n", strlen("mypasswd\n")); waitpid (pid, NULL, 0); _exit(0); } else { execlp ("su", "su", NULL); } } --qMm9M+Fa2AknHoGS-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message