+2002-12-28 Ion Badulescu <ionut@moisil.badula.org>
+
+ * configure.in: increase library patchlevel
+
+ * libamu/xutil.c (amu_release_controlling_tty): close and reopen
+ file descriptors 0,1,2 before calling setsid()
+
2002-12-27 Erez Zadok <ezk@cs.sunysb.edu>
* updated copyright year to 2003 on all files
dnl
dnl AC_CONFIG_AUX_DIR(m4)
AC_PREREQ(2.52)
-AC_REVISION($Revision: 1.44 $)
+AC_REVISION($Revision: 1.45 $)
AC_COPYRIGHT([Copyright (c) 1997-2003 Erez Zadok])
dnl find out system type
AC_MSG_NOTICE(*** SYSTEM TYPES ***)
dnl
dnl We increase the minor number for am-utils-6.1, because it has a new API
dnl (get_server_pid) but can be used without problems by am-utils-6.0.3+.
-LIBTOOL_LDFLAGS="-version-info 5:2:3"
+LIBTOOL_LDFLAGS="-version-info 5:3:3"
AC_SUBST(LIBTOOL_LDFLAGS)
dnl ======================================================================
* SUCH DAMAGE.
*
*
- * $Id: xutil.c,v 1.28 2002/12/27 22:44:11 ezk Exp $
+ * $Id: xutil.c,v 1.29 2002/12/28 22:28:57 ib42 Exp $
*
*/
#endif /* TIOCNOTTY */
int tempfd;
-#ifdef HAVE_SETSID
- /* XXX: one day maybe use vhangup(2) */
- if (setsid() < 0) {
- plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m");
- } else {
- plog(XLOG_INFO, "released controlling tty using setsid()");
- return;
- }
-#endif /* HAVE_SETSID */
-
/*
* In daemon mode, leaving open file descriptors to terminals or pipes
* can be a really bad idea.
* Case in point: the redhat startup script calls us through their 'initlog'
- * program, which exits as soon as the original amd process exits. If, at some
- * point, a misbehaved library function decides to print something to the screen,
- * we get a SIGPIPE and die.
- * More precisely: NIS libc functions will attempt to print to stderr
+ * program, which exits as soon as the original amd process exits. If,
+ * at some point, a misbehaved library function decides to print something
+ * to the screen, we get a SIGPIPE and die.
+ * And guess what: NIS glibc functions will attempt to print to stderr
* "YPBINDPROC_DOMAIN: Domain not bound" if ypbind is running but can't find
* a ypserver.
*
fflush(stderr); close(2); dup2(tempfd, 2);
close(tempfd);
+#ifdef HAVE_SETSID
+ /* XXX: one day maybe use vhangup(2) */
+ if (setsid() < 0) {
+ plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m");
+ } else {
+ plog(XLOG_INFO, "released controlling tty using setsid()");
+ return;
+ }
+#endif /* HAVE_SETSID */
+
#ifdef TIOCNOTTY
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {