]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-escape.xml
resolved: basic OpenSSL support for DNS-over-TLS
[thirdparty/systemd.git] / man / systemd-escape.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="systemd-escape"
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>systemd-escape</title>
14 <productname>systemd</productname>
15 </refentryinfo>
16
17 <refmeta>
18 <refentrytitle>systemd-escape</refentrytitle>
19 <manvolnum>1</manvolnum>
20 </refmeta>
21
22 <refnamediv>
23 <refname>systemd-escape</refname>
24 <refpurpose>Escape strings for usage in systemd unit names</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <cmdsynopsis>
29 <command>systemd-escape</command>
30 <arg choice="opt" rep="repeat">OPTIONS</arg>
31 <arg choice="opt" rep="repeat">STRING</arg>
32 </cmdsynopsis>
33 </refsynopsisdiv>
34
35 <refsect1>
36 <title>Description</title>
37
38 <para><command>systemd-escape</command> may be used to escape
39 strings for inclusion in systemd unit names. The command may be
40 used to escape and to undo escaping of strings.</para>
41
42 <para>The command takes any number of strings on the command line,
43 and will process them individually, one after another. It will
44 output them separated by spaces to stdout.</para>
45
46 <para>By default, this command will escape the strings passed,
47 unless <option>--unescape</option> is passed which results in the
48 inverse operation being applied. If <option>--mangle</option> is given, a
49 special mode of escaping is applied instead, which assumes the
50 string is already escaped but will escape everything that
51 appears obviously non-escaped.</para>
52
53 <para>For details on the escaping and unescaping algorithms see the relevant section in
54 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
55 </refsect1>
56
57 <refsect1>
58 <title>Options</title>
59
60 <para>The following options are understood:</para>
61
62 <variablelist>
63 <varlistentry>
64 <term><option>--suffix=</option></term>
65
66 <listitem><para>Appends the specified unit type suffix to the
67 escaped string. Takes one of the unit types supported by
68 systemd, such as <literal>service</literal> or
69 <literal>mount</literal>. May not be used in conjunction with
70 <option>--template=</option>, <option>--unescape</option> or
71 <option>--mangle</option>.</para></listitem>
72 </varlistentry>
73
74 <varlistentry>
75 <term><option>--template=</option></term>
76
77 <listitem><para>Inserts the escaped strings in a unit name
78 template. Takes a unit name template such as
79 <filename>foobar@.service</filename>. With
80 <option>--unescape</option>, expects instantiated unit names
81 for this template and extracts and unescapes just the instance
82 part. May not be used in conjunction with
83 <option>--suffix=</option>,
84 <option>--instance</option> or
85 <option>--mangle</option>.</para></listitem>
86 </varlistentry>
87
88 <varlistentry>
89 <term><option>--path</option></term>
90 <term><option>-p</option></term>
91
92 <listitem><para>When escaping or unescaping a string, assume it refers to a file system path. This eliminates
93 leading, trailing or duplicate <literal>/</literal> characters and rejects <literal>.</literal> and
94 <literal>..</literal> path components. This is particularly useful for generating strings suitable for
95 unescaping with the <literal>%f</literal> specifier in unit files, see
96 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
97 </para></listitem>
98 </varlistentry>
99
100 <varlistentry>
101 <term><option>--unescape</option></term>
102 <term><option>-u</option></term>
103
104 <listitem><para>Instead of escaping the specified strings,
105 undo the escaping, reversing the operation. May not be used in
106 conjunction with <option>--suffix=</option> or
107 <option>--mangle</option>.</para></listitem>
108 </varlistentry>
109
110 <varlistentry>
111 <term><option>--mangle</option></term>
112 <term><option>-m</option></term>
113
114 <listitem><para>Like <option>--escape</option>, but only
115 escape characters that are obviously not escaped yet, and
116 possibly automatically append an appropriate unit type suffix
117 to the string. May not be used in conjunction with
118 <option>--suffix=</option>, <option>--template=</option> or
119 <option>--unescape</option>.</para></listitem>
120 </varlistentry>
121
122 <varlistentry>
123 <term><option>--instance</option></term>
124
125 <listitem><para>With <option>--unescape</option>, unescape
126 and print only the instance part of an instantiated unit name
127 template. Results in an error for an uninstantiated template
128 like <filename>ssh@.service</filename> or a non-template name
129 like <filename>ssh.service</filename>.
130 Must be used in conjunction with <option>--unescape</option>
131 and may not be used in conjunction with
132 <option>--template</option>.</para></listitem>
133 </varlistentry>
134
135 <xi:include href="standard-options.xml" xpointer="help" />
136 <xi:include href="standard-options.xml" xpointer="version" />
137 </variablelist>
138
139 </refsect1>
140
141 <refsect1>
142 <title>Examples</title>
143
144 <para>To escape a single string:</para>
145 <programlisting>$ systemd-escape 'Hallöchen, Meister'
146 Hall\xc3\xb6chen\x2c\x20Meister</programlisting>
147
148 <para>To undo escaping on a single string:</para>
149 <programlisting>$ systemd-escape -u 'Hall\xc3\xb6chen\x2c\x20Meister'
150 Hallöchen, Meister</programlisting>
151
152 <para>To generate the mount unit for a path:</para>
153 <programlisting>$ systemd-escape -p --suffix=mount "/tmp//waldi/foobar/"
154 tmp-waldi-foobar.mount</programlisting>
155
156 <para>To generate instance names of three strings:</para>
157 <programlisting>$ systemd-escape --template=systemd-nspawn@.service 'My Container 1' 'containerb' 'container/III'
158 systemd-nspawn@My\x20Container\x201.service systemd-nspawn@containerb.service systemd-nspawn@container-III.service</programlisting>
159
160 <para>To extract the instance part of an instantiated unit:</para>
161 <programlisting>$ systemd-escape -u --instance 'systemd-nspawn@My\x20Container\x201.service'
162 My Container 1</programlisting>
163
164 <para>To extract the instance part of an instance of a particular template:</para>
165 <programlisting>$ systemd-escape -u --template=systemd-nspawn@.service 'systemd-nspawn@My\x20Container\x201.service'
166 My Container 1</programlisting>
167 </refsect1>
168
169 <refsect1>
170 <title>Exit status</title>
171
172 <para>On success, 0 is returned, a non-zero failure code
173 otherwise.</para>
174 </refsect1>
175
176 <refsect1>
177 <title>See Also</title>
178 <para>
179 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
180 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
181 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
182 </para>
183 </refsect1>
184
185 </refentry>