Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

356
Views
Linux: let a process fail, if it does opens a file for writing

I would like a command-line-tool to fail if it opens a particular file for writing.

Is there a way I can modify the environment (maybe via cgroups) of the command-line tool, so that the command/process gets (for example) "permission denied"?

chmod a-w file does not work. The process seems to unlink() and then re-create the file.

I know that I can watch the syscalls of a process with strace. But is there a way to alter some calls, so that the process gets a different result?

Background: unittesting

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

strace has an option called -e inject or simply --inject which can be used to alter system calls of the tracee. (See manpage here)

In particular, in can be combined with the -P option to only trace syscalls accessing a specified path.

over 4 years ago · Santiago Trujillo Report

0

Since the calls are honored in the order they are loaded from shared libraries, you can use LD_PRELOAD to load a custom library prior to the system libraries and hijack their execution. This is used by many network card accelerators like OpenOnload from Solarflare/Xilinx.

https://sumit-ghosh.com/articles/hijacking-library-functions-code-injection-ld-preload/

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!