head 1.2; access; symbols; locks; strict; comment @# @; 1.2 date 2007.12.28.09.47.15; author rse; state Exp; branches; next 1.1; commitid lyetdoud0JHXfbLs; 1.1 date 2007.01.07.10.19.17; author rse; state Exp; branches; next ; commitid qBblPxckn2rrQy1s; desc @@ 1.2 log @apply a segfault fix from sudosh2 @ text @Index: src/Makefile.in --- src/Makefile.in.orig 2005-06-13 04:33:29 +0200 +++ src/Makefile.in 2007-12-28 10:43:39 +0100 @@@@ -427,7 +427,7 @@@@ install-sudosh.conf: test -z "$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)" - test -f $(sysconfdir)/sudosh.conf || $(INSTALL) -o 0 -g 0 -m 0444 '$(srcdir)/sudosh.conf' '$(sysconfdir)/sudosh.conf' + test -f $(sysconfdir)/sudosh.conf || $(INSTALL) -m 0444 '$(srcdir)/sudosh.conf' '$(sysconfdir)/sudosh.conf' install: install-am install-sudosh.conf # Tell versions [3.59,3.63) of GNU make to not export all variables. Index: src/getopt.c --- src/getopt.c.orig 2005-06-13 01:22:42 +0200 +++ src/getopt.c 2007-12-28 10:43:39 +0100 @@@@ -37,6 +37,8 @@@@ #include "config.h" #endif +#include + #ifndef __STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ Index: src/parse.c --- src/parse.c.orig 2005-06-13 01:22:42 +0200 +++ src/parse.c 2007-12-28 10:43:39 +0100 @@@@ -19,7 +19,8 @@@@ void parse(option * o, const char *file) { FILE *f = fopen(file, "r"); - unsigned int line_number, i; + unsigned int line_number; + int i; char line[BUFSIZ]; char *arg, *cmt, *opt; config *scan; @@@@ -38,6 +39,9 @@@@ while (isspace(*opt)) opt++; + if (strlen(opt)==0) + continue; + for (i = strlen(opt) - 1; i >= 0 && isspace(opt[i]); i--) opt[i] = '\0'; Index: src/sudosh.c --- src/sudosh.c.orig 2005-06-13 04:35:07 +0200 +++ src/sudosh.c 2007-12-28 10:43:39 +0100 @@@@ -28,6 +28,13 @@@@ #define WRITE(a, b, c) do_write(a, b, c, __FILE__, __LINE__) +#ifdef __FreeBSD__ +#include +#include +#include +#include +#endif + static struct termios termorig; static struct winsize winorig; @@@@ -545,19 +552,43 @@@@ { char *sname; +#ifdef __FreeBSD__ +#define PTYLEN 16 + char sname_area[PTYLEN]; + struct termios tt; + struct winsize win; + + sname = sname_area; + if (tcgetattr(STDIN_FILENO, &tt) == -1) + { + perror ("tcgetattr"); + return -1; + } + if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == -1) + { + perror ("ioctl"); + return -1; + } + if (openpty(&p->mfd, &p->sfd, sname, &tt, &win) == -1) { +#else if ((p->mfd = open ("/dev/ptmx", O_RDWR)) == -1) { if ((p->mfd = open ("/dev/ptc", O_RDWR)) == -1) { +#endif perror ("Cannot open cloning master pty"); return -1; +#ifndef __FreeBSD__ } +#endif } +#if !defined(__FreeBSD_version) || (defined(__FreeBSD_version) && __FreeBSD_version >= 500000) (void) unlockpt (p->mfd); (void) grantpt (p->mfd); sname = (char *) ptsname (p->mfd); +#endif if ((p->sfd = open (sname, O_RDWR)) == -1) { @@@@ -619,9 +650,14 @@@@ for (i = 3; i < 100; ++i) close (i); +#ifdef __FreeBSD__ + (void) tcsetattr(0, TCSADRAIN, &termorig); + (void) login_tty(pst->sfd); +#else #ifdef TCSETS (void) ioctl (0, TCSETS, &termorig); #endif +#endif (void) ioctl (0, TIOCSWINSZ, &winorig); setuid (getuid ()); @@@@ -663,6 +699,13 @@@@ { static struct termios termnew; +#ifdef __FreeBSD__ + if (tcgetattr(ttyfd, &termorig) == -1) + { + perror ("tcgetattr failed"); + exit (EXIT_FAILURE); + } +#else #ifdef TCGETS if (ioctl (ttyfd, TCGETS, &termorig) == -1) { @@@@ -670,6 +713,7 @@@@ exit (EXIT_FAILURE); } #endif +#endif if (ioctl (ttyfd, TIOCGWINSZ, &winorig) == -1) { @@@@ -677,6 +721,11 @@@@ exit (EXIT_FAILURE); } +#ifdef __FreeBSD__ + (void) cfmakeraw(&termnew); + termnew.c_lflag &= ~ECHO; + (void) tcsetattr(ttyfd, TCSAFLUSH, &termnew); +#else termnew.c_cc[VEOF] = 1; termnew.c_iflag = BRKINT | ISTRIP | IXON | IXANY; termnew.c_oflag = 0; @@@@ -686,14 +735,20 @@@@ #ifdef TCSETS (void) ioctl (ttyfd, TCSETS, &termnew); #endif +#endif } static void bye (int signum) { + +#ifdef __FreeBSD__ + (void) tcsetattr(0, TCSADRAIN, &termorig); +#else #ifdef TCSETS (void) ioctl (0, TCSETS, &termorig); #endif +#endif close (timing.fd); close (script.fd); @ 1.1 log @new package: sudosh 1.8.2 (SUDO Shell) @ text @d3 1 a3 1 +++ src/Makefile.in 2007-01-07 10:55:05 +0100 d15 1 a15 1 +++ src/getopt.c 2007-01-07 10:54:52 +0100 d27 1 a27 1 +++ src/parse.c 2007-01-07 10:54:52 +0100 d38 10 d50 1 a50 1 +++ src/sudosh.c 2007-01-07 10:54:52 +0100 @