|
Line
Link Here
|
| 0 |
-- session.c 2005-08-25 17:01:54.000000000 +0530 |
0 |
++ session.c-securetty 2005-10-25 19:33:52.000000000 +0530 |
|
Lines 1566-1571
Link Here
|
| 1566 |
close(i); |
1566 |
close(i); |
| 1567 |
} |
1567 |
} |
| 1568 |
|
1568 |
|
|
|
1569 |
int |
| 1570 |
check_securetty(char *namebuf) |
| 1571 |
{ |
| 1572 |
|
| 1573 |
FILE *f; |
| 1574 |
char buf[1024]; |
| 1575 |
struct stat sb; |
| 1576 |
|
| 1577 |
namebuf += (sizeof("/dev/")-1); |
| 1578 |
if ((f = fopen("/etc/securetty", "r")) == NULL) |
| 1579 |
return(1); |
| 1580 |
|
| 1581 |
if (fstat(fileno(f), &sb) == -1) |
| 1582 |
fatal("fstat securetty file: %s", strerror(errno)); |
| 1583 |
if (sb.st_uid != 0 || (sb.st_mode & 077) != 0) { |
| 1584 |
logit("Bad owner or permissions on securetty file"); |
| 1585 |
return(1); |
| 1586 |
} |
| 1587 |
|
| 1588 |
while (fgets(buf, sizeof buf, f) != NULL) { |
| 1589 |
buf[strlen(buf)-1] = '\0'; |
| 1590 |
if (strcmp(namebuf, buf) == 0) { |
| 1591 |
fclose(f); |
| 1592 |
return(1); |
| 1593 |
} |
| 1594 |
} |
| 1595 |
fclose(f); |
| 1596 |
execl(LOGIN_PROGRAM, "login", "-h", (char *)NULL); |
| 1597 |
|
| 1598 |
} |
| 1599 |
|
| 1600 |
|
| 1569 |
/* |
1601 |
/* |
| 1570 |
* Performs common processing for the child, such as setting up the |
1602 |
* Performs common processing for the child, such as setting up the |
| 1571 |
* environment, closing extra file descriptors, setting the user and group |
1603 |
* environment, closing extra file descriptors, setting the user and group |
|
Lines 1710-1715
Link Here
|
| 1710 |
signal(SIGPIPE, SIG_DFL); |
1742 |
signal(SIGPIPE, SIG_DFL); |
| 1711 |
|
1743 |
|
| 1712 |
if (options.use_login) { |
1744 |
if (options.use_login) { |
|
|
1745 |
if (s->pw->pw_uid == 0 && check_securetty(s->tty)) |
| 1713 |
launch_login(pw, hostname); |
1746 |
launch_login(pw, hostname); |
| 1714 |
/* NEVERREACHED */ |
1747 |
/* NEVERREACHED */ |
| 1715 |
} |
1748 |
} |