You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# It's ok if cwd is nil. In that case Puppet::Util::Execution.execute() simply will not attempt to
327
+
# change the working directory, which is exactly the right behavior when no cwd parameter is
328
+
# expressed on the resource. Moreover, attempting to change to the directory that is already
329
+
# the working directory can fail under some circumstances, so avoiding the directory change attempt
330
+
# is preferable to defaulting cwd to that directory.
331
+
332
+
# note that we are passing "false" for the "override_locale" parameter, which ensures that the user's
333
+
# default/system locale will be respected. Callers may override this behavior by setting locale-related
334
+
# environment variables (LANG, LC_ALL, etc.) in their 'environment' configuration.
335
+
output=Puppet::Util::Execution.execute(
336
+
command,
337
+
failonfail: false,
338
+
combine: true,
339
+
cwd: cwd,
340
+
uid: resource[:user],
341
+
gid: resource[:group],
342
+
override_locale: false,
343
+
custom_environment: environment,
344
+
sensitive: false
345
+
)
346
+
# The shell returns 127 if the command is missing.
347
+
ifoutput.exitstatus == 127
348
+
raiseArgumentError,output
349
+
end
350
+
# Return output twice as processstatus was returned before, but only exitstatus was ever called.
351
+
# Output has the exitstatus on it so it is returned instead. This is here twice as changing this
352
+
# would result in a change to the underlying API.
353
+
[output,output]
354
+
end
355
+
356
+
defextractexe(command)
357
+
ifcommand.is_a?Array
358
+
command.first
359
+
else
360
+
match=/^"([^"]+)"|^'([^']+)'/.match(command)
361
+
ifmatch
362
+
# extract whichever of the two sides matched the content.
363
+
match[1]ormatch[2]
364
+
else
365
+
command.split(/ /)[0]
366
+
end
367
+
end
368
+
end
369
+
370
+
defvalidatecmd(command)
371
+
exe=extractexe(command)
372
+
# if we're not fully qualified, require a path
373
+
self.fail_("'%{exe}' is not qualified and no path was specified. Please qualify the command or specify a path.") % {exe: exe}if !absolute_path?(exe)andresource[:path].nil?
0 commit comments