I was trying to create an example for FreeBSD 8-STABLE, and found that one cannot rely on (from system) ...
... If there is only one scalar argument, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system's command shell for parsing (this is "/bin/sh -c" on Unix platforms, but varies on other platforms). If there are no shell metacharacters in the argument, it is split into words and passed directly to "execvp", which is more efficient. ...
... as I could not find any trace of a shell for system q[date 2>&1] & ktrace via ...
ktrace -di perl -e 'print system q[date 2>&1]' \
&& kdump -d | fgrep /bin/sh
... had to use ...
ktrace -di perl -e 'print system q[date 2>&1 </dev/null]'
... to invoke the shell (/bin/sh). Apparently 2>&1 does not qualify as shell metacharacters (here).
(An actual example has yet to be produced.)
date 2
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|