Re: run a piece of code before start a program *always*




Unruh wrote:
"gaetanoortisi@xxxxxxxx" <gaetanoortisi@xxxxxxxx> writes:

Hello,
as the subject says: suppose I want to prefix the execution of an
application with a log program
that records the session so that is not possible to run the application
directly without being logged.


What is the smart solution?

Write a shell script which calls the log and then calls the renamed
program.


I guess it depends upon how rigorous you want "not possible" to be.
Interpreting that as I would, a shell script isn't going to cut it, but
a setuid binary that sets up the logging and then execs the actual
program (which has its perms set only to be executable only by the
setuid person or group) would prevent un-logged use.

Or, you could use sudo ( gentle intro at
http://aplawrence.com/Basics/sudo.html ) to enforce a similar idea, but
that's not quite so bulletproof for this use.


--
Tony Lawrence
Unix/Linux/Mac OS X Resources
http://aplawrence.com

.



Relevant Pages

  • Re: Spawning process with environment variables
    ... There is no difference at this level: Every system invocation passes ... a single-line script to a shell for execution. ... invoking a library call which creates a coprocess whose purpose is to ... execution of shell scripts instead of writing shell script controlling ...
    (comp.unix.programmer)
  • Re: Spawning process with environment variables
    ... shell running the command" and writing and then executing a new ... a single-line script to a shell for execution. ... execution of shell scripts instead of writing shell script controlling ...
    (comp.unix.programmer)
  • Re: Spawning process with environment variables
    ... shell running the command" and writing and then executing a new ... a single-line script to a shell for execution. ... execution of shell scripts instead of writing shell script controlling ...
    (comp.unix.programmer)
  • Re: Spawning process with environment variables
    ... shell running the command" and writing and then executing a new ... a single-line script to a shell for execution. ... execution of shell scripts instead of writing shell script controlling ...
    (comp.unix.programmer)
  • 40% slowdown with dynamic /bin/sh
    ... Here is a simple test which times the execution of a null ... shell script. ... It basically times fork/exec of the chosen shell. ... % cat harness.sh ...
    (freebsd-current)