diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-25 19:29:02 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-25 19:29:02 +0000 |
commit | 0afe748d654f553771ee2f4b07ab1ccce30b9ddd (patch) | |
tree | 579ffc84d6b1e5922f1e4c14528b66ef4213cee4 | |
parent | f0c47a47ea65135be8b78cd215ba4a67ecc44a57 (diff) |
XFree86 4.3.99.16 Bring the tree up to date for the Cygwin folksxf86-4_3_99_902xf86-4_3_99_901xf86-4_3_99_16
-rw-r--r-- | luit.c | 6 | ||||
-rw-r--r-- | luit.man | 6 | ||||
-rw-r--r-- | sys.c | 59 | ||||
-rw-r--r-- | sys.h | 2 |
4 files changed, 61 insertions, 12 deletions
@@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/luit/luit.c,v 1.10 2003/02/24 01:10:25 dawes Exp $ */ +/* $XFree86: xc/programs/luit/luit.c,v 1.11 2003/09/08 14:25:30 eich Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -545,6 +545,10 @@ parent(int pid, int pty) #endif installHandler(SIGCHLD, sigchldHandler); + rc = copyTermios(0, pty); + if(rc < 0) + FatalError("Couldn't copy terminal settings\n"); + rc = setRawTermios(); if(rc < 0) FatalError("Couldn't set terminal to raw\n"); @@ -1,4 +1,4 @@ -.\" $XFree86: xc/programs/luit/luit.man,v 1.7 2003/02/24 01:10:25 dawes Exp $ +.\" $XFree86: xc/programs/luit/luit.man,v 1.8 2003/04/03 16:44:36 dawes Exp $ .TH LUIT 1 __vendorversion__ .SH NAME luit \- Locale and ISO\ 2022 support for Unicode terminals @@ -202,8 +202,8 @@ the startup code has not been exhaustively audited, and the author takes no responsibility for any resulting security issues. .B Luit -will refuse to run if it is installed setuid and the underlying system -does not have POSIX saved ids. +will refuse to run if it is installed setuid and cannot safely drop +privileges. .SH BUGS None of this complexity should be necessary. Stateless UTF-8 throughout the system is the way to go. @@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/luit/sys.c,v 1.7 2002/01/07 20:38:30 dawes Exp $ */ +/* $XFree86: xc/programs/luit/sys.c,v 1.10 2003/09/08 14:25:30 eich Exp $ */ #include <stdlib.h> #include <string.h> @@ -68,6 +68,10 @@ THE SOFTWARE. #include <stropts.h> #endif +#if (defined(__unix__) || defined(unix)) && !defined(USG) +#include <sys/param.h> +#endif + #include "sys.h" static int saved_tio_valid = 0; @@ -211,6 +215,23 @@ installHandler(int signum, void (*handler)(int)) } int +copyTermios(int sfd, int dfd) +{ + struct termios tio; + int rc; + + rc = tcgetattr(sfd, &tio); + if(rc < 0) + return -1; + + rc = tcsetattr(dfd, TCSAFLUSH, &tio); + if(rc < 0) + return -1; + + return 0; +} + +int saveTermios(void) { int rc; @@ -311,7 +332,8 @@ allocatePty(int *pty_return, char **line_return) { char name[12], *line = NULL; int pty = -1; - char *name1 = "pqrstuvwxyzPQRST", *name2 = "0123456789abcdef"; + char *name1 = "pqrstuvwxyzPQRST", + *name2 = "0123456789abcdefghijklmnopqrstuv"; char *p1, *p2; #ifdef HAVE_GRANTPT @@ -363,17 +385,16 @@ allocatePty(int *pty_return, char **line_return) pty = open(name, O_RDWR); if(pty >= 0) goto found; - if(errno == ENOENT) - goto bail; - else - continue; + /* Systems derived from 4.4BSD differ in their pty names, + so ENOENT doesn't necessarily imply we're done. */ + continue; } } goto bail; found: - line = malloc(strlen(name)); + line = malloc(strlen(name) + 1); strcpy(line, name); line[5] = 't'; fix_pty_perms(line); @@ -429,7 +450,10 @@ openTty(char *line) return -1; } -#ifdef _POSIX_SAVED_IDS +/* Post-4.4 BSD systems have POSIX semantics (_POSIX_SAVED_IDS + or not, depending on the version). 4.3BSD and Minix do not have + saved IDs at all, so there's no issue. */ +#if (defined(BSD) && !defined(_POSIX_SAVED_IDS)) || defined(_MINIX) int droppriv() { @@ -439,6 +463,25 @@ droppriv() return rc; return setgid(getgid()); } +#elif defined(_POSIX_SAVED_IDS) +int +droppriv() +{ + int uid = getuid(); + int euid = geteuid(); + int gid = getgid(); + int egid = getegid(); + int rc; + + if((uid != euid || gid != egid) && euid != 0) { + errno = ENOSYS; + return -1; + } + rc = setuid(uid); + if(rc < 0) + return rc; + return setgid(gid); +} #else int droppriv() @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/luit/sys.h,v 1.3 2003/10/24 20:38:12 tsi Exp $ */ /* Copyright (c) 2001 by Juliusz Chroboczek @@ -24,6 +25,7 @@ int waitForOutput(int fd); int waitForInput(int fd1, int fd2); int setWindowSize(int sfd, int dfd); int installHandler(int signum, void (*handler)(int)); +int copyTermios(int sfd, int dfd); int saveTermios(void); int restoreTermios(void); int setRawTermios(void); |