crypt-portable

Portable version of the classic crypt(1) utility
git clone git://git.sgregoratto.me/crypt-portable
Log | Files | Refs

commit 58c41fce676321c0e010a9bbfd3aaa41107ad799
parent 93da5ab9a9912059cbd3269b8c32e62c324eddd8
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date:   Mon,  4 Nov 2019 22:22:44 +1100

Sync with latest oconfigure version

Diffstat:
Mcompats.c | 51+++++++++++++++++++++++----------------------------
Mconfigure | 8++++++--
2 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/compats.c b/compats.c @@ -869,8 +869,9 @@ memrchr(const void *s, int c, size_t n) } #endif /* !HAVE_MEMRCHR */ #if !HAVE_READPASSPHRASE -/* $OpenBSD$ */ - +/* + * Original: readpassphrase.c in OpenSSH portable + */ /* * Copyright (c) 2000-2002, 2007, 2010 * Todd C. Miller <millert@openbsd.org> @@ -902,19 +903,14 @@ memrchr(const void *s, int c, size_t n) #include <termios.h> #include <unistd.h> -#ifndef TCSASOFT -/* If we don't have TCSASOFT define it so that ORing it it below is a no-op. */ -# define TCSASOFT 0 -#endif - -/* SunOS 4.x which lacks _POSIX_VDISABLE, but has VDISABLE */ -#if !defined(_POSIX_VDISABLE) && defined(VDISABLE) -# define _POSIX_VDISABLE VDISABLE -#endif +static volatile sig_atomic_t readpassphrase_signo[_NSIG]; -static volatile sig_atomic_t signo[_NSIG]; +static void +readpassphrase_handler(int s) +{ -static void handler(int); + readpassphrase_signo[s] = 1; +} char * readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) @@ -925,6 +921,12 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) struct termios term, oterm; struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm; struct sigaction savetstp, savettin, savettou, savepipe; +/* If we don't have TCSASOFT define it so that ORing it it below is a no-op. */ +#ifndef TCSASOFT + const int tcasoft = 0; +#else + const int tcasoft = TCASOFT; +#endif /* I suppose we could alloc on demand in this case (XXX). */ if (bufsiz == 0) { @@ -934,7 +936,7 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) restart: for (i = 0; i < _NSIG; i++) - signo[i] = 0; + readpassphrase_signo[i] = 0; nr = -1; save_errno = 0; need_restart = 0; @@ -965,7 +967,7 @@ restart: if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) term.c_cc[VSTATUS] = _POSIX_VDISABLE; #endif - (void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term); + (void)tcsetattr(input, TCSAFLUSH|tcasoft, &term); } else { memset(&term, 0, sizeof(term)); term.c_lflag |= ECHO; @@ -980,7 +982,7 @@ restart: */ sigemptyset(&sa.sa_mask); sa.sa_flags = 0; /* don't restart system calls */ - sa.sa_handler = handler; + sa.sa_handler = readpassphrase_handler; (void)sigaction(SIGALRM, &sa, &savealrm); (void)sigaction(SIGHUP, &sa, &savehup); (void)sigaction(SIGINT, &sa, &saveint); @@ -1015,13 +1017,13 @@ restart: /* Restore old terminal settings and signals. */ if (memcmp(&term, &oterm, sizeof(term)) != 0) { - const int sigttou = signo[SIGTTOU]; + const int sigttou = readpassphrase_signo[SIGTTOU]; /* Ignore SIGTTOU generated when we are not the fg pgrp. */ - while (tcsetattr(input, TCSAFLUSH|TCSASOFT, &oterm) == -1 && - errno == EINTR && !signo[SIGTTOU]) + while (tcsetattr(input, TCSAFLUSH|tcasoft, &oterm) == -1 && + errno == EINTR && !readpassphrase_signo[SIGTTOU]) continue; - signo[SIGTTOU] = sigttou; + readpassphrase_signo[SIGTTOU] = sigttou; } (void)sigaction(SIGALRM, &savealrm, NULL); (void)sigaction(SIGHUP, &savehup, NULL); @@ -1040,7 +1042,7 @@ restart: * now that we have restored the signal handlers. */ for (i = 0; i < _NSIG; i++) { - if (signo[i]) { + if (readpassphrase_signo[i]) { kill(getpid(), i); switch (i) { case SIGTSTP: @@ -1057,13 +1059,6 @@ restart: errno = save_errno; return(nr == -1 ? NULL : buf); } - -static void -handler(int s) -{ - - signo[s] = 1; -} #endif /* !HAVE_READPASSPHRASE */ #if !HAVE_REALLOCARRAY /* diff --git a/configure b/configure @@ -15,7 +15,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -OCONFIGURE_VERSION="0.1.8" +OCONFIGURE_VERSION="0.1.10" # # This script outputs two files: config.h and Makefile.configure. @@ -349,9 +349,13 @@ cat << __HEREDOC__ #endif __HEREDOC__ -# For the function declaration variables... +# This is just for size_t. +# Most of these functions, in the real world, pull in <string.h> or +# someting that pulls in support for size_t. +# Our function declarations are standalone, so specify them here. [ ${HAVE_MD5} -eq 0 -o \ + ${HAVE_READPASSPHRASE} -eq 0 -o \ ${HAVE_REALLOCARRAY} -eq 0 -o \ ${HAVE_RECALLOCARRAY} -eq 0 -o \ ${HAVE_STRLCAT} -eq 0 -o \