naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
594167
From 05ea18897aeafa1f2d47c5eae6c43bdd6ff71b9d Mon Sep 17 00:00:00 2001
594167
From: Yonathan Randolph <yonathan@gmail.com>
594167
Date: Sun, 26 Dec 2021 17:12:00 -0800
594167
Subject: [PATCH] man: clarify Environmentfile format
594167
594167
Remove incorrect claim that C escapes (such as \t and \n) are recognized and that control characters are disallowed. Specify the allowed characters and escapes with single quotes, with double quotes, and without quotes.
594167
594167
(cherry picked from commit 4bbcde8498eb59557ebddd7830efb47c0297ff4b)
594167
594167
Related: #2017035
594167
---
594167
 man/systemd.exec.xml | 51 ++++++++++++++++++++++++++++----------------
594167
 1 file changed, 33 insertions(+), 18 deletions(-)
594167
594167
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
594167
index cd21d5b28d..69858d5e59 100644
594167
--- a/man/systemd.exec.xml
594167
+++ b/man/systemd.exec.xml
594167
@@ -2485,18 +2485,39 @@ SystemCallErrorNumber=EPERM</programlisting>
594167
       <varlistentry>
594167
         <term><varname>EnvironmentFile=</varname></term>
594167
 
594167
-        <listitem><para>Similar to <varname>Environment=</varname> but reads the environment variables from a text
594167
-        file. The text file should contain new-line-separated variable assignments.  Empty lines, lines without an
594167
-        <literal>=</literal> separator, or lines starting with ; or # will be ignored, which may be used for
594167
-        commenting. A line ending with a backslash will be concatenated with the following one, allowing multiline
594167
-        variable definitions. The parser strips leading and trailing whitespace from the values of assignments, unless
594167
-        you use double quotes (").</para>
594167
-
594167
-        <para><ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C escapes</ulink>
594167
-        are supported, but not
594167
-        <ulink url="https://en.wikipedia.org/wiki/Control_character#In_ASCII">most control characters</ulink>.
594167
-        <literal>\t</literal> and <literal>\n</literal> can be used to insert tabs and newlines within
594167
-        <varname>EnvironmentFile=</varname>.</para>
594167
+        <listitem><para>Similar to <varname>Environment=</varname> but reads the environment variables from a text file.
594167
+        The text file should contain newline-separated variable assignments.  Empty lines, lines without an
594167
+        <literal>=</literal> separator, or lines starting with <literal>;</literal> or <literal>#</literal> will be
594167
+        ignored, which may be used for commenting. The file must be UTF-8 encoded. Valid characters are 
594167
+        url="https://www.unicode.org/glossary/#unicode_scalar_value">unicode scalar values</ulink> other than 
594167
+        url="https://www.unicode.org/glossary/#noncharacter">noncharacters</ulink>, U+0000 NUL, and U+FEFF 
594167
+        url="https://www.unicode.org/glossary/#byte_order_mark">byte order mark</ulink>. Control codes other than NUL
594167
+        are allowed.</para>
594167
+
594167
+        <para>In the file, an unquoted value after the <literal>=</literal> is parsed with the same backslash-escape
594167
+        rules as 
594167
+        url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_01">unquoted
594167
+        text</ulink> in a POSIX shell, but unlike in a shell, interior whitespace is preserved and quotes after the
594167
+        first non-whitespace character are preserved. Leading and trailing whitespace (space, tab, carriage return) is
594167
+        discarded, but interior whitespace within the line is preserved verbatim. A line ending with a backslash will be
594167
+        continued to the following one, with the newline itself discarded. A backslash
594167
+        <literal>\</literal> followed by any character other than newline will preserve the following character, so that
594167
+        <literal>\\</literal> will become the value <literal>\</literal>.</para>
594167
+
594167
+        <para>In the file, a <literal>'</literal>-quoted value after the <literal>=</literal> can span multiple lines
594167
+        and contain any character verbatim other than single quote, like 
594167
+        url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_02">single-quoted
594167
+        text</ulink> in a POSIX shell. No backslash-escape sequences are recognized. Leading and trailing whitespace
594167
+        outside of the single quotes is discarded.</para>
594167
+
594167
+        <para>In the file, a <literal>"</literal>-quoted value after the <literal>=</literal> can span multiple lines,
594167
+        and the same escape sequences are recognized as in 
594167
+        url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03">double-quoted
594167
+        text</ulink> of a POSIX shell. Backslash (<literal>\</literal>) followed by any of <literal>"\`$</literal> will
594167
+        preserve that character. A backslash followed by newline is a line continuation, and the newline itself is
594167
+        discarded. A backslash followed by any other character is ignored; both the backslash and the following
594167
+        character are preserved verbatim. Leading and trailing whitespace outside of the double quotes is
594167
+        discarded.</para>
594167
 
594167
         <para>The argument passed should be an absolute filename or wildcard expression, optionally prefixed with
594167
         <literal>-</literal>, which indicates that if the file does not exist, it will not be read and no error or
594167
@@ -2529,12 +2550,6 @@ SystemCallErrorNumber=EPERM</programlisting>
594167
         <para>Variables set for invoked processes due to this setting are subject to being overridden by those
594167
         configured with <varname>Environment=</varname> or <varname>EnvironmentFile=</varname>.</para>
594167
 
594167
-        <para><ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C escapes</ulink>
594167
-        are supported, but not
594167
-        <ulink url="https://en.wikipedia.org/wiki/Control_character#In_ASCII">most control characters</ulink>.
594167
-        <literal>\t</literal> and <literal>\n</literal> can be used to insert tabs and newlines within
594167
-        <varname>EnvironmentFile=</varname>.</para>
594167
-
594167
         <para>Example:
594167
         <programlisting>PassEnvironment=VAR1 VAR2 VAR3</programlisting>
594167
         passes three variables <literal>VAR1</literal>,