diff options
author | cy <cy@FreeBSD.org> | 2004-10-30 02:31:14 +0800 |
---|---|---|
committer | cy <cy@FreeBSD.org> | 2004-10-30 02:31:14 +0800 |
commit | 23e2dca57e6d37a6b427a18916cf39a7030742bd (patch) | |
tree | 68a9a2c87101354559697b12fd2fa24daa9c46cf /security | |
parent | 7d982e45002c3a9cdc6486665c067d791567b50a (diff) | |
download | freebsd-ports-gnome-23e2dca57e6d37a6b427a18916cf39a7030742bd.tar.gz freebsd-ports-gnome-23e2dca57e6d37a6b427a18916cf39a7030742bd.tar.zst freebsd-ports-gnome-23e2dca57e6d37a6b427a18916cf39a7030742bd.zip |
Correct some tty handling problems.
Diffstat (limited to 'security')
-rw-r--r-- | security/sudosh/Makefile | 2 | ||||
-rw-r--r-- | security/sudosh/files/patch-src::sudosh.c | 129 | ||||
-rw-r--r-- | security/sudosh2/Makefile | 2 | ||||
-rw-r--r-- | security/sudosh2/files/patch-src::sudosh.c | 129 | ||||
-rw-r--r-- | security/sudosh3/Makefile | 2 | ||||
-rw-r--r-- | security/sudosh3/files/patch-src::sudosh.c | 129 |
6 files changed, 375 insertions, 18 deletions
diff --git a/security/sudosh/Makefile b/security/sudosh/Makefile index cd58476af25a..8c899c526a13 100644 --- a/security/sudosh/Makefile +++ b/security/sudosh/Makefile @@ -7,7 +7,7 @@ PORTNAME= sudosh PORTVERSION= 1.4.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= security MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME:S/_/-/} diff --git a/security/sudosh/files/patch-src::sudosh.c b/security/sudosh/files/patch-src::sudosh.c index 9f7d3a914cb3..3209d24268ef 100644 --- a/security/sudosh/files/patch-src::sudosh.c +++ b/security/sudosh/files/patch-src::sudosh.c @@ -1,5 +1,5 @@ --- src/sudosh.c.orig Tue Oct 26 18:01:24 2004 -+++ src/sudosh.c Thu Oct 28 15:18:50 2004 ++++ src/sudosh.c Fri Oct 29 11:26:34 2004 @@ -75,6 +75,12 @@ #define SIGCHLD SIGCLD #endif @@ -13,20 +13,67 @@ static struct termios termorig; static struct winsize winorig; -@@ -377,15 +383,24 @@ +@@ -99,6 +105,9 @@ + static void rawmode (int); + static int findms (struct pst *); + void mysyslog (int, const char *, ...); ++#ifdef __FreeBSD__ ++static void sanemode(int ttyfd); ++#endif + + int + main (int argc, char *argv[], char *environ[]) +@@ -255,8 +264,9 @@ + mysyslog (LOG_INFO, start_msg); + mysyslog (LOG_INFO, "to view this session type: sudosh-replay %s-%i", + user, now); +- ++#ifndef __FreeBSD__ + rawmode (0); ++#endif + + if (findms (&pspair) < 0) + { +@@ -269,6 +279,9 @@ + case 0: + close (pspair.mfd); + prepchild (&pspair); ++#ifdef __FreeBSD__ ++ rawmode (0); ++#endif + case -1: + perror ("fork failed"); + bye (1); +@@ -276,6 +289,9 @@ + close (pspair.sfd); + } + ++#ifdef __FreeBSD__ ++ rawmode(0); ++#endif + setuid (getuid ()); + + memset (&sa, 0, sizeof sa); +@@ -377,15 +393,30 @@ { if ((p->mfd = open ("/dev/ptc", O_RDWR)) == -1) { - perror ("Cannot open cloning master pty"); - return -1; +#ifdef __FreeBSD__ ++#define PTYLEN 16 ++ if ((int)(sname= malloc(PTYLEN)) == -1) ++ { ++ perror("Cannot allocate memory"); ++ return -1; ++ } + if (openpty(&p->mfd, &p->sfd, sname, NULL, NULL) == -1) + { +#endif -+ perror ("Cannot open cloning master pty"); -+ return -1; ++ perror ("Cannot open cloning master pty"); ++ return -1; +#ifdef __FreeBSD__ -+ } ++ } +#endif } } @@ -40,3 +87,75 @@ if ((p->sfd = open (sname, O_RDWR)) == -1) { +@@ -456,11 +487,53 @@ + abort (); + } + ++#ifdef __FreeBSD__ ++static void ++sanemode(int ttyfd) ++{ ++ static struct termios termnew; ++ ++ if (tcgetattr(ttyfd, &termnew) == -1) ++ { ++ perror ("tcgetattr failed"); ++ exit (1); ++ } ++ termnew.c_cflag = TTYDEF_CFLAG | (termnew.c_cflag & CLOCAL); ++ termnew.c_iflag = TTYDEF_IFLAG; ++ termnew.c_iflag |= ICRNL; ++ /* preserve user-preference flags in lflag */ ++#define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH) ++ termnew.c_lflag = TTYDEF_LFLAG | (termnew.c_lflag & LKEEP); ++ termnew.c_oflag = TTYDEF_OFLAG; ++ if (tcsetattr(ttyfd, TCSAFLUSH, &termnew) == -1) ++ { ++ perror ("tcsetattr (sane) failed"); ++ exit (1); ++ } ++} ++#endif ++ + static void + rawmode (int ttyfd) + { + static struct termios termnew; + ++#ifdef __FreeBSD__ ++ if (tcgetattr(ttyfd, &termnew) == -1) ++ { ++ perror ("tcgetattr failed"); ++ exit (1); ++ } ++ cfmakeraw(&termnew); ++ termnew.c_cflag &= ~(CSIZE|PARENB); ++ termnew.c_cflag |= CS8; ++ if (tcsetattr(ttyfd, TCSADRAIN, &termnew) == -1) ++ { ++ perror ("tcsetattr (raw) failed"); ++ exit (1); ++ } ++ return; ++#else __FreeBSD__ + #ifdef TCGETS + if (ioctl (ttyfd, TCGETS, &termorig) == -1) + { +@@ -484,6 +557,7 @@ + #ifdef TCSETS + (void) ioctl (ttyfd, TCSETS, &termnew); + #endif ++#endif __FreeBSD__ + } + + static void +@@ -491,6 +565,9 @@ + { + #ifdef TCSETS + (void) ioctl (0, TCSETS, &termorig); ++#endif ++#ifdef __FreeBSD__ ++ sanemode(0); + #endif + + fclose (fttime); diff --git a/security/sudosh2/Makefile b/security/sudosh2/Makefile index cd58476af25a..8c899c526a13 100644 --- a/security/sudosh2/Makefile +++ b/security/sudosh2/Makefile @@ -7,7 +7,7 @@ PORTNAME= sudosh PORTVERSION= 1.4.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= security MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME:S/_/-/} diff --git a/security/sudosh2/files/patch-src::sudosh.c b/security/sudosh2/files/patch-src::sudosh.c index 9f7d3a914cb3..3209d24268ef 100644 --- a/security/sudosh2/files/patch-src::sudosh.c +++ b/security/sudosh2/files/patch-src::sudosh.c @@ -1,5 +1,5 @@ --- src/sudosh.c.orig Tue Oct 26 18:01:24 2004 -+++ src/sudosh.c Thu Oct 28 15:18:50 2004 ++++ src/sudosh.c Fri Oct 29 11:26:34 2004 @@ -75,6 +75,12 @@ #define SIGCHLD SIGCLD #endif @@ -13,20 +13,67 @@ static struct termios termorig; static struct winsize winorig; -@@ -377,15 +383,24 @@ +@@ -99,6 +105,9 @@ + static void rawmode (int); + static int findms (struct pst *); + void mysyslog (int, const char *, ...); ++#ifdef __FreeBSD__ ++static void sanemode(int ttyfd); ++#endif + + int + main (int argc, char *argv[], char *environ[]) +@@ -255,8 +264,9 @@ + mysyslog (LOG_INFO, start_msg); + mysyslog (LOG_INFO, "to view this session type: sudosh-replay %s-%i", + user, now); +- ++#ifndef __FreeBSD__ + rawmode (0); ++#endif + + if (findms (&pspair) < 0) + { +@@ -269,6 +279,9 @@ + case 0: + close (pspair.mfd); + prepchild (&pspair); ++#ifdef __FreeBSD__ ++ rawmode (0); ++#endif + case -1: + perror ("fork failed"); + bye (1); +@@ -276,6 +289,9 @@ + close (pspair.sfd); + } + ++#ifdef __FreeBSD__ ++ rawmode(0); ++#endif + setuid (getuid ()); + + memset (&sa, 0, sizeof sa); +@@ -377,15 +393,30 @@ { if ((p->mfd = open ("/dev/ptc", O_RDWR)) == -1) { - perror ("Cannot open cloning master pty"); - return -1; +#ifdef __FreeBSD__ ++#define PTYLEN 16 ++ if ((int)(sname= malloc(PTYLEN)) == -1) ++ { ++ perror("Cannot allocate memory"); ++ return -1; ++ } + if (openpty(&p->mfd, &p->sfd, sname, NULL, NULL) == -1) + { +#endif -+ perror ("Cannot open cloning master pty"); -+ return -1; ++ perror ("Cannot open cloning master pty"); ++ return -1; +#ifdef __FreeBSD__ -+ } ++ } +#endif } } @@ -40,3 +87,75 @@ if ((p->sfd = open (sname, O_RDWR)) == -1) { +@@ -456,11 +487,53 @@ + abort (); + } + ++#ifdef __FreeBSD__ ++static void ++sanemode(int ttyfd) ++{ ++ static struct termios termnew; ++ ++ if (tcgetattr(ttyfd, &termnew) == -1) ++ { ++ perror ("tcgetattr failed"); ++ exit (1); ++ } ++ termnew.c_cflag = TTYDEF_CFLAG | (termnew.c_cflag & CLOCAL); ++ termnew.c_iflag = TTYDEF_IFLAG; ++ termnew.c_iflag |= ICRNL; ++ /* preserve user-preference flags in lflag */ ++#define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH) ++ termnew.c_lflag = TTYDEF_LFLAG | (termnew.c_lflag & LKEEP); ++ termnew.c_oflag = TTYDEF_OFLAG; ++ if (tcsetattr(ttyfd, TCSAFLUSH, &termnew) == -1) ++ { ++ perror ("tcsetattr (sane) failed"); ++ exit (1); ++ } ++} ++#endif ++ + static void + rawmode (int ttyfd) + { + static struct termios termnew; + ++#ifdef __FreeBSD__ ++ if (tcgetattr(ttyfd, &termnew) == -1) ++ { ++ perror ("tcgetattr failed"); ++ exit (1); ++ } ++ cfmakeraw(&termnew); ++ termnew.c_cflag &= ~(CSIZE|PARENB); ++ termnew.c_cflag |= CS8; ++ if (tcsetattr(ttyfd, TCSADRAIN, &termnew) == -1) ++ { ++ perror ("tcsetattr (raw) failed"); ++ exit (1); ++ } ++ return; ++#else __FreeBSD__ + #ifdef TCGETS + if (ioctl (ttyfd, TCGETS, &termorig) == -1) + { +@@ -484,6 +557,7 @@ + #ifdef TCSETS + (void) ioctl (ttyfd, TCSETS, &termnew); + #endif ++#endif __FreeBSD__ + } + + static void +@@ -491,6 +565,9 @@ + { + #ifdef TCSETS + (void) ioctl (0, TCSETS, &termorig); ++#endif ++#ifdef __FreeBSD__ ++ sanemode(0); + #endif + + fclose (fttime); diff --git a/security/sudosh3/Makefile b/security/sudosh3/Makefile index cd58476af25a..8c899c526a13 100644 --- a/security/sudosh3/Makefile +++ b/security/sudosh3/Makefile @@ -7,7 +7,7 @@ PORTNAME= sudosh PORTVERSION= 1.4.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= security MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME:S/_/-/} diff --git a/security/sudosh3/files/patch-src::sudosh.c b/security/sudosh3/files/patch-src::sudosh.c index 9f7d3a914cb3..3209d24268ef 100644 --- a/security/sudosh3/files/patch-src::sudosh.c +++ b/security/sudosh3/files/patch-src::sudosh.c @@ -1,5 +1,5 @@ --- src/sudosh.c.orig Tue Oct 26 18:01:24 2004 -+++ src/sudosh.c Thu Oct 28 15:18:50 2004 ++++ src/sudosh.c Fri Oct 29 11:26:34 2004 @@ -75,6 +75,12 @@ #define SIGCHLD SIGCLD #endif @@ -13,20 +13,67 @@ static struct termios termorig; static struct winsize winorig; -@@ -377,15 +383,24 @@ +@@ -99,6 +105,9 @@ + static void rawmode (int); + static int findms (struct pst *); + void mysyslog (int, const char *, ...); ++#ifdef __FreeBSD__ ++static void sanemode(int ttyfd); ++#endif + + int + main (int argc, char *argv[], char *environ[]) +@@ -255,8 +264,9 @@ + mysyslog (LOG_INFO, start_msg); + mysyslog (LOG_INFO, "to view this session type: sudosh-replay %s-%i", + user, now); +- ++#ifndef __FreeBSD__ + rawmode (0); ++#endif + + if (findms (&pspair) < 0) + { +@@ -269,6 +279,9 @@ + case 0: + close (pspair.mfd); + prepchild (&pspair); ++#ifdef __FreeBSD__ ++ rawmode (0); ++#endif + case -1: + perror ("fork failed"); + bye (1); +@@ -276,6 +289,9 @@ + close (pspair.sfd); + } + ++#ifdef __FreeBSD__ ++ rawmode(0); ++#endif + setuid (getuid ()); + + memset (&sa, 0, sizeof sa); +@@ -377,15 +393,30 @@ { if ((p->mfd = open ("/dev/ptc", O_RDWR)) == -1) { - perror ("Cannot open cloning master pty"); - return -1; +#ifdef __FreeBSD__ ++#define PTYLEN 16 ++ if ((int)(sname= malloc(PTYLEN)) == -1) ++ { ++ perror("Cannot allocate memory"); ++ return -1; ++ } + if (openpty(&p->mfd, &p->sfd, sname, NULL, NULL) == -1) + { +#endif -+ perror ("Cannot open cloning master pty"); -+ return -1; ++ perror ("Cannot open cloning master pty"); ++ return -1; +#ifdef __FreeBSD__ -+ } ++ } +#endif } } @@ -40,3 +87,75 @@ if ((p->sfd = open (sname, O_RDWR)) == -1) { +@@ -456,11 +487,53 @@ + abort (); + } + ++#ifdef __FreeBSD__ ++static void ++sanemode(int ttyfd) ++{ ++ static struct termios termnew; ++ ++ if (tcgetattr(ttyfd, &termnew) == -1) ++ { ++ perror ("tcgetattr failed"); ++ exit (1); ++ } ++ termnew.c_cflag = TTYDEF_CFLAG | (termnew.c_cflag & CLOCAL); ++ termnew.c_iflag = TTYDEF_IFLAG; ++ termnew.c_iflag |= ICRNL; ++ /* preserve user-preference flags in lflag */ ++#define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH) ++ termnew.c_lflag = TTYDEF_LFLAG | (termnew.c_lflag & LKEEP); ++ termnew.c_oflag = TTYDEF_OFLAG; ++ if (tcsetattr(ttyfd, TCSAFLUSH, &termnew) == -1) ++ { ++ perror ("tcsetattr (sane) failed"); ++ exit (1); ++ } ++} ++#endif ++ + static void + rawmode (int ttyfd) + { + static struct termios termnew; + ++#ifdef __FreeBSD__ ++ if (tcgetattr(ttyfd, &termnew) == -1) ++ { ++ perror ("tcgetattr failed"); ++ exit (1); ++ } ++ cfmakeraw(&termnew); ++ termnew.c_cflag &= ~(CSIZE|PARENB); ++ termnew.c_cflag |= CS8; ++ if (tcsetattr(ttyfd, TCSADRAIN, &termnew) == -1) ++ { ++ perror ("tcsetattr (raw) failed"); ++ exit (1); ++ } ++ return; ++#else __FreeBSD__ + #ifdef TCGETS + if (ioctl (ttyfd, TCGETS, &termorig) == -1) + { +@@ -484,6 +557,7 @@ + #ifdef TCSETS + (void) ioctl (ttyfd, TCSETS, &termnew); + #endif ++#endif __FreeBSD__ + } + + static void +@@ -491,6 +565,9 @@ + { + #ifdef TCSETS + (void) ioctl (0, TCSETS, &termorig); ++#endif ++#ifdef __FreeBSD__ ++ sanemode(0); + #endif + + fclose (fttime); |