=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rsync/main.c,v retrieving revision 1.23 retrieving revision 1.24 diff -c -r1.23 -r1.24 *** src/usr.bin/rsync/main.c 2019/02/16 17:59:33 1.23 --- src/usr.bin/rsync/main.c 2019/02/17 15:59:09 1.24 *************** *** 1,4 **** ! /* $Id: main.c,v 1.23 2019/02/16 17:59:33 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: main.c,v 1.24 2019/02/17 15:59:09 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * *************** *** 284,290 **** { struct opts opts; pid_t child; ! int fds[2], c, st; struct fargs *fargs; struct option lopts[] = { { "rsh", required_argument, NULL, 'e' }, --- 284,290 ---- { struct opts opts; pid_t child; ! int fds[2], rc = 0, c, st; struct fargs *fargs; struct option lopts[] = { { "rsh", required_argument, NULL, 'e' }, *************** *** 402,409 **** if (opts.server) { if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) err(EXIT_FAILURE, "pledge"); ! c = rsync_server(&opts, (size_t)argc, argv); ! return c ? EXIT_SUCCESS : EXIT_FAILURE; } /* --- 402,408 ---- if (opts.server) { if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) err(EXIT_FAILURE, "pledge"); ! return rsync_server(&opts, (size_t)argc, argv); } /* *************** *** 430,438 **** if (pledge("stdio unix rpath wpath cpath dpath inet fattr chown dns getpw unveil", NULL) == -1) err(EXIT_FAILURE, "pledge"); ! c = rsync_socket(&opts, fargs); fargs_free(fargs); ! return c ? EXIT_SUCCESS : EXIT_FAILURE; } /* Drop the dns/inet possibility. */ --- 429,437 ---- if (pledge("stdio unix rpath wpath cpath dpath inet fattr chown dns getpw unveil", NULL) == -1) err(EXIT_FAILURE, "pledge"); ! rc = rsync_socket(&opts, fargs); fargs_free(fargs); ! return rc; } /* Drop the dns/inet possibility. */ *************** *** 470,476 **** fds[1] = -1; if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) err(EXIT_FAILURE, "pledge"); ! c = rsync_client(&opts, fds[0], fargs); fargs_free(fargs); /* --- 469,475 ---- fds[1] = -1; if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) err(EXIT_FAILURE, "pledge"); ! rc = rsync_client(&opts, fds[0], fargs); fargs_free(fargs); /* *************** *** 479,485 **** * So close the connection here so that they don't hang. */ ! if (!c) { close(fds[0]); fds[0] = -1; } --- 478,484 ---- * So close the connection here so that they don't hang. */ ! if (!rc) { close(fds[0]); fds[0] = -1; } *************** *** 487,497 **** if (waitpid(child, &st, 0) == -1) err(EXIT_FAILURE, "waitpid"); if (!(WIFEXITED(st) && WEXITSTATUS(st) == EXIT_SUCCESS)) ! c = 0; if (fds[0] != -1) close(fds[0]); ! return c ? EXIT_SUCCESS : EXIT_FAILURE; usage: fprintf(stderr, "usage: %s [-Daglnoprtv] " "[-e ssh-prog] [--delete] [--rsync-path=prog] src ... dst\n", --- 486,496 ---- if (waitpid(child, &st, 0) == -1) err(EXIT_FAILURE, "waitpid"); if (!(WIFEXITED(st) && WEXITSTATUS(st) == EXIT_SUCCESS)) ! rc = 0; if (fds[0] != -1) close(fds[0]); ! return rc; usage: fprintf(stderr, "usage: %s [-Daglnoprtv] " "[-e ssh-prog] [--delete] [--rsync-path=prog] src ... dst\n",