Thread: How to stop a program from accessing the file system

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    8

    How to stop a program from accessing the file system

    I don't want my programs to access the file system at all
    means no file creation, no deletion not even the a single stream for accessing files.
    how can i do that

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    So, don't create, open, or delete files?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Go away.
    If you can't tell us which OS you're using, we're going to get fed up "real soon now" of even caring whether you get an answer or not.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    8
    Quote Originally Posted by Salem View Post
    Go away.
    If you can't tell us which OS you're using, we're going to get fed up "real soon now" of even caring whether you get an answer or not.
    sorry for that
    i use windows xp
    but i can migrate to ubuntu if it is possible only on linux

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I find it quite unlikely that you would be able to start an application without accessing the filesystem on either of Linux or Windows.

    You can of course have a read-only filesystem [available in both] that would essentially prevent any CHANGES to the filesystem.

    If you explain what your ultimate goal is (I suspect that you are trying to set up an internet cafe/student computer room or similar and want to prevent users from corrupting the machines), we may be able to suggest better solutions.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273

  7. #7
    Registered User
    Join Date
    May 2008
    Posts
    8
    the scenario is that i have to some programs on my system.
    the programs are quite simple, hardly 4-5 classes, i have to test it on my system but i dont want to mess up my system up because i dont know the code provided and c++ is really powerful .. other then these class files i wont the program to touch any other filse

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by gogoc View Post
    the scenario is that i have to some programs on my system.
    the programs are quite simple, hardly 4-5 classes, i have to test it on my system but i dont want to mess up my system up because i dont know the code provided and c++ is really powerful .. other then these class files i wont the program to touch any other filse
    So, make your filesystem read only. You can do that trivially by setting up a different user that has no access to write to any directory on the machine.

    But a quick code-review should expose any trivial attempts to do harmful things to your system. If the attempts are really complex, then you probably want to run this in a virtual machine that doesn't have access to the hardware at all, such as Xen or VMWare's solutions. Both are free.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by gogoc View Post
    the scenario is that i have to some programs on my system.
    the programs are quite simple, hardly 4-5 classes, i have to test it on my system but i dont want to mess up my system up because i dont know the code provided and c++ is really powerful .. other then these class files i wont the program to touch any other filse
    Then run the programs inside a VMWare image. If the image gets messed up, who cares -- just bring up a clean image and continue...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  4. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 01:04 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM