limiting a plugin function from opening a file

This is a discussion on limiting a plugin function from opening a file within the C Programming forums, part of the General Programming Boards category; Hi, I am working on a small program which I would like to be extensible with plugins written by external ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    limiting a plugin function from opening a file

    Hi,

    I am working on a small program which I would like to be extensible with plugins written by external parties (using the dlopen family of commands). However I would like to provide a basic level of security by limiting the potential of a plugin to cause harm.

    For example, say I do not want plugins to be able to read or write files. Is there a way for me to be able to prevent a function in the plugin library from calling (for example) fopen()?

    I have been looking for some time now but can't work out if this is possible at all, and if it is, how it could be done.

    Thanks,

    Jath

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    I can't think of any easy (or practically feasible way). This is why most programs that allow third party plugins invent their own domain specific language and just parse that themselves, instead of just blindly allowing arbitrary binaries to be loaded in.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    If the plugins are binary code, then no. You can't choose what they can or not. The best you can do is give guidelines to what they may and may not do.
    That or create and parse your own language.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    2
    Thanks for the quick replies. OK, looks like it'll have to be either user beware or I get very familiar with bison/flex.

    Jath

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21