Sean Finney on Sun, 16 Jun 2002 18:50:14 +0200 |
On Sun, Jun 16, 2002 at 12:12:51PM -0400, Walt Mankowski wrote: > On Sat, Jun 15, 2002 at 02:00:05PM -0400, Fred K Ollinger wrote: > > The user does supply one of the strings, but I'm not going to do a system > > b/c I don't know how to get that to work easily w/ a pointer to a char > > array. > > system(3) only takes one parameter -- a pointer to a character array. > What's the problem? I imagine that the string he gets from the user is the filename of the source or destination file, whereas to system(3) he wants to pass something like "cp user_specified_file somewhere_else". this would be really easy to do with exec/fork(2), something like execl("/bin/cp", "cp", "userfile", "otherfile", NULL), but again, there are similar security implications to system(3) if this is setuid root. I think really the best thing to do here is just do the code that does the copying with read/write, since it's less complex than exec/fork anyway, and doesn't have the same security troubles. --sean ______________________________________________________________________ Philadelphia Linux Users Group - http://www.phillylinux.org Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce General Discussion - http://lists.phillylinux.org/mail/listinfo/plug
|
|