In article <slrnflgt13.4vm.nospam@xxxxxxxxxxxxxx>,
Bob <nospam@xxxxxxxxxxxxxx> wrote:
Why does a call to system() work by passing the command line string
supplied to sh -c? This is causing problems when running in a chroot
environment where no sh is available. Wouldn't it be better for C to
replace the system() call by a fork()-exec() pair? Is there some
compiler option that can change the behavior of system()?
As far as the C standard is concerned, it could work either way.
But in practice it's much more useful if commands passed to system()
are treated the same way as commands typed to the shell. For example,
I expect system("rm *") to remove all the files in the directory,
which wouldn't happen if you just executed the "rm" program with with
argv[1] set to "*".
If you're writing code to work in a chroot()ed environment you quite
likely want to take special care with any commands you execute: I
suggest writing your own system()-like function that uses fork()
and exec() (and probably wait()) directly.
[UNIX] Vulnerabilities Found in Scponly ...SSHd environment files.... the user can upload a file with a custom ... This provides the user with a means of running arbitrary commands... the user could execute arbitrary commands by uploading ... (Securiteam)
Re: Process Understanding ... their environment, especially env variables. ... the that one user has a bash shell while the other has no shell ... The environment variables are read by software commands.... Now when you execute the source command again, ... (Fedora)
Re: Execute commands from file ... It is possible to execute them command by command, ... "like if the commands was typed one after the other in a interactive session", ... The problem with this approach is that each line executes without any connection to the environment created by previous lies. ... and you will see NameError raised because the assignment hasn't affected the environment for the print statement.... (comp.lang.python)
Re: In need of a SHELL Script - Please!!! ... if the commands in the file must be executed ... Absolutely correct but none of that applies to this particular script.... just trying to move a bunch of files, not affect the environment.... he just doesn't know how to make the script executable and/or how to execute... (comp.unix.shell)
Re: Learning LaTeX? ... advantages over normal commands, myself -- look at the difficulties involved with grabbing all of the inside text as an argument to a command, for example. ... It's fairly easy to tell what a \endor an \endis delineating, but a corresponding closing brace would only be clear if the author were either fastidious about indenting or commented the closing brace -- and, in either case, it's very possible that the author could have made a typo and thus be incorrect about what the closing brace were closing. ... There is an interesting contrast to be made between LaTeX-style environments with \begin, \enddelineation, and ConTeXt-style environments with \startenvironment, \stopenvironment delineation. ... The former makes it much easier to include some generic code in every environment; the latter makes grabbing the inside text as an argument relatively easy. ... (comp.text.tex)