From 15a7b5b667a06492cc6250a49fe8159f77937b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= Date: Sat, 26 Apr 2014 18:20:37 +0200 Subject: Revert "fix-utf8-status-padding-bug" This reverts commit e9e78d9b2b413337d9f783ad9a514c8accd25ac9. --- src/attacher.c | 52 ++++++++++++++-------------------------------------- src/braille_tsi.c | 1 + src/display.c | 19 +++++-------------- src/extern.h | 1 - src/fileio.c | 2 ++ src/screen.c | 9 ++------- src/socket.c | 2 +- src/tty.sh | 14 -------------- src/utmp.c | 8 ++++---- 9 files changed, 29 insertions(+), 79 deletions(-) diff --git a/src/attacher.c b/src/attacher.c index 8847d5d..7159c7f 100644 --- a/src/attacher.c +++ b/src/attacher.c @@ -185,8 +185,8 @@ int how; if (ret == SIG_POWER_BYE) { int ppid; - if (setgid(real_gid) || setuid(real_uid)) - Panic(errno, "setuid/gid"); + setgid(real_gid); + setuid(real_uid); if ((ppid = getppid()) > 1) Kill(ppid, SIGHUP); exit(0); @@ -282,10 +282,7 @@ int how; #ifdef MULTIUSER if (!multiattach) #endif - { - if (setuid(real_uid)) - Panic(errno, "setuid"); - } + setuid(real_uid); #if defined(MULTIUSER) && defined(USE_SETEUID) else { @@ -293,8 +290,7 @@ int how; xseteuid(real_uid); /* multi_uid, allow backend to send signals */ } #endif - if (setgid(real_gid)) - Panic(errno, "setgid"); + setgid(real_gid); eff_uid = real_uid; eff_gid = real_gid; @@ -490,8 +486,7 @@ AttacherFinit SIGDEFARG #ifdef MULTIUSER if (tty_oldmode >= 0) { - if (setuid(own_uid)) - Panic(errno, "setuid"); + setuid(own_uid); chmod(attach_tty, tty_oldmode); } #endif @@ -509,14 +504,11 @@ AttacherFinitBye SIGDEFARG if (multiattach) exit(SIG_POWER_BYE); #endif - if (setgid(real_gid)) - Panic(errno, "setgid"); + setgid(real_gid); #ifdef MULTIUSER - if (setuid(own_uid)) - Panic(errno, "setuid"); + setuid(own_uid); #else - if (setuid(real_uid)) - Panic(errno, "setuid"); + setuid(real_uid); #endif /* we don't want to disturb init (even if we were root), eh? jw */ if ((ppid = getppid()) > 1) @@ -687,14 +679,11 @@ static sigret_t LockHup SIGDEFARG { int ppid = getppid(); - if (setgid(real_gid)) - Panic(errno, "setgid"); + setgid(real_gid); #ifdef MULTIUSER - if (setuid(own_uid)) - Panic(errno, "setuid"); + setuid(own_uid); #else - if (setuid(real_uid)) - Panic(errno, "setuid"); + setuid(real_uid); #endif if (ppid > 1) Kill(ppid, SIGHUP); @@ -721,14 +710,11 @@ LockTerminal() if ((pid = fork()) == 0) { /* Child */ - if (setgid(real_gid)) - Panic(errno, "setgid"); + setgid(real_gid); #ifdef MULTIUSER - if (setuid(own_uid)) - Panic(errno, "setuid"); + setuid(own_uid); #else - if (setuid(real_uid)) /* this should be done already */ - Panic(errno, "setuid"); + setuid(real_uid); /* this should be done already */ #endif closeallfiles(0); /* important: /etc/shadow may be open */ execl(prg, "SCREEN-LOCK", NULL); @@ -861,7 +847,6 @@ screen_builtin_lck() #ifdef USE_PAM pam_handle_t *pamh = 0; int pam_error; - char *tty_name; #endif char *pass = 0, mypass[16 + 1], salt[3]; int using_pam = 1; @@ -947,15 +932,6 @@ screen_builtin_lck() pam_error = pam_start("screen", ppp->pw_name, &PAM_conversation, &pamh); if (pam_error != PAM_SUCCESS) AttacherFinit(SIGARG); /* goodbye */ - - if (strncmp(attach_tty, "/dev/", 5) == 0) - tty_name = attach_tty + 5; - else - tty_name = attach_tty; - pam_error = pam_set_item(pamh, PAM_TTY, tty_name); - if (pam_error != PAM_SUCCESS) - AttacherFinit(SIGARG); /* goodbye */ - pam_error = pam_authenticate(pamh, 0); pam_end(pamh, pam_error); PAM_conversation.appdata_ptr = 0; diff --git a/src/braille_tsi.c b/src/braille_tsi.c index 6f84913..6768291 100644 --- a/src/braille_tsi.c +++ b/src/braille_tsi.c @@ -127,6 +127,7 @@ display_status_tsi() r = read(bd.bd_fd,ibuf,1); if (r != 1) return -1; + if (r != -1) if (ibuf[0] == 'V') r = read(bd.bd_fd, ibuf, 3); else diff --git a/src/display.c b/src/display.c index 8161e1e..64ea856 100644 --- a/src/display.c +++ b/src/display.c @@ -2163,7 +2163,7 @@ int start, max; { int chars = strlen_onscreen((unsigned char *)(s + start), (unsigned char *)(s + max)); D_encoding = 0; - PutWinMsg(s, start, max + ((max - start) - chars)); /* Multibyte count */ + PutWinMsg(s, start, max); D_encoding = UTF8; D_x -= (max - chars); /* Yak! But this is necessary to count for the fact that not every byte represents a @@ -2257,15 +2257,11 @@ void RefreshHStatus() { char *buf; -#ifdef UTF8 - int extrabytes = strlen(hstatusstring) - strlen_onscreen(hstatusstring, NULL); -#else - int extrabytes = 0; -#endif + evdeq(&D_hstatusev); if (D_status == STATUS_ON_HS) return; - buf = MakeWinMsgEv(hstatusstring, D_fore, '%', (D_HS && D_has_hstatus == HSTATUS_HS && D_WS > 0) ? D_WS : D_width - !D_CLP + extrabytes, &D_hstatusev, 0); + buf = MakeWinMsgEv(hstatusstring, D_fore, '%', (D_HS && D_has_hstatus == HSTATUS_HS && D_WS > 0) ? D_WS : D_width - !D_CLP, &D_hstatusev, 0); if (buf && *buf) { ShowHStatus(buf); @@ -2360,13 +2356,8 @@ int y, from, to, isblank; { if (y == cv->c_ye + 1 && from >= cv->c_xs && from <= cv->c_xe) { -#ifdef UTF8 - int extrabytes = strlen(captionstring) - strlen_onscreen(captionstring, NULL); -#else - int extrabytes = 0; -#endif p = Layer2Window(cv->c_layer); - buf = MakeWinMsgEv(captionstring, p, '%', cv->c_xe - cv->c_xs + (cv->c_xe + 1 < D_width || D_CLP) + extrabytes, &cv->c_captev, 0); + buf = MakeWinMsgEv(captionstring, p, '%', cv->c_xe - cv->c_xs + (cv->c_xe + 1 < D_width || D_CLP), &cv->c_captev, 0); if (cv->c_captev.timeout.tv_sec) evenq(&cv->c_captev); xx = to > cv->c_xe ? cv->c_xe : to; @@ -2375,7 +2366,7 @@ int y, from, to, isblank; SetRendition(&mchar_so); if (l > xx - cv->c_xs + 1) l = xx - cv->c_xs + 1; - l = PrePutWinMsg(buf, from - cv->c_xs, l + extrabytes); + l = PrePutWinMsg(buf, from - cv->c_xs, l); from = cv->c_xs + l; for (; from <= xx; from++) PUTCHARLP(' '); diff --git a/src/extern.h b/src/extern.h index a3e3ca2..b8cead4 100644 --- a/src/extern.h +++ b/src/extern.h @@ -110,7 +110,6 @@ extern void brktty __P((int)); extern struct baud_values *lookup_baud __P((int bps)); extern int SetBaud __P((struct mode *, int, int)); extern int SttyMode __P((struct mode *, char *)); -extern int CheckTtyname __P((char *)); /* mark.c */ diff --git a/src/fileio.c b/src/fileio.c index 05df0c4..978f07b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -80,6 +80,8 @@ register char *str1, *str2; } else { + if (len1 == 0) + return 0; if ((cp = malloc((unsigned) len1 + add_colon + 1)) == NULL) Panic(0, "%s", strnomem); cp[len1 + add_colon] = '\0'; diff --git a/src/screen.c b/src/screen.c index 473e4fa..515c0bb 100644 --- a/src/screen.c +++ b/src/screen.c @@ -972,13 +972,8 @@ char **av; else \ attach_tty = ""; \ } \ - else \ - { \ - if (stat(attach_tty, &st)) \ - Panic(errno, "Cannot access '%s'", attach_tty); \ - if (CheckTtyname(attach_tty)) \ - Panic(0, "Bad tty '%s'", attach_tty); \ - } \ + else if (stat(attach_tty, &st)) \ + Panic(errno, "Cannot access '%s'", attach_tty); \ if (strlen(attach_tty) >= MAXPATHLEN) \ Panic(0, "TtyName too long - sorry."); \ } while (0) diff --git a/src/socket.c b/src/socket.c index b4d2400..711c709 100644 --- a/src/socket.c +++ b/src/socket.c @@ -722,7 +722,6 @@ struct msg *mp; char *args[MAXARGS]; register int n; register char **pp = args, *p = mp->m.create.line; - char buf[20]; nwin = nwin_undef; n = mp->m.create.nargs; @@ -732,6 +731,7 @@ struct msg *mp; if (n) { int l, num; + char buf[20]; l = strlen(p); if (IsNumColon(p, 10, buf, sizeof(buf))) diff --git a/src/tty.sh b/src/tty.sh index 3374753..0b5524e 100644 --- a/src/tty.sh +++ b/src/tty.sh @@ -60,7 +60,6 @@ exit 0 #include #include #include -#include #ifndef sgi # include #endif @@ -1500,19 +1499,6 @@ int ibaud, obaud; return 0; } - -int -CheckTtyname (tty) -char *tty; -{ - struct stat st; - - if (lstat(tty, &st) || !S_ISCHR(st.st_mode) || - (st.st_nlink > 1 && strncmp(tty, "/dev/", 5))) - return -1; - return 0; -} - /* * Write out the mode struct in a readable form */ diff --git a/src/utmp.c b/src/utmp.c index fa8b87b..afa0948 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -361,7 +361,7 @@ RemoveLoginSlot() char *tty; debug("couln't zap slot -> do mesg n\n"); D_loginttymode = 0; - if ((tty = ttyname(D_userfd)) && stat(tty, &stb) == 0 && (int)stb.st_uid == real_uid && !CheckTtyname(tty) && ((int)stb.st_mode & 0777) != 0666) + if ((tty = ttyname(D_userfd)) && stat(tty, &stb) == 0 && (int)stb.st_uid == real_uid && ((int)stb.st_mode & 0777) != 0666) { D_loginttymode = (int)stb.st_mode & 0777; chmod(D_usertty, stb.st_mode & 0600); @@ -387,7 +387,7 @@ RestoreLoginSlot() } UT_CLOSE; D_loginslot = (slot_t)0; - if (D_loginttymode && (tty = ttyname(D_userfd)) && !CheckTtyname(tty)) + if (D_loginttymode && (tty = ttyname(D_userfd))) chmod(tty, D_loginttymode); } @@ -575,7 +575,7 @@ struct win *wi; return ut_delete_user(slot, u.ut_pid, 0, 0) != 0; #endif #ifdef HAVE_UTEMPTER - if (eff_uid && wi && wi->w_ptyfd != -1) + if (eff_uid && wi->w_ptyfd != -1) { /* sigh, linux hackers made the helper functions void */ if (SLOT_USED(u)) @@ -853,7 +853,7 @@ getlogin() for (fd = 0; fd <= 2 && (tty = ttyname(fd)) == NULL; fd++) ; - if ((tty == NULL) || CheckTtyname(tty) || ((fd = open(UTMP_FILE, O_RDONLY)) < 0)) + if ((tty == NULL) || ((fd = open(UTMP_FILE, O_RDONLY)) < 0)) return NULL; tty = stripdev(tty); retbuf[0] = '\0'; -- cgit v1.2.1