- Made readlink_stat() and link_stat() optionally follow a symlink
[rsync/rsync.git] / clientserver.c
index 697d026..501e6e4 100644 (file)
@@ -207,7 +207,8 @@ int start_inband_exchange(char *user, char *path, int f_in, int f_out, int argc)
 static int rsync_module(int f_in, int f_out, int i)
 {
        int argc = 0;
-       char *argv[MAX_ARGS];
+       int maxargs;
+       char **argv;
        char **argp;
        char line[MAXPATHLEN];
        uid_t uid = (uid_t)-2;  /* canonically "nobody" */
@@ -230,7 +231,7 @@ static int rsync_module(int f_in, int f_out, int i)
        }
 
        if (am_daemon && am_server) {
-               rprintf(FINFO, "rsync allowed access on module %s from %s (%s)\n",
+               rprintf(FLOG, "rsync allowed access on module %s from %s (%s)\n",
                        name, host, addr);
        }
 
@@ -385,6 +386,9 @@ static int rsync_module(int f_in, int f_out, int i)
 
        io_printf(f_out, "@RSYNCD: OK\n");
 
+       maxargs = MAX_ARGS;
+       if (!(argv = new_array(char *, maxargs)))
+               out_of_memory("rsync_module");
        argv[argc++] = "rsyncd";
 
        while (1) {
@@ -396,23 +400,25 @@ static int rsync_module(int f_in, int f_out, int i)
 
                p = line;
 
+               if (argc == maxargs) {
+                       maxargs += MAX_ARGS;
+                       if (!(argv = realloc_array(argv, char *, maxargs)))
+                               out_of_memory("rsync_module");
+               }
                if (!(argv[argc] = strdup(p)))
-                       return -1;
+                       out_of_memory("rsync_module");
 
                if (start_glob) {
                        if (start_glob == 1) {
                                request = strdup(p);
                                start_glob++;
                        }
-                       glob_expand(name, argv, &argc, MAX_ARGS);
+                       glob_expand(name, &argv, &argc, &maxargs);
                } else
                        argc++;
 
                if (strcmp(line, ".") == 0)
                        start_glob = 1;
-
-               if (argc == MAX_ARGS)
-                       return -1;
        }
 
        argp = argv;
@@ -423,12 +429,12 @@ static int rsync_module(int f_in, int f_out, int i)
 
        if (request) {
                if (*auth_user) {
-                       rprintf(FINFO,"rsync %s %s from %s@%s (%s)\n",
-                               am_sender?"on":"to",
+                       rprintf(FLOG, "rsync %s %s from %s@%s (%s)\n",
+                               am_sender ? "on" : "to",
                                request, auth_user, host, addr);
                } else {
-                       rprintf(FINFO,"rsync %s %s from %s (%s)\n",
-                               am_sender?"on":"to",
+                       rprintf(FLOG, "rsync %s %s from %s (%s)\n",
+                               am_sender ? "on" : "to",
                                request, host, addr);
                }
                free(request);
@@ -581,7 +587,7 @@ int daemon_main(void)
 
        log_init();
 
-       rprintf(FINFO, "rsyncd version %s starting, listening on port %d\n",
+       rprintf(FLOG, "rsyncd version %s starting, listening on port %d\n",
                RSYNC_VERSION, rsync_port);
        /* TODO: If listening on a particular address, then show that
         * address too.  In fact, why not just do inet_ntop on the