*/
#ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.53 1999/02/26 10:38:51 paulus Exp $";
+static char rcsid[] = "$Id: main.c,v 1.56 1999/03/06 11:28:10 paulus Exp $";
#endif
#include <stdio.h>
hungup = 0;
kill_link = 0;
sigprocmask(SIG_UNBLOCK, &mask, NULL);
- while ((ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0)) < 0) {
+ for (;;) {
+ /* If the user specified the device name, become the
+ user before opening it. */
+ if (!devnam_info.priv)
+ seteuid(uid);
+ ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
+ if (!devnam_info.priv)
+ seteuid(0);
+ if (ttyfd >= 0)
+ break;
if (errno != EINTR)
syslog(LOG_ERR, "Failed to open %s: %m", devnam);
if (!persist || errno != EINTR)
/* reopen tty if necessary to wait for carrier */
if (connector == NULL && modem) {
- while ((i = open(devnam, O_RDWR)) < 0) {
+ for (;;) {
+ if (!devnam_info.priv)
+ seteuid(uid);
+ i = open(devnam, O_RDWR);
+ if (!devnam_info.priv)
+ seteuid(0);
+ if (i >= 0)
+ break;
if (errno != EINTR)
syslog(LOG_ERR, "Failed to reopen %s: %m", devnam);
if (!persist || errno != EINTR || hungup || kill_link)
close(errfd);
}
}
- setuid(getuid());
+ setuid(uid);
setgid(getgid());
execl("/bin/sh", "sh", "-c", program, (char *)0);
syslog(LOG_ERR, "could not exec /bin/sh: %m");
int new_fd;
/* Leave the current location */
- (void) setsid(); /* No controlling tty. */
+ (void) setsid(); /* No controlling tty. */
(void) umask (S_IRWXG|S_IRWXO);
- (void) chdir ("/"); /* no current directory. */
- setuid(geteuid());
+ (void) chdir ("/"); /* no current directory. */
+ setuid(0); /* set real UID = root */
setgid(getegid());
/* Ensure that nothing of our device environment is inherited. */
}
}
- for (; len > 0; --len) {
+ for (i = 0; i < len && i < 32; ++i) {
GETCHAR(x, p);
printer(arg, " %.2x", x);
}
+ if (i < len)
+ printer(arg, " ...");
}
static void