Visit Our UNIX and Linux User Community


Capture child processes and change return values question


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Capture child processes and change return values question
# 1  
Old 08-04-2009
Question Capture child processes and change return values question

Thanks in advance.
My environment is Ubuntu 9.04 desktop customized to be a high school classroom server for teaching code development. I have a unique "fake" jail called "lshell" which is very easy to setup and restricts users to commands that I dictate DISALLOWING ANYTHING ELSE. These questions below represent the last piece we would love to have for this open project.

I have a very specific need. I need to accomplish the following (without discussion about jail environments please).

I'd like users in a shell to enter "gedit" or other software/IDE, and do work. When the user makes a "File and Open" step they can only see or examine their directory and nowhere else.
Questions: Can I use one of the traces(l,p,s) or is their another way to restrict "what they can see"? Can these commands, along with some scripting, be used to return their top directory as $theirusername only and not be able to navigate elsewhere? Perhaps change some returning value say of
/home/jail/home/user to /user .

I can post the lshell.py script that I am using as the limited shell, if needed.

Thanks
# 2  
Old 08-04-2009
If you are not already doing so have you considered using chroot(1) as part of this?

Jailkit - chroot jail utilities looks helpful, as does: http://unixwiz.net/techtips/chroot-practices.html but this one should be looked at also: Breaking out of a chroot() padded cell!
# 3  
Old 08-04-2009
Instead of hacking this at the system call level, why not put user you want to restrict into a chroot? They really, genuinely wouldn't have access to anything you didn't put in there.
# 4  
Old 08-04-2009
Thanks, I need to read up on chroot and it's usage.

Doesn't it require copying lots of files/libs into the chrooted envronment. I'm trying to avoid such a thing, as it makes it more difficult for teachers, new to Linux, to replicate this along with everything else already in place.

Will the command really lock a user down as needed and does it allow gedit or similar as I expressed above?

Upon further searching, maybe fakechroot and fakeroot will work. Let you know when I give it a try.

Last edited by tuxhats; 08-05-2009 at 01:07 PM..
# 5  
Old 08-05-2009
Quote:
Originally Posted by tuxhats
Doesn't it require copying lots of files/libs into the chrooted envronment. I'm trying to avoid such a thing, as it makes it more difficult for teachers, new to Linux, to replicate this along with everything else already in place.
You could just link files instead of copying them. They would have to be hardlinks, not symlinks, but it wouldn't need to be copied wholesale as long as its on the same partition.
# 6  
Old 08-05-2009
It seems that everyone is pointing to symlinks, jails, and NOT towards interception and return of modified info to the user. fakeroot and chroot aren't answers I'm after.

If I can intercept say a returning $DIR and make it $username only, it should work regardless of the app I make available to the user.
# 7  
Old 08-06-2009
Quote:
Originally Posted by tuxhats
It seems that everyone is pointing to symlinks, jails, and NOT towards interception and return of modified info to the user.
Yes... There's a reason for that: The way you want to go about this is odd, unreliable, nonportable, and dangerous. You can make your system unbootable trying to override libraries this way, or accidentally open security holes, and make your life a whole lot harder for yourself in general, all for the sake of doing this your way instead of the standard way UNIX has supported for a very long time.

Last edited by Corona688; 08-06-2009 at 04:06 PM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #166
Difficulty: Easy
The Internet is a packet-switched network.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get all child processes of a process

is there a universal way of getting the children of a particular process? i'm looking for a solution that works across different OSes...linux, aix, sunos, hpux. i did a search online and i kept finding answers that were specific to Linux..i.e. pstree. i want to be able to specify a process... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

How to capture C program return values in Kshell

I have a K shell script (ksh) that needs to return an email address. A C program was written (prog1) to now access the email address off of an oracle table. The call to the program in the ksh is prog1 -p parm1 Based on Parm1 the program will read an oracle table and retrieve the email... (2 Replies)
Discussion started by: jclanc8
2 Replies

3. Programming

How to capture messages from child process?

Hi all, I'm new in programming, but want to start writing a simple GUI for linux console application,say, wget.(for educational purpose :) ). The question is: how to start child process from C++ code and then start capture messages from its stdout? Thanks in advance. (2 Replies)
Discussion started by: vahagn_iv
2 Replies

4. Shell Programming and Scripting

how to capture PID for a child script

Hi, I'm looking for a method where we can capture the PID and if possible the progress of child process especially the ones running in background. can anyone help? (6 Replies)
Discussion started by: aman jain
6 Replies

5. UNIX for Advanced & Expert Users

killing all child processes

Hi, Is there a way I can kill all the child processes of a process, given its process id. Many thanks in advance. J. (1 Reply)
Discussion started by: superuser84
1 Replies

6. Shell Programming and Scripting

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies

7. Programming

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies

8. Shell Programming and Scripting

Parent/Child Processes

Hello. I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors? Thanks (2 Replies)
Discussion started by: yoi2hot4ya
2 Replies

9. Programming

Controlling child processes

Hello all, I am trying to create n child processes and control them from a parent process; say make child 3 print its pid and then child 5 do the same and some other stuff. Is there a way to accomplishing this after all the child processes are created via a call to fork(). Thank you, FG (23 Replies)
Discussion started by: forumGuy
23 Replies

10. UNIX for Dummies Questions & Answers

what are parent and child processes all about?

I don't follow what these are... this is what my text says... "When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Discussion started by: xyyz
1 Replies

Featured Tech Videos