Jump to content

Can you run a program with restricted io access.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
Somelauw

Somelauw

    Newbie

  • Members
  • PipPip
  • 18 posts
I want to make a program run but I want to limit it's reading, writing and execution rights to the stdin and stdout only.
The program should not be able to modify anything else than the stdin and stdout.
I think I could use chmod for this and maybe assign a userid to the program of a user with very few rights. The disadvantage would be that I need to create a dummy user.

Is there a way to restrict the file-acces with as few modifications to my system as possible?
My OS is an Ubuntu.
I would also like to be able to limit the memory the program is allowed to use when running.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I'm a little confused about that. Do you mean you want to give it no rights to access files at all? Depending on what else you want it to do, that could be awkward. Ultimately, you can choose to only use stdin and stdout, but a pipe or redirect will get around that. Running it as a special user isn't really limiting the program, just the environment.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Somelauw

Somelauw

    Newbie

  • Members
  • PipPip
  • 18 posts

WingedPanther said:

Ultimately, you can choose to only use stdin and stdout, but a pipe or redirect will get around that.

Yes, I want to limit it's input/output to stdin/stdout.
I don't understand how the program is able to get around this using piping or redirect.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
When you call a program from the command line, you can specify the input/output to be results of other programs, files, etc. The result is that the OS will hook stdin/stdout to something other than the keyboard/monitor.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Somelauw

Somelauw

    Newbie

  • Members
  • PipPip
  • 18 posts

WingedPanther said:

When you call a program from the command line, you can specify the input/output to be results of other programs, files, etc. The result is that the OS will hook stdin/stdout to something other than the keyboard/monitor.

That's completely fine and it's even what I want.
Can you tell me how to restrict a program like this?

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Only use stdin and stdout for your output when you code it. It's more of a languages issue than an OS issue.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
Somelauw

Somelauw

    Newbie

  • Members
  • PipPip
  • 18 posts

WingedPanther said:

Only use stdin and stdout for your output when you code it. It's more of a languages issue than an OS issue.

Yes, but I want to limit it externally since I am not writing the program itself.

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I don't think this will be possible. If you provide support to load the libraries for using stdin/stdout, then other libraries can be loaded as well, for things like GUI interfaces, etc.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog