spawn() is just a wrapper for DOS compatibility. There are WinExec, ShellExecute, ShellExecuteEx, CreateProcess, CreateProcessEx, CreateProcessAsUser, CreateProcessWithLogonW, CreateProcessWithTokenW, and perhaps another dozen of functions and wrappers for creating a process in different ways, and with ridiculusly complicated data structures for input and output parameters. It's just pain once you understand how simple and elegant fork() and exec() are. Hooking those Windows functions may be possible, some have documented hook functions, others don't.

On Unix (Linux), the fakeroot package (a Debian project) may help, perhaps combined with chroot. chroot the entire script collection in a root jail, then run perl as unprivileged user via fakeroot. While everything seems to be a "real" root environment, it isn't. All files belong the unprivileged user, and if they don't, the faked root simply can't open/read/modify/delete them -- unless you give explicit permissions to the unprivileged user. And thanks to chroot, a rm -rf / "just" damages the root jail, which can be restored with a simple tar xf.

Alexander


In reply to Re^2: mocking or trapping system calls by Anonymous Monk
in thread mocking or trapping system calls by wu-lee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.