getspwuid.c gettime.c glob.c goodpath.c gram.c gram.y interfaces.c \
iolog.c isblank.c lbuf.c ldap.c list.c logging.c match.c mksiglist.c \
mkstemp.c memrchr.c nanosleep.c parse.c parse_args.c pwutil.c \
- set_perms.c sigaction.c snprintf.c strcasecmp.c strerror.c strlcat.c \
- strlcpy.c strsignal.c sudo.c sudo_noexec.c sudo_edit.c sudo_nss.c \
- term.c testsudoers.c tgetpass.c toke.c toke.l tsgetgrpw.c utimes.c \
- vasgroups.c visudo.c zero_bytes.c redblack.c selinux.c sesh.c \
+ set_perms.c setsid.c sigaction.c snprintf.c strcasecmp.c strerror.c \
+ strlcat.c strlcpy.c strsignal.c sudo.c sudo_noexec.c sudo_edit.c \
+ sudo_nss.c term.c testsudoers.c tgetpass.c toke.c toke.l tsgetgrpw.c \
+ utimes.c vasgroups.c visudo.c zero_bytes.c redblack.c selinux.c sesh.c \
sudoreplay.c getdate.c getdate.y getline.c timestr.c $(AUTH_SRCS)
AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/bsdauth.c auth/dce.c auth/fwtk.c \
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/redblack.c
set_perms.o: $(srcdir)/set_perms.c $(SUDODEP)
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/set_perms.c
+setsid.o: $(srcdir)/setsid.c $(srcdir)/compat.h config.h
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/setsid.c
sigaction.o: $(srcdir)/sigaction.c $(srcdir)/compat.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sigaction.c
siglist.o: siglist.c $(srcdir)/compat.h config.h
/* Define to 1 to send mail when the user is not in the sudoers file. */
#undef SEND_MAIL_WHEN_NO_USER
+/* Define to 1 if the `setpgrp' function takes no argument. */
+#undef SETPGRP_VOID
+
/* Define to 1 if you want sudo to start a shell if given no arguments. */
#undef SHELL_IF_NO_ARGS
done
+fi
+done
+
+for ac_func in setsid
+do :
+ ac_fn_c_check_func "$LINENO" "setsid" "ac_cv_func_setsid"
+if test "x$ac_cv_func_setsid" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SETSID 1
+_ACEOF
+
+else
+
+ case " $LIBOBJS " in
+ *" setsid.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS setsid.$ac_objext"
+ ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setpgrp takes no argument" >&5
+$as_echo_n "checking whether setpgrp takes no argument... " >&6; }
+if test "${ac_cv_func_setpgrp_void+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ as_fn_error "cannot check setpgrp when cross compiling" "$LINENO" 5
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+/* If this system has a BSD-style setpgrp which takes arguments,
+ setpgrp(1, 1) will fail with ESRCH and return -1, in that case
+ exit successfully. */
+ return setpgrp (1,1) != -1;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ac_cv_func_setpgrp_void=no
+else
+ ac_cv_func_setpgrp_void=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setpgrp_void" >&5
+$as_echo "$ac_cv_func_setpgrp_void" >&6; }
+if test $ac_cv_func_setpgrp_void = yes; then
+
+$as_echo "#define SETPGRP_VOID 1" >>confdefs.h
+
+fi
+
+
fi
done
AC_LIBOBJ(getline)
AC_CHECK_FUNCS(fgetln)
])
+AC_CHECK_FUNCS(setsid, [], [
+ AC_LIBOBJ(setsid)
+ AC_FUNC_SETPGRP
+])
AC_CHECK_FUNCS(sysctl getutid getutxid, [break])
* and the slave pty as the controlling terminal.
* This allows us to be notified when the child has been suspended.
*/
-#ifdef HAVE_SETSID
if (setsid() == -1) {
warning("setsid");
goto bad;
}
-#else
-# ifdef TIOCNOTTY
- n = open(_PATH_TTY, O_RDWR|O_NOCTTY);
- if (n >= 0) {
- /* Disconnect from old controlling tty. */
- if (ioctl(n, TIOCNOTTY, NULL) == -1)
- warning("cannot disconnect controlling tty");
- close(n);
- }
-# endif
- setpgrp(0, 0);
-#endif
if (io_fds[SFD_SLAVE] != -1) {
#ifdef TIOCSCTTY
if (ioctl(io_fds[SFD_SLAVE], TIOCSCTTY, NULL) != 0)
}
/* Daemonize - disassociate from session/tty. */
-#ifdef HAVE_SETSID
if (setsid() == -1)
warning("setsid");
-#else
- setpgrp(0, 0);
-# ifdef TIOCNOTTY
- if ((fd = open(_PATH_TTY, O_RDWR, 0644)) != -1) {
- ioctl(fd, TIOCNOTTY, NULL);
- close(fd);
- }
-# endif
-#endif
(void) chdir("/");
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0644)) != -1) {
(void) dup2(fd, STDIN_FILENO);
#ifndef HAVE_STRSIGNAL
char *strsignal __P((int));
#endif
+#ifndef HAVE_SETSID
+pid_t setsid __P((void));
+#endif
#endif /* _SUDO_MISSING_H */
--- /dev/null
+/*
+ * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+
+#include <fcntl.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <pathnames.h>
+#include <compat.h>
+
+pid_t
+setsid()
+{
+ int fd;
+
+#ifdef SETPGRP_VOID
+ if (setpgrp() == -1)
+#else
+ if (setpgrp(0, 0) == -1)
+#endif
+ return -1;
+# ifdef TIOCNOTTY
+ if ((fd = open(_PATH_TTY, O_RDWR, 0644)) != -1) {
+ (void) ioctl(fd, TIOCNOTTY, NULL);
+ close(fd);
+ }
+# endif
+ return getpid();
+}