Mpart2tar

README at trunk
Login

File README artifact 1a18b50c1f on branch trunk



1. Before doing anything with this Software, read the LICENCE at the
   end of mpart2tar.c file. Each program has at the end a COPYRIGHT
   notice.

2. The distribution directory Mpart2tar contains:

 a) This README file.

 b) upload.tcl is a very simple cgi script that offers a web form
    for uploading a text message and some files. The generated form 
    data is stored on the server as a file of type multipart/form-data.
    If it is configurated to save files in directory Uploads in the
    home directory of user username in server sereveraddr, you can get
    new uploads with:

     rsync -av username@serveraddr:Uploads/ Uploads

    But from time to time you must log into the server and delete old post.

 c) mpart2tar.c is a program that takes a file as above and gives in 
    stdout a tar file containing the contents of the form. If compiled 
    as mpart2tar, the usage is like:

     mpart2tar formdatafile > formdatafile.tar
     mpart2tar formdatafile | tar tvf -
     mpart2tar formdatafile | tar xvf -

    The tar file expands as directory formdatafile-d with two files
    for each field of the form, one with the headers and one with
    the given content.
 
3. For installing upload.tcl

 (a) Put in the first line the path to the tclsh interpreter.
 (b) Put in line beginning with "set Dir" the path of the directory 
     where files must be uploaded. It must be writable by the web server.
 (c) Put in line beginning with "set N" the maximal number of uploads allowed.
 (d) Put in line beginning with "set M" the maximal size of an upload in bytes.
 (e) Put this script where the CGI server reads it.

4. For installing mpart2tar

 (a) Adapt the headers of mpart2tar.c to your system. 
 (b) Compile mpart2tar.c with: cc -o mpart2tar mpart2tar.c
 (c) Put the generated mpart2tar in your PATH.

 Examples:
 (a) In FreeBSD 11.4 should compile without changes. 
 (b) For OpenBSD delete "#include <malloc_np.h>". 
 (c) For Debian also put on the top
      "#define _GNU_SOURCE" and "#include <stdint.h>".

5. Background

 I wanted to offer a form for uploading files with a simple cgi script,
 just for circumventing email. The CGI server offers in stdout the
 form fields, the first line has a separator of the parts, each part 
 has at the beginning a header block, an empty line and a form field.
 Before saving this to a file, I added a "from line" at the beginning, 
 some headers that the server offers in the environement variables, 
 mainly "Content-Type" that also contains the separator as parameter 
 "boundary", and an empty line, in order that it appear to be a mail 
 folder containing an email with mime attachements. With this I hoped 
 to be able to separate the parts with a normal mail program: it does 
 not work because lines are separated with \r\n and these programs in 
 Unix expect lines separated with \n. To replace \n with \r\n does not 
 help, because the file, opposite to mails, may contain arbitrary binary 
 data. That is why I wrote mpart2tar.c. I kept update.tcl as simple as 
 possible, but usable, and wrote mpart2tar.c more generic than necessary, 
 in order to experiment with them.

6. What can be done with it?

 For example make the CGI script send the file encrypted per Email, 
 instead of saving it in the server, or at least to save it encrypted. 
 Or make it send an Email anouncing new post. Or to make other CGI 
 script for managing and reading the postbox after authentication. 
 Or to offer postboxes for many users. Just some ideas.