svn commit: samba r18132 - in
branches/SAMBA_4_0/source/lib/replace: .
tridge at samba.org
tridge at samba.org
Wed Sep 6 05:27:01 GMT 2006
Author: tridge
Date: 2006-09-06 05:27:01 +0000 (Wed, 06 Sep 2006)
New Revision: 18132
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18132
Log:
getpass can't depend on fns in lib/util/
Modified:
branches/SAMBA_4_0/source/lib/replace/getpass.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/getpass.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/getpass.c 2006-09-06 05:21:32 UTC (rev 18131)
+++ branches/SAMBA_4_0/source/lib/replace/getpass.c 2006-09-06 05:27:01 UTC (rev 18132)
@@ -114,6 +114,32 @@
static struct termios t;
#endif /* SYSV_TERMIO */
+static void catch_signal(int signum,void (*handler)(int ))
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction act;
+ struct sigaction oldact;
+
+ memset(&act, 0, sizeof(act));
+
+ act.sa_handler = handler;
+#ifdef SA_RESTART
+ /*
+ * We *want* SIGALRM to interrupt a system call.
+ */
+ if(signum != SIGALRM)
+ act.sa_flags = SA_RESTART;
+#endif
+ sigemptyset(&act.sa_mask);
+ sigaddset(&act.sa_mask,signum);
+ sigaction(signum,&act,&oldact);
+ return oldact.sa_handler;
+#else /* !HAVE_SIGACTION */
+ /* FIXME: need to handle sigvec and systems with broken signal() */
+ return signal(signum, handler);
+#endif
+}
+
char *getsmbpass(const char *prompt)
{
FILE *in, *out;
@@ -123,7 +149,7 @@
size_t nread;
/* Catch problematic signals */
- CatchSignal(SIGINT, SIGNAL_CAST SIG_IGN);
+ catch_signal(SIGINT, SIGNAL_CAST SIG_IGN);
/* Try to write to and read from the terminal if we can.
If we can't open the terminal, use stderr and stdin. */
@@ -175,7 +201,7 @@
fclose (in);
/* Catch problematic signals */
- CatchSignal(SIGINT, SIGNAL_CAST SIG_DFL);
+ catch_signal(SIGINT, SIGNAL_CAST SIG_DFL);
printf("\n");
return buf;
More information about the samba-cvs
mailing list