This file is indexed.

/usr/share/doc/cockpit/guide/cockpit-spawn.html is in cockpit-doc 164-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>cockpit.js: Spawning Processes</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Cockpit Guide">
<link rel="up" href="api-base1.html" title="API: base1">
<link rel="prev" href="cockpit-http.html" title="cockpit.js: HTTP Client">
<link rel="next" href="cockpit-metrics.html" title="cockpit.js: Metrics">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="cockpit-http.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="api-base1.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Cockpit Guide</th>
<td><a accesskey="n" href="cockpit-metrics.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="cockpit-spawn"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>cockpit.js: Spawning Processes</h2>
<p>cockpit.js: Spawning Processes — Spawning processes or scripts</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<p>This is the API for spawning a process and receiving its output, as well
    as exit codes.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-spawn"></a><h2>cockpit.spawn()</h2>
<pre class="programlisting">
process = cockpit.spawn(args, [options])
</pre>
<p>Spawns a process on the system.</p>
<p>The <code class="code">args</code> should be an array starting with the executable and
      containing all the arguments to pass on the command line. If <code class="code">args</code>
      is a string then it is interpreted as an executable name. The optional
      <code class="code">options</code> argument is a javascript plain object and can contain
      any of the following fields:
    </p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">"binary"</code></span></p></td>
<td><p>If set to <code class="code">true</code> then handle the input and output
          of the process as arrays of binary bytes.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"directory"</code></span></p></td>
<td><p>The directory to spawn the process in.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"err"</code></span></p></td>
<td><p>Controls where the standard error is sent. By default it is logged
          to the journal. If set to <code class="code">"out"</code> it is included in with the
          output data. If set to <code class="code">"ignore"</code> then the error output is discarded.
          If set to <code class="code">"message"</code>, then it will be returned as the error message.
          When the <code class="code">"pty"</code> field is set, this field has no effect.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"host"</code></span></p></td>
<td><p>The remote host to spawn the process on. If an alternate user or port is
          required it can be specified as <code class="code">"user@myhost:port"</code>. If no host is
          specified then the correct one will be automatically selected based on the page
          calling this function.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"environ"</code></span></p></td>
<td><p>An optional array that contains strings to be used as
          additional environment variables for the new process. These are
          <code class="code">"NAME=VALUE"</code> strings.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"pty"</code></span></p></td>
<td><p>Launch the process in its own PTY terminal, and send/receive
          terminal input and output.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"batch"</code></span></p></td>
<td><p>Batch data coming from the process in blocks of at least this
            size. This is not a guarantee. After a short timeout the data will be sent
            even if the data doesn't match the batch size. Defaults to zero.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"latency"</code></span></p></td>
<td><p> The timeout for flushing any cached data in milliseconds.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">"superuser"</code></span></p></td>
<td>
<p>Set to <code class="code">"require"</code> to spawn the process as root instead of
            the logged in user. If the currently logged in user is not permitted to become root
            (eg: via <code class="code">pkexec</code>) then the <code class="code">client</code> will immediately be
            <a class="link" href="cockpit-dbus.html#cockpit-dbus-onclose" title="client.onclose">closed</a> with a <code class="code">"access-denied"</code>
            problem code.</p>
<p>Set to <code class="code">"try"</code> to try to run the process as root, but if that fails,
            fall back to an unprivileged process.</p>
</td>
</tr>
</tbody>
</table></div>
<p>The spawned process is a
      <a class="ulink" href="https://www.promisejs.org/" target="_top">promise</a>
      that will complete if the process exits successfully, or fail if there's a problem.
      Some additional methods besides the standard promise methods are documented
      below.</p>
<p>The standard output of the process is made available via the spawned process
      object. Any non-UTF8 output from the process will be coerced into textual form.
      It is highly recommended that only textual output be produced by the command.
      The standard error is logged to the journal.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-script"></a><h2>cockpit.script()</h2>
<pre class="programlisting">
process = cockpit.script(script, [args], [options])
</pre>
<p>Run a shell script on the system.</p>
<p>This function <a class="link" href="cockpit-spawn.html#cockpit-spawn-spawn" title="cockpit.spawn()">spawns</a> a Bourne shell script
      process. The full text of the <code class="code">/bin/sh</code> shell script should be passed in as
      the first argument. The <code class="code">args</code> can be an array of arguments, not including
      the executable, which are passed to the script as <code class="code">$1</code>, <code class="code">$2</code> and
      so on. Shebang options are not used or respected.</p>
<p>The <code class="code">options</code> is an optional javascript plain object and can include
      any of the fields listed for the
      <a class="link" href="cockpit-spawn.html#cockpit-spawn-spawn" title="cockpit.spawn()"><code class="code">cockpit.spawn()</code></a> function.</p>
<p>The spawned process is a
      <a class="ulink" href="https://www.promisejs.org/" target="_top">promise</a>
      that will complete if the script exits successfully, or fail if there's a problem.
      Some additional methods besides the standard promise methods are documented
      below.</p>
<p>The standard output of the process is made available via the spawned process
      object. Any non-UTF8 output from the process will be coerced into textual form.
      It is highly recommended that only textual output be produced by the command.
      The standard error is logged to the journal by default.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-done"></a><h2>process.done()</h2>
<pre class="programlisting">
process.done(function(data[, message]) { ... })
</pre>
<p>This is a standard
      <a class="ulink" href="https://www.promisejs.org/" target="_top">promise</a>
      method. It sets up a handler to be called when the process finishes successfully.</p>
<p>The <code class="code">data</code> argument contains the standard output of the process.
      If it a string, unless the process was opened in binary mode, in which case the
      <code class="code">data</code> is an array of bytes. If a
      <code class="code"><a class="link" href="cockpit-spawn.html#cockpit-spawn-stream" title="process.stream()">process.stream()</a></code>
      handler is set up, then any standard output data consumed by the handler will not
      be included in the <code class="code">data</code> argument.</p>
<p>If the process was spawned with the <code class="code">"err"</code> option set to
      <code class="code">"message"</code> then the second argument will contain the standard error
      output of the process.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-fail"></a><h2>process.fail()</h2>
<pre class="programlisting">
process.fail(function(exception[, data]) { ... })
</pre>
<p>This is a standard
      <a class="ulink" href="http://api.jquery.com/category/deferred-object/" target="_top">jQuery promise</a> method.
      It sets up a handler to be called when the process fails, terminates or exits.</p>
<p>The <code class="code">exception</code> object passed to the handler can have the
      following fields:</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">message</code></span></p></td>
<td><p>A message describing the exception. If the process was spawned with
            the <code class="code">"err"</code> option set to <code class="code">"message"</code> then the second argument
            will contain the standard error output of the process.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">problem</code></span></p></td>
<td><p>A <a class="link" href="cockpit-error.html#cockpit-problems" title="Problem Codes">problem code</a> string when
          a problem occurred starting or communicating with the process. This is <code class="code">null</code>
          if the process exited or was terminated.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">exit_status</code></span></p></td>
<td><p>The numeric exit status of the process. This is <code class="code">null</code> if
          the process did not exit.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">exit_signal</code></span></p></td>
<td><p>A string representing a unix signal that caused the process to terminate.
          This is <code class="code">null</code> if the process did not terminate because of a signal.</p></td>
</tr>
</tbody>
</table></div>
<p>If the process actually ran and produced output before failing, it will be available in
      the <code class="code">data</code> argument. Otherwise this argument will be <code class="code">undefined</code>.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-always"></a><h2>process.always()</h2>
<pre class="programlisting">
process.always(function() { ... })
</pre>
<p>This is a standard
      <a class="ulink" href="http://api.jquery.com/category/deferred-object/" target="_top">jQuery promise</a> method.
      It sets up a handler to be called when the process completes, whether it exits successfully,
      fails, terminates, or exits with a failure.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-stream"></a><h2>process.stream()</h2>
<pre class="programlisting">
process.stream(function(data) { ... })
</pre>
<p>This sets up a handler to be called when the process has standard output. The
      handler will be called multiple times. The handler will be called regardless of
      whether the process ends up exiting successfully or not.</p>
<p>Only one handler may be registered at a time. Registering an additional handler
      replaces the previous one. The handler receives either string <code class="code">data</code> or
      an array of binary bytes as its argument. A stream handler may return a number, which
      indicates the number of characters or bytes consumed from <code class="code">data</code>. Any data
      not consumed will be included again the next time the handler is called.</p>
<p>If a <code class="code">process.stream()</code> handler is set up, then the
      <code class="code"><a class="link" href="cockpit-spawn.html#cockpit-spawn-done" title="process.done()">process.done()</a></code> handlers will
      only get any remaining data not consumed by the stream handler.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-input"></a><h2>process.input()</h2>
<pre class="programlisting">
process.input(data, [stream])
</pre>
<p>This method writes <code class="code">data</code> to the standard input of the process.
      If <code class="code">data</code> is <code class="code">null</code> or <code class="code">undefined</code> it is not sent.
      The <code class="code">data</code> should be a string or an array of bytes if the process was
      opened in binary mode.</p>
<p>If <code class="code">stream</code> is set to <code class="code">true</code> then this function may be
      called again with further input. Otherwise the standard input of the process
      is closed.</p>
</div>
<div class="refsection">
<a name="cockpit-spawn-close"></a><h2>process.close()</h2>
<pre class="programlisting">
process.close([problem])
</pre>
<p>Close the process by closing its standard input and output. If <code class="code">problem</code> is
      specified it should be a standard
      <a class="link" href="cockpit-error.html#cockpit-problems" title="Problem Codes">problem code</a> string. In this case the
      process will be terminated with a signal.</p>
</div>
</div>
<div class="footer"><hr></div>
</body>
</html>