[1090] in Kerberos-V5-bugs
util/ss/libss.a does not deal with posix signaling well
daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Sat Feb 11 14:39:13 1995
From: epeisach@MIT.EDU
Date: Sat, 11 Feb 1995 14:38:48 -0500
To: krb5-bugs@MIT.EDU
The ss library does not handle signals properly. In particular, there is
an assumption that BSD signaling conventions are adheared to. (see
example run). The following example is when one suspends a process and
resumes, the ss library exits one out... This was fixed in the MIT
sources about tw years ago with dealing with SOLARIS. Well, it bites on
OSF/1 as well an probably other platforms... The changes included are:
Makefile.in:
Use ARADD instead of ARCHIVE... Sorry, but modifying the source
code for one of the library items should not insert multiple copies of
the object in the library (which ARCHIVE does with -qv).
configure.in:
Add AC_PROG_ARCHIVE_ADD - see above
Add CHECK_SIGNALS - define POSIX_SIGNALS if proper
list_rqs.c, listen.c, pager.c: code changes conditional on
POSIX_SIGNALS...
Ezra
----------------------------------------------------------
Script started on Sat Feb 11 14:21:01 1995
% ./kdb5_edit
kdb5_edit: No such file or directory while setting active database to '/krb5/principal'
kdb5_edit: ^Z
Stopped
% fg
./kdb5_edit
kdb5_edit: %
%
------------------------------------------------
===================================================================
RCS file: /mit/krb5/.cvsroot/src/util/ss/Makefile.in,v
retrieving revision 1.17
diff -c -r1.17 Makefile.in
*** 1.17 1994/10/24 18:38:21
--- Makefile.in 1995/02/11 19:31:15
***************
*** 105,111 ****
all:: libss.a
libss.a: $(OBJS)
! $(ARCHIVE) $@ $(OBJS)
$(RANLIB) $@
clean::
--- 105,111 ----
all:: libss.a
libss.a: $(OBJS)
! $(ARADD) $@ $(OBJS)
$(RANLIB) $@
clean::
===================================================================
RCS file: /mit/krb5/.cvsroot/src/util/ss/configure.in,v
retrieving revision 1.12
diff -c -r1.12 configure.in
*** 1.12 1994/10/26 05:45:53
--- configure.in 1995/02/11 19:26:50
***************
*** 6,11 ****
--- 6,12 ----
AC_PROG_YACC
AC_PROG_AWK
AC_PROG_ARCHIVE
+ AC_PROG_ARCHIVE_ADD
AC_PROG_RANLIB
HAVE_YYLINENO
AC_FUNC_CHECK(strdup,AC_DEFINE(HAS_STRDUP))
***************
*** 14,19 ****
--- 15,21 ----
CHECK_DIRENT
CHECK_FCNTL
CHECK_WAIT_TYPE
+ CHECK_SIGNALS
CHECK_SIGPROCMASK
AC_RETSIGTYPE
CHECK_STDARG
===================================================================
RCS file: /mit/krb5/.cvsroot/src/util/ss/list_rqs.c,v
retrieving revision 1.2
diff -c -r1.2 list_rqs.c
*** 1.2 1994/10/24 18:38:30
--- list_rqs.c 1995/02/11 19:09:15
***************
*** 34,40 ****
--- 34,45 ----
FILE *output;
int fd;
int mask;
+ #ifdef POSIX_SIGNALS
+ struct sigaction nsig, osig;
+ sigset_t nmask, omask;
+ #else
RETSIGTYPE (*func)();
+ #endif
#ifndef WAIT_USES_INT
union wait waitb;
#else
***************
*** 44,54 ****
--- 49,76 ----
DONT_USE(argc);
DONT_USE(argv);
+ #ifdef POSIX_SIGNALS
+ sigemptyset(&nmask);
+ sigaddset(&nmask, SIGINT);
+ sigprocmask(SIG_BLOCK, &nmask, &omask);
+
+ nsig.sa_handler = SIG_IGN;
+ sigemptyset(&nsig.sa_mask);
+ nsig.sa_flags = 0;
+ sigaction(SIGINT, &nsig, &osig);
+ #else
mask = sigblock(sigmask(SIGINT));
func = signal(SIGINT, SIG_IGN);
+ #endif
+
fd = ss_pager_create();
output = fdopen(fd, "w");
+
+ #ifdef POSIX_SIGNALS
+ sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
+ #else
sigsetmask(mask);
+ #endif
fprintf (output, "Available %s requests:\n\n",
ss_info (sci_idx) -> subsystem_name);
***************
*** 84,88 ****
--- 106,114 ----
#ifndef NO_FORK
wait(&waitb);
#endif
+ #ifdef POSIX_SIGNALS
+ sigaction(SIGINT, &osig, (struct sigaction *)0);
+ #else
(void) signal(SIGINT, func);
+ #endif
}
===================================================================
RCS file: /mit/krb5/.cvsroot/src/util/ss/listen.c,v
retrieving revision 1.3
diff -c -r1.3 listen.c
*** 1.3 1994/10/24 18:38:32
--- listen.c 1995/02/11 19:24:12
***************
*** 47,78 ****
int sci_idx;
{
register char *cp;
- register RETSIGTYPE (*sig_cont)();
register ss_data *info;
- RETSIGTYPE (*sig_int)(), (*old_sig_cont)();
char input[BUFSIZ];
char buffer[BUFSIZ];
char *end = buffer;
- int mask;
int code;
jmp_buf old_jmpb;
ss_data *old_info = current_info;
current_info = info = ss_info(sci_idx);
- sig_cont = (RETSIGTYPE (*)())0;
info->abort = 0;
mask = sigblock(sigmask(SIGINT));
memcpy(old_jmpb, listen_jmpb, sizeof(jmp_buf));
sig_int = signal(SIGINT, listen_int_handler);
setjmp(listen_jmpb);
(void) sigsetmask(mask);
while(!info->abort) {
print_prompt();
*end = '\0';
old_sig_cont = sig_cont;
sig_cont = signal(SIGCONT, print_prompt);
if (sig_cont == print_prompt)
sig_cont = old_sig_cont;
if (fgets(input, BUFSIZ, stdin) != input) {
code = SS_ET_EOF;
goto egress;
--- 47,114 ----
int sci_idx;
{
register char *cp;
register ss_data *info;
char input[BUFSIZ];
char buffer[BUFSIZ];
char *end = buffer;
int code;
jmp_buf old_jmpb;
ss_data *old_info = current_info;
+ #ifdef POSIX_SIGNALS
+ struct sigaction isig, csig, nsig, osig;
+ sigset_t nmask, omask;
+ #else
+ register RETSIGTYPE (*sig_cont)();
+ RETSIGTYPE (*sig_int)(), (*old_sig_cont)();
+ int mask;
+ #endif
current_info = info = ss_info(sci_idx);
info->abort = 0;
+
+ #ifdef POSIX_SIGNALS
+ csig.sa_handler = (RETSIGTYPE (*)())0;
+ sigemptyset(&nmask);
+ sigaddset(&nmask, SIGINT);
+ sigprocmask(SIG_BLOCK, &nmask, &omask);
+ #else
+ sig_cont = (RETSIGTYPE (*)())0;
mask = sigblock(sigmask(SIGINT));
+ #endif
+
memcpy(old_jmpb, listen_jmpb, sizeof(jmp_buf));
+
+ #ifdef POSIX_SIGNALS
+ nsig.sa_handler = listen_int_handler;
+ sigemptyset(&nsig.sa_mask);
+ nsig.sa_flags = 0;
+ sigaction(SIGINT, &nsig, &isig);
+ #else
sig_int = signal(SIGINT, listen_int_handler);
+ #endif
+
setjmp(listen_jmpb);
+
+ #ifdef POSIX_SIGNALS
+ sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
+ #else
(void) sigsetmask(mask);
+ #endif
while(!info->abort) {
print_prompt();
*end = '\0';
+ #ifdef POSIX_SIGNALS
+ nsig.sa_handler = listen_int_handler; /* fgets is not signal-safe */
+ osig = csig;
+ sigaction(SIGCONT, &nsig, &csig);
+ if ((RETSIGTYPE (*)())csig.sa_handler==(RETSIGTYPE (*)())listen_int_handler)
+ csig = osig;
+ #else
old_sig_cont = sig_cont;
sig_cont = signal(SIGCONT, print_prompt);
if (sig_cont == print_prompt)
sig_cont = old_sig_cont;
+ #endif
if (fgets(input, BUFSIZ, stdin) != input) {
code = SS_ET_EOF;
goto egress;
***************
*** 83,89 ****
--- 119,129 ----
if (cp == input)
continue;
}
+ #ifdef POSIX_SIGNALS
+ sigaction(SIGCONT, &csig, (struct sigaction *)0);
+ #else
(void) signal(SIGCONT, sig_cont);
+ #endif
for (end = input; *end; end++)
;
***************
*** 105,111 ****
--- 145,155 ----
}
code = 0;
egress:
+ #ifdef POSIX_SIGNALS
+ sigaction(SIGINT, &isig, (struct sigaction *)0);
+ #else
(void) signal(SIGINT, sig_int);
+ #endif
memcpy(listen_jmpb, old_jmpb, sizeof(jmp_buf));
current_info = old_info;
return code;
===================================================================
RCS file: /mit/krb5/.cvsroot/src/util/ss/pager.c,v
retrieving revision 1.1
diff -c -r1.1 pager.c
*** 1.1 1993/06/03 12:31:13
--- pager.c 1995/02/11 19:20:52
***************
*** 67,79 ****
--- 67,96 ----
void ss_page_stdin()
{
int i;
+ #ifdef POSIX_SIGNALS
+ struct sigaction sa;
+ sigset_t mask;
+ #endif
for (i = 3; i < 32; i++)
(void) close(i);
+ #ifdef POSIX_SIGNALS
+ sa.sa_handler = SIG_DFL;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sigaction(SIGINT, &sa, (struct sigaction *)0);
+ #else
(void) signal(SIGINT, SIG_DFL);
+ #endif
{
+ #ifdef POSIX_SIGNALS
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGINT);
+ sigprocmask(SIG_UNBLOCK, &mask, (sigset_t *)0);
+ #else
int mask = sigblock(0);
mask &= ~sigmask(SIGINT);
sigsetmask(mask);
+ #endif
}
if (_ss_pager_name == (char *)NULL) {
if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL)