]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
man: mention O_NOCTTY and it's importance in daemon(7)
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Mar 2019 15:55:46 +0000 (16:55 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 Mar 2019 14:13:33 +0000 (15:13 +0100)
Fixes: #9164
man/daemon.xml

index 7724bb4e08d8efa25008bd9d0cd051b010c9f339..41da01943c6a65dd2ae8b1adbc73d184f420917e 100644 (file)
         <function>setsid()</function> to detach from any terminal and
         create an independent session.</para></listitem>
 
-        <listitem><para>In the child, call <function>fork()</function>
-        again, to ensure that the daemon can never re-acquire a
-        terminal again.</para></listitem>
+        <listitem><para>In the child, call <function>fork()</function> again, to ensure that the daemon can
+        never re-acquire a terminal again. (This relevant if the program — and all its dependencies — does
+        not carefully specify `O_NOCTTY` on each and every single `open()` call that might potentially open a
+        TTY device node.)</para></listitem>
 
         <listitem><para>Call <function>exit()</function> in the first
         child, so that only the second child (the actual daemon
         and
         <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para></listitem>
 
+        <listitem><para>As new-style daemons are invoked without a controlling TTY (but as their own session
+        leaders) care should be taken to always specify `O_NOCTTY` on `open()` calls that possibly reference
+        a TTY device node, so that no controlling TTY is accidentally acquired.</para></listitem>
+
       </orderedlist>
 
       <para>These recommendations are similar but not identical to the