Important: Please read the Qt Code of Conduct -

Real read-only file Windows

  • I need to create a application for a LAN, like a little chat, but I need to save logs files with the conversations, but the files can't be erased or edited, is possible to do that? and if is possible I need a clue.


  • Moderators

    As far as I know that is not possible.

    Linux has a pretty obscure feature of an "append" flag for just such purposes. Files with this flag set can only have contents appended, no other write operations are possible. But even this flag is more meant as a way to prevent accidents than to stop file owners from editing it.

    Depending on how temper proof you need your system to be you could just run a logger process as some system user, have it log into files belonging to this system user and only allow read access to the users. Might be good enough, even though any admin (or anybody booting from a linux live CD) can still meddle with the logs.

    The only temper-proof way I can see is to write your file to a WORM (Write Once Read Many) medium.

    Alternatively you might be able to come up with a system based on hashes and asymetric encryption which could detect manipulation of the log file. But make sure to get lots of reviews on your architecture and implementation if you go down this alley: It is hard to get this right!

  • Thanks for the answer, I thought it was not possible, and thanks for the alternatives

Log in to reply