[PATCH] write only

peter pan lanwanhr at yahoo.com
Thu Feb 12 12:08:00 GMT 2004


We use rsync to provide an rsync share on a linux server with a javascript
program on Windows clients which ensures all client data is backed up each
morning.

After making no progress with my posting last month regarding making a module
upload only to prevent someone from manually downloading the rsync share
obtaining other users work (exclude = * wasn't possible because we need
--delete to work) I have had a go at making a patch to add this functionality
to rsync.

I've added a write only option to rsyncd.conf which is essentially the opposite
of read only.  This means that although it's possible someone on our allowed IP
range could overwrite (or delete) files on the rsync share, they would not be
allowed to download any files (my primary concern).

Below is the patch for rsync-2.6.0 however there are some points I'd like to
make:

- I don't know c :) (I once did a quick program for an assignment 10 years
ago),
- I've never made a diff patch before so I might be doing it wrong,
- I don't really understand rsync's internals or all the ramifications of these
changes,
- The patch doesn't change man pages etc.

It's extremely unlikely I've done everything right - so if any one would like
to point areas I'm falling down on I'd appreciate it.

J

------------------------------------

--- rsync-2.6.0/main.c.orig     Thu Feb 12 11:47:38 2004
+++ rsync-2.6.0/main.c  Thu Feb 12 11:48:16 2004
@@ -347,12 +347,19 @@ static void do_server_sender(int f_in, i
        int i;
        struct file_list *flist;
        char *dir = argv[0];
+        extern int module_id;
        extern int relative_paths;
        extern int recurse;
 
        if (verbose > 2)
                rprintf(FINFO,"server_sender starting pid=%d\n",(int)getpid());
 
+        if (am_daemon && lp_write_only(module_id) && !am_sender) {
+                rprintf(FERROR,"ERROR: module is write only\n");
+                exit_cleanup(RERR_SYNTAX);
+                return;
+        }
+
        if (!relative_paths && !push_dir(dir, 0)) {
                rprintf(FERROR, "push_dir %s failed: %s (3)\n",
                        full_fname(dir), strerror(errno));
--- rsync-2.6.0/loadparm.c.orig Thu Feb 12 11:47:17 2004
+++ rsync-2.6.0/loadparm.c      Thu Feb 12 11:48:11 2004
@@ -119,6 +119,7 @@ typedef struct
        char *comment;
        char *lock_file;
        BOOL read_only;
+        BOOL write_only;
        BOOL list;
        BOOL use_chroot;
        BOOL transfer_logging;
@@ -151,6 +152,7 @@ static service sDefault =
        NULL,    /* comment */
        DEFAULT_LOCK_FILE,    /* lock file */
        True,    /* read only */
+       False,   /* write only */
        True,    /* list */
        True,    /* use chroot */
        False,   /* transfer logging */
@@ -276,6 +278,7 @@ static struct parm_struct parm_table[] =
   {"lock file",        P_STRING,  P_LOCAL,  &sDefault.lock_file,   NULL,   0},
   {"path",             P_PATH,    P_LOCAL,  &sDefault.path,        NULL,   0},
   {"read only",        P_BOOL,    P_LOCAL,  &sDefault.read_only,   NULL,   0},
+  {"write only",       P_BOOL,    P_LOCAL,  &sDefault.write_only,  NULL,   0},
   {"list",             P_BOOL,    P_LOCAL,  &sDefault.list,        NULL,   0},
   {"use chroot",       P_BOOL,    P_LOCAL,  &sDefault.use_chroot,  NULL,   0},
   {"ignore nonreadable",P_BOOL,   P_LOCAL,  &sDefault.ignore_nonreadable, 
NULL,   0},
@@ -353,6 +356,7 @@ FN_LOCAL_STRING(lp_comment, comment)
 FN_LOCAL_STRING(lp_path, path)
 FN_LOCAL_STRING(lp_lock_file, lock_file)
 FN_LOCAL_BOOL(lp_read_only, read_only)
+FN_LOCAL_BOOL(lp_write_only, write_only)
 FN_LOCAL_BOOL(lp_list, list)
 FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
 FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
--- rsync-2.6.0/proto.h.orig    Thu Feb 12 11:48:01 2004
+++ rsync-2.6.0/proto.h Thu Feb 12 11:48:23 2004
@@ -125,6 +125,7 @@ char *lp_comment(int );
 char *lp_path(int );
 char *lp_lock_file(int );
 BOOL lp_read_only(int );
+BOOL lp_write_only(int );
 BOOL lp_list(int );
 BOOL lp_use_chroot(int );
 BOOL lp_transfer_logging(int );

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


More information about the rsync mailing list