From 609944a5f7dfa77cf0964e75f134da445a113b67 Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Fri, 5 Aug 1994 22:49:46 +0000 Subject: [PATCH] * configure.in: test for sigprocmask and sigset_t to set POSIX_SIGNALS. * krlogin.c, kcmd.c: use POSIX_SIGNALS. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4052 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/bsd/ChangeLog | 5 +++++ src/appl/bsd/configure.in | 5 +++++ src/appl/bsd/kcmd.c | 28 ++++++++++++++++++++++++++++ src/appl/bsd/krlogin.c | 37 ++++++++++++++++++++++++++++++++++--- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index 3e0894338..c5c17f435 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,8 @@ +Fri Aug 5 18:47:00 1994 Mark Eichin (eichin@cygnus.com) + + * configure.in: test for sigprocmask and sigset_t to set POSIX_SIGNALS. + * krlogin.c, kcmd.c: use POSIX_SIGNALS. + Fri Aug 5 15:35:54 1994 Mark Eichin (eichin@cygnus.com) * configure.in, logutil.c: check for NO_UT_PID, use it. diff --git a/src/appl/bsd/configure.in b/src/appl/bsd/configure.in index ae55528f0..98ffd4bae 100644 --- a/src/appl/bsd/configure.in +++ b/src/appl/bsd/configure.in @@ -15,6 +15,11 @@ AC_FUNC_CHECK(killpg,AC_DEFINE(HAVE_KILLPG)) AC_FUNC_CHECK(getdtablesize,AC_DEFINE(HAVE_GETDTABLESIZE)) AC_FUNC_CHECK(initgroups,AC_DEFINE(HAVE_INITGROUPS)) AC_FUNC_CHECK(setpriority,AC_DEFINE(HAVE_SETPRIORITY)) +AC_FUNC_CHECK(sigprocmask, +AC_COMPILE_CHECK([sigset_t], +[#include ], +[sigset_t x], +AC_DEFINE(POSIX_SIGNALS))) AC_HAVE_HEADERS(sys/filio.h sys/sockio.h unistd.h sys/label.h ttyent.h sys/ptyvar.h lastlog.h) AC_REPLACE_FUNCS(getdtablesize) CHECK_DIRENT diff --git a/src/appl/bsd/kcmd.c b/src/appl/bsd/kcmd.c index d6d9f4a4b..094bc55f3 100644 --- a/src/appl/bsd/kcmd.c +++ b/src/appl/bsd/kcmd.c @@ -51,9 +51,11 @@ static char sccsid[] = "derived from @(#)rcmd.c 5.17 (Berkeley) 6/27/88"; #endif #include #include +#ifndef POSIX_SIGNALS #ifndef sigmask #define sigmask(m) (1 << ((m)-1)) #endif +#endif /* POSIX_SIGNALS */ #include #include @@ -94,7 +96,11 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, krb5_flags authopts; { int i, s, timo = 1, pid; +#ifdef POSIX_SIGNALS + sigset_t oldmask, urgmask; +#else long oldmask; +#endif struct sockaddr_in sin, from, local_laddr; krb5_creds *ret_cred = 0; char c; @@ -165,11 +171,17 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, /* XXX we should free the old realm first */ krb5_princ_set_realm(ret_cred->server, &rdata); } +#ifdef POSIX_SIGNALS + sigemptyset(&urgmask); + sigaddset(&urgmask, SIGURG); + sigprocmask(SIG_BLOCK, &urgmask, &oldmask); +#else #ifdef sgi oldmask = sigignore(sigmask(SIGURG)); #else oldmask = sigblock(sigmask(SIGURG)); #endif +#endif /* POSIX_SIGNALS */ for (;;) { s = getport(&lport); @@ -178,9 +190,13 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, fprintf(stderr, "socket: All ports in use\n"); else perror("kcmd: socket"); +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &oldmask, (sigset_t*)0); +#else #ifndef sgi sigsetmask(oldmask); #endif +#endif /* POSIX_SIGNALS */ if (tmpstr) krb5_xfree(tmpstr); if (host_save) krb5_xfree(host_save); krb5_free_creds(ret_cred); @@ -224,9 +240,13 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, } #endif /* !(defined(ultrix) || defined(sun)) */ perror(hp->h_name); +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &oldmask, (sigset_t*)0); +#else #ifndef sgi sigsetmask(oldmask); #endif +#endif /* POSIX_SIGNALS */ if (tmpstr) krb5_xfree(tmpstr); if (host_save) krb5_xfree(host_save); krb5_free_creds(ret_cred); @@ -391,9 +411,13 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, status = -1; goto bad3; } +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &oldmask, (sigset_t*)0); +#else #ifndef sgi sigsetmask(oldmask); #endif +#endif /* POSIX_SIGNALS */ *sock = s; if (tmpstr) krb5_xfree(tmpstr); if (host_save) krb5_xfree(host_save); @@ -410,9 +434,13 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, (void) close(*fd2p); bad: (void) close(s); +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &oldmask, (sigset_t*)0); +#else #ifndef sgi sigsetmask(oldmask); #endif +#endif /* POSIX_SIGNALS */ if (tmpstr) krb5_xfree(tmpstr); if (host_save) krb5_xfree(host_save); if (ret_cred) diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index 3143d0ff7..ba66f823a 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -207,9 +207,11 @@ char term[256] = "network"; extern int errno; krb5_sigtype lostpeer(); int dosigwinch = 0; +#ifndef POSIX_SIGNALS #ifndef sigmask -#define sigmask(m) (1 << ((m)-1)) +#define sigmask(m) (1 << ((m)-1)) #endif +#endif /* POSIX_SIGNALS */ #ifdef NO_WINSIZE struct winsize { unsigned short ws_row, ws_col; @@ -304,7 +306,12 @@ main(argc, argv) #endif struct passwd *pwd; struct servent *sp; - int uid, options = 0, oldmask; + int uid, options = 0; +#ifdef POSIX_SIGNALS + sigset_t *oldmask, omask, urgmask; +#else + int oldmask; +#endif int on = 1; #ifdef KERBEROS char **orig_argv = argv; @@ -512,11 +519,19 @@ main(argc, argv) (void) signal(SIGPIPE, lostpeer); /* will use SIGUSR1 for window size hack, so hold it off */ +#ifdef POSIX_SIGNALS + sigemptyset(&urgmask); + sigaddset(&urgmask, SIGURG); + sigaddset(&urgmask, SIGUSR1); + oldmask = &omask; + sigprocmask(SIG_BLOCK, &urgmask, oldmask); +#else #ifdef sgi oldmask = sigignore(sigmask(SIGURG) | sigmask(SIGUSR1)); #else oldmask = sigblock(sigmask(SIGURG) | sigmask(SIGUSR1)); #endif +#endif /* POSIX_SIGNALS */ if (debug_port) sp->s_port = htons(debug_port); @@ -689,6 +704,9 @@ struct ltchars noltc = { -1, -1, -1, -1, -1, -1 }; #endif doit(oldmask) +#ifdef POSIX_SIGNALS + sigset_t *oldmask; +#endif { #ifdef POSIX_TERMIOS (void) tcgetattr(0, &deftty); @@ -762,9 +780,14 @@ doit(oldmask) */ (void) signal(SIGURG, copytochild); (void) signal(SIGUSR1, writeroob); + +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, oldmask, (sigset_t*)0); +#else #ifndef sgi (void) sigsetmask(oldmask); #endif +#endif /* POSIX_SIGNALS */ (void) signal(SIGCHLD, catchild); writer(); prf("Closed connection."); @@ -1228,9 +1251,13 @@ krb5_sigtype * reader: read from remote: line -> 1 */ reader(oldmask) +#ifdef POSIX_SIGNALS + sigset_t *oldmask; +#else int oldmask; +#endif { -#if (defined(BSD) && BSD >= 43) || defined(ultrix) +#if (defined(BSD) && BSD+0 >= 43) || defined(ultrix) int pid = getpid(); #else int pid = -getpid(); @@ -1245,9 +1272,13 @@ reader(oldmask) (void) fcntl(rem, F_SETOWN, pid); #endif (void) setjmp(rcvtop); +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, oldmask, (sigset_t*)0); +#else #ifndef sgi (void) sigsetmask(oldmask); #endif +#endif /* POSIX_SIGNALS */ for (;;) { while ((remaining = rcvcnt - (bufp - rcvbuf)) > 0) { rcvstate = WRITING; -- 2.26.2