Cleaned up whitespace/indentation.
authorWayne Davison <wayned@samba.org>
Sat, 10 May 2003 08:33:08 +0000 (08:33 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 10 May 2003 08:33:08 +0000 (08:33 +0000)
clientserver.c

index 8a26ed5..a56a792 100644 (file)
@@ -1,18 +1,18 @@
 /* -*- c-file-style: "linux"; -*-
- * 
+ *
  * Copyright (C) 1998-2001 by Andrew Tridgell <tridge@samba.org>
  * Copyright (C) 2001-2002 by Martin Pool <mbp@samba.org>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -55,10 +55,10 @@ int start_socket_client(char *host, char *path, int argc, char *argv[])
        char *p, *user=NULL;
        extern char *bind_address;
        extern int default_af_hint;
-       
+
        /* this is redundant with code in start_inband_exchange(), but
-          this short-circuits a problem before we open a socket, and 
-          the extra check won't hurt */
+        * this short-circuits a problem before we open a socket, and
+        * the extra check won't hurt */
        if (*path == '/') {
                rprintf(FERROR,"ERROR: The remote path must start with a module name not a /\n");
                return -1;
@@ -79,7 +79,7 @@ int start_socket_client(char *host, char *path, int argc, char *argv[])
                        host, rsync_port);
        }
        fd = open_socket_out_wrapped (host, rsync_port, bind_address,
-                                     default_af_hint);
+                                               default_af_hint);
        if (fd == -1) {
                exit_cleanup(RERR_SOCKETIO);
        }
@@ -113,15 +113,15 @@ int start_inband_exchange(char *user, char *path, int f_in, int f_out, int argc)
        if (!user) user = getenv("USER");
        if (!user) user = getenv("LOGNAME");
 
-       /* set daemon_over_rsh to false since we need to build the 
-          true set of args passed through the rsh/ssh connection; 
-          this is a no-op for direct-socket-connection mode */
+       /* set daemon_over_rsh to false since we need to build the
+        * true set of args passed through the rsh/ssh connection;
+        * this is a no-op for direct-socket-connection mode */
        daemon_over_rsh = 0;
        server_options(sargs, &sargc);
 
        sargs[sargc++] = ".";
 
-       if (path && *path) 
+       if (path && *path)
                sargs[sargc++] = path;
 
        sargs[sargc] = NULL;
@@ -245,14 +245,14 @@ static int rsync_module(int f_in, int f_out, int i)
                return -1;
        }
 
-       
+
        auth_user = auth_server(f_in, f_out, i, addr, "@RSYNCD: AUTHREQD ");
 
        if (!auth_user) {
                rprintf(FERROR,"auth failed on module %s from %s (%s)\n",
                        name, host, addr);
                io_printf(f_out, "@ERROR: auth failed on module %s\n", name);
-               return -1;              
+               return -1;
        }
 
        module_id = i;
@@ -266,7 +266,7 @@ static int rsync_module(int f_in, int f_out, int i)
                                rprintf(FERROR,"Invalid uid %s\n", p);
                                io_printf(f_out, "@ERROR: invalid uid %s\n", p);
                                return -1;
-                       } 
+                       }
                        uid = atoi(p);
                }
 
@@ -276,17 +276,17 @@ static int rsync_module(int f_in, int f_out, int i)
                                rprintf(FERROR,"Invalid gid %s\n", p);
                                io_printf(f_out, "@ERROR: invalid gid %s\n", p);
                                return -1;
-                       } 
+                       }
                        gid = atoi(p);
                }
        }
-        
-        /* TODO: If we're not root, but the configuration requests
-         * that we change to some uid other than the current one, then
-         * log a warning. */
 
-        /* TODO: Perhaps take a list of gids, and make them into the
-         * supplementary groups. */
+       /* TODO: If we're not root, but the configuration requests
+        * that we change to some uid other than the current one, then
+        * log a warning. */
+
+       /* TODO: Perhaps take a list of gids, and make them into the
+        * supplementary groups. */
 
        p = lp_include_from(i);
        add_exclude_file(p, 1, 1);
@@ -322,7 +322,7 @@ static int rsync_module(int f_in, int f_out, int i)
                }
 
                if (!push_dir("/", 0)) {
-                        rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
+                       rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
                        io_printf(f_out, "@ERROR: chdir failed\n");
                        return -1;
                }
@@ -422,7 +422,7 @@ static int rsync_module(int f_in, int f_out, int i)
                }
        }
 
-        argp = argv;
+       argp = argv;
        ret = parse_arguments(&argc, (const char ***) &argp, 0);
 
        if (filesfrom_fd == 0)
@@ -450,18 +450,18 @@ static int rsync_module(int f_in, int f_out, int i)
                if (remote_version == 22 || (remote_version > 17 && am_sender))
                        io_start_multiplex_out(f_out);
        }
-        
-        /* For later protocol versions, we don't start multiplexing
-         * until we've configured nonblocking in start_server.  That
-         * means we're in a sticky situation now: there's no way to
-         * convey errors to the client. */
 
-        /* FIXME: Hold off on reporting option processing errors until
-         * we've set up nonblocking and multiplexed IO and can get the
-         * message back to them. */
+       /* For later protocol versions, we don't start multiplexing
+        * until we've configured nonblocking in start_server.  That
+        * means we're in a sticky situation now: there's no way to
+        * convey errors to the client. */
+
+       /* FIXME: Hold off on reporting option processing errors until
+        * we've set up nonblocking and multiplexed IO and can get the
+        * message back to them. */
        if (!ret) {
-                option_error();
-                exit_cleanup(RERR_UNSUPPORTED);
+               option_error();
+               exit_cleanup(RERR_UNSUPPORTED);
        }
 
        if (lp_timeout(i)) {
@@ -484,7 +484,7 @@ static void send_listing(int fd)
 
        for (i=0;i<n;i++)
                if (lp_list(i))
-                   io_printf(fd, "%-15s\t%s\n", lp_name(i), lp_comment(i));
+                       io_printf(fd, "%-15s\t%s\n", lp_name(i), lp_comment(i));
 
        if (remote_version >= 25)
                io_printf(fd,"@RSYNCD: EXIT\n");
@@ -537,7 +537,7 @@ int start_daemon(int f_in, int f_out)
        if (sscanf(line,"@RSYNCD: %d", &remote_version) != 1) {
                io_printf(f_out, "@ERROR: protocol startup error\n");
                return -1;
-       }       
+       }
 
        while (i == -1) {
                line[0] = 0;
@@ -548,7 +548,7 @@ int start_daemon(int f_in, int f_out)
                if (!*line || strcmp(line,"#list")==0) {
                        send_listing(f_out);
                        return -1;
-               } 
+               }
 
                if (*line == '#') {
                        /* it's some sort of command that I don't understand */
@@ -578,10 +578,10 @@ int daemon_main(void)
                int i;
 
                /* we are running via inetd - close off stdout and
-                  stderr so that library functions (and getopt) don't
-                  try to use them. Redirect them to /dev/null */
+                * stderr so that library functions (and getopt) don't
+                * try to use them. Redirect them to /dev/null */
                for (i=1;i<3;i++) {
-                       close(i); 
+                       close(i);
                        open("/dev/null", O_RDWR);
                }
 
@@ -589,7 +589,7 @@ int daemon_main(void)
        }
 
        if (!no_detach)
-           become_daemon();
+               become_daemon();
 
        if (!lp_load(config_file, 1)) {
                exit_cleanup(RERR_SYNTAX);
@@ -598,11 +598,10 @@ int daemon_main(void)
        log_init();
 
        rprintf(FINFO, "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
-         * local address??? */
+               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
+        * local address??? */
 
        if (((pid_file = lp_pid_file()) != NULL) && (*pid_file != '\0')) {
                char pidbuf[16];
@@ -611,9 +610,9 @@ int daemon_main(void)
                cleanup_set_pid(pid);
                if ((fd = do_open(lp_pid_file(), O_WRONLY|O_CREAT|O_TRUNC,
                                        0666 & ~orig_umask)) == -1) {
-                   cleanup_set_pid(0);
-                   rsyserr(FLOG, errno, "failed to create pid file %s", pid_file);
-                   exit_cleanup(RERR_FILEIO);
+                       cleanup_set_pid(0);
+                       rsyserr(FLOG, errno, "failed to create pid file %s", pid_file);
+                       exit_cleanup(RERR_FILEIO);
                }
                snprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
                write(fd, pidbuf, strlen(pidbuf));