diff options
author | cy <cy@FreeBSD.org> | 2005-04-13 10:03:46 +0800 |
---|---|---|
committer | cy <cy@FreeBSD.org> | 2005-04-13 10:03:46 +0800 |
commit | 485bdc29fbb3346be72dae30687c4994ac7ec8a0 (patch) | |
tree | 3a15fe5209f63d116a5ee77d464c417ad53ddc2a /security/sudosh/files | |
parent | a98049117302207556006667214a3145d7efd3be (diff) | |
download | freebsd-ports-gnome-485bdc29fbb3346be72dae30687c4994ac7ec8a0.tar.gz freebsd-ports-gnome-485bdc29fbb3346be72dae30687c4994ac7ec8a0.tar.zst freebsd-ports-gnome-485bdc29fbb3346be72dae30687c4994ac7ec8a0.zip |
Udate 1.4.1 --> 1.4.8
Diffstat (limited to 'security/sudosh/files')
-rw-r--r-- | security/sudosh/files/patch-src::sudosh.c | 170 |
1 files changed, 75 insertions, 95 deletions
diff --git a/security/sudosh/files/patch-src::sudosh.c b/security/sudosh/files/patch-src::sudosh.c index eccb20ad878e..7c906c4b31ab 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 Sat Nov 13 19:31:14 2004 +--- src/sudosh.c.orig Tue Mar 22 21:05:05 2005 ++++ src/sudosh.c Thu Mar 24 14:54:25 2005 @@ -24,6 +24,9 @@ #include <unistd.h> #include <signal.h> @@ -23,65 +23,53 @@ static struct termios termorig; static struct winsize winorig; -@@ -99,6 +108,9 @@ - static void rawmode (int); - static int findms (struct pst *); - void mysyslog (int, const char *, ...); +@@ -105,6 +114,9 @@ + static int findms(struct pst *); + void mysyslog(int, const char *, ...); + void mklogdir(void); +#ifdef __FreeBSD__ +static void sanemode(int ttyfd); +#endif - int - main (int argc, char *argv[], char *environ[]) -@@ -255,8 +267,9 @@ - mysyslog (LOG_INFO, start_msg); - mysyslog (LOG_INFO, "to view this session type: sudosh-replay %s-%i", - user, now); + int main(int argc, char *argv[], char *environ[]) + { +@@ -265,8 +277,9 @@ + mysyslog(LOG_INFO, start_msg); + mysyslog(LOG_INFO, "to view this session type: sudosh-replay %s-%s-%i", + sudo_user, user_name, now); - +#ifndef __FreeBSD__ - rawmode (0); + rawmode(0); +#endif - if (findms (&pspair) < 0) - { -@@ -269,6 +282,9 @@ - case 0: - close (pspair.mfd); - prepchild (&pspair); -+#ifdef __FreeBSD__ -+ rawmode (0); -+#endif - case -1: - perror ("fork failed"); - bye (1); -@@ -276,6 +292,9 @@ - close (pspair.sfd); + if (findms(&pspair) < 0) { + perror("open pty failed"); +@@ -283,6 +296,9 @@ + default: + close(pspair.sfd); } - +#ifdef __FreeBSD__ -+ rawmode(0); ++ rawmode (0); +#endif - setuid (getuid ()); - - memset (&sa, 0, sizeof sa); -@@ -377,15 +396,32 @@ - { - if ((p->mfd = open ("/dev/ptc", O_RDWR)) == -1) - { -- perror ("Cannot open cloning master pty"); -- return -1; + + setuid(getuid()); + +@@ -372,15 +388,30 @@ + + if ((p->mfd = open("/dev/ptmx", O_RDWR)) == -1) { + 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; ++#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) -+ { ++ 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 @@ -89,85 +77,77 @@ } +#if !defined(__FreeBSD_version) || (defined(__FreeBSD_version) && __FreeBSD_version >= 500000) - (void) unlockpt (p->mfd); - (void) grantpt (p->mfd); + (void) unlockpt(p->mfd); + (void) grantpt(p->mfd); +#endif +#ifndef __FreeBSD__ - sname = (char *) ptsname (p->mfd); + sname = (char *) ptsname(p->mfd); +#endif - if ((p->sfd = open (sname, O_RDWR)) == -1) - { -@@ -456,11 +492,53 @@ - abort (); + if ((p->sfd = open(sname, O_RDWR)) == -1) { + perror("open slave pty"); +@@ -447,10 +478,46 @@ + abort(); } +#ifdef __FreeBSD__ -+static void -+sanemode(int ttyfd) ++static void sanemode(int ttyfd) +{ -+ static struct termios termnew; ++ static struct termios termnew; + -+ if (tcgetattr(ttyfd, &termnew) == -1) -+ { -+ perror ("tcgetattr failed"); -+ exit (1); ++ 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 */ ++ 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); ++ 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 void rawmode(int ttyfd) { - static struct termios termnew; + static struct termios termnew; +#ifdef __FreeBSD__ -+ if (tcgetattr(ttyfd, &termnew) == -1) -+ { -+ perror ("tcgetattr failed"); -+ exit (1); ++ 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); ++ 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 +562,7 @@ + if (ioctl(ttyfd, TCGETS, &termorig) == -1) { + perror("ioctl TCGETS failed"); +@@ -472,12 +539,16 @@ #ifdef TCSETS - (void) ioctl (ttyfd, TCSETS, &termnew); + (void) ioctl(ttyfd, TCSETS, &termnew); #endif +#endif __FreeBSD__ } - static void -@@ -491,6 +570,9 @@ + static void bye(int signum) { #ifdef TCSETS - (void) ioctl (0, TCSETS, &termorig); + (void) ioctl(0, TCSETS, &termorig); +#endif +#ifdef __FreeBSD__ -+ sanemode(0); ++ sanemode(0); #endif - fclose (fttime); + fclose(fttime); |