Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

357
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda