jlistf has asked for the wisdom of the Perl Monks concerning the following question:

here's my problem:
i want to limit access to an FTP server for certain users, but the server admin will not let me set up more than one account. so, i'm trying to restrict access with a perl program, specifically a CGI script. first question: does this sound possible?

now, i want to keep one connection to the server open throughout the whole process, but i'm going to have to either re-run the same script a couple of times, or run more than one script to do the user interface. it doesn't seem like i can keep the connection open if i stop the script and start a new one. heres my idea: i run some sort of umbrella script that opens the connection, works with the FTP server and then closes it, and another set of scripts that deals with user interface which will send commands to the umbrella script. second question: does this sound possible?

thanks for any help. i'm open to suggestions... even comments that i'm a fool.

Replies are listed 'Best First'.
Re: advice about FTP/CGI
by BBQ (Curate) on Jul 11, 2000 at 20:12 UTC
    I'm not sure I understand exactly what it is you're trying to do, but if I had to do a workaround (via CGI) I'd do the following:
    • create a "permissions" table with usernames and passwords
    • accept file uploads via CGI authenticating against that table
    • after accepting the upload, connect to the FTP server with your default account
    • upload the file via Net::FTP
    • disconnect and return the status through CGI
    The obvious downside to this, is the time required to do multiple file transfers. First you'd need to upload the file to the webserver and then transfer the same file to the FTP server. This could take a while depending on the size of the file!

    Of course, I would also check with the server admin if this is a problem (and I would think it is, or else (s)he would have granted FTP access to your users in the first place). Instead of using FTP, I am currently working on a Virtual Filesystem with MySQL, so that users can share and store files via HTTPS. As soon as I finish it, I will be posting the code to the Code Catacombs.

    #!/home/bbq/bin/perl
    # Trust no1!
      i guess that'll work out. ideally, i'd like to provide the users with the same functionality as a direct FTP connection, just limit which files they can alter. if i do that with this method, it could take a real long time to perform a command. (open connection, perform command, get results, close connection, return results)

      the server admin shouldn't have any problem though. the users will all have access through one (my) account. the perl script is just there to limit which files each user can alter. basically the perl script will mimic the permission effects of multiple accounts while still only using one.