version 1.23, 2019/02/16 17:59:33 |
version 1.24, 2019/02/17 15:59:09 |
|
|
{ |
{ |
struct opts opts; |
struct opts opts; |
pid_t child; |
pid_t child; |
int fds[2], c, st; |
int fds[2], rc = 0, c, st; |
struct fargs *fargs; |
struct fargs *fargs; |
struct option lopts[] = { |
struct option lopts[] = { |
{ "rsh", required_argument, NULL, 'e' }, |
{ "rsh", required_argument, NULL, 'e' }, |
|
|
if (opts.server) { |
if (opts.server) { |
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) |
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) |
err(EXIT_FAILURE, "pledge"); |
err(EXIT_FAILURE, "pledge"); |
c = rsync_server(&opts, (size_t)argc, argv); |
return rsync_server(&opts, (size_t)argc, argv); |
return c ? EXIT_SUCCESS : EXIT_FAILURE; |
|
} |
} |
|
|
/* |
/* |
|
|
if (pledge("stdio unix rpath wpath cpath dpath inet fattr chown dns getpw unveil", |
if (pledge("stdio unix rpath wpath cpath dpath inet fattr chown dns getpw unveil", |
NULL) == -1) |
NULL) == -1) |
err(EXIT_FAILURE, "pledge"); |
err(EXIT_FAILURE, "pledge"); |
c = rsync_socket(&opts, fargs); |
rc = rsync_socket(&opts, fargs); |
fargs_free(fargs); |
fargs_free(fargs); |
return c ? EXIT_SUCCESS : EXIT_FAILURE; |
return rc; |
} |
} |
|
|
/* Drop the dns/inet possibility. */ |
/* Drop the dns/inet possibility. */ |
|
|
fds[1] = -1; |
fds[1] = -1; |
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) |
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1) |
err(EXIT_FAILURE, "pledge"); |
err(EXIT_FAILURE, "pledge"); |
c = rsync_client(&opts, fds[0], fargs); |
rc = rsync_client(&opts, fds[0], fargs); |
fargs_free(fargs); |
fargs_free(fargs); |
|
|
/* |
/* |
|
|
* So close the connection here so that they don't hang. |
* So close the connection here so that they don't hang. |
*/ |
*/ |
|
|
if (!c) { |
if (!rc) { |
close(fds[0]); |
close(fds[0]); |
fds[0] = -1; |
fds[0] = -1; |
} |
} |
|
|
if (waitpid(child, &st, 0) == -1) |
if (waitpid(child, &st, 0) == -1) |
err(EXIT_FAILURE, "waitpid"); |
err(EXIT_FAILURE, "waitpid"); |
if (!(WIFEXITED(st) && WEXITSTATUS(st) == EXIT_SUCCESS)) |
if (!(WIFEXITED(st) && WEXITSTATUS(st) == EXIT_SUCCESS)) |
c = 0; |
rc = 0; |
|
|
if (fds[0] != -1) |
if (fds[0] != -1) |
close(fds[0]); |
close(fds[0]); |
return c ? EXIT_SUCCESS : EXIT_FAILURE; |
return rc; |
usage: |
usage: |
fprintf(stderr, "usage: %s [-Daglnoprtv] " |
fprintf(stderr, "usage: %s [-Daglnoprtv] " |
"[-e ssh-prog] [--delete] [--rsync-path=prog] src ... dst\n", |
"[-e ssh-prog] [--delete] [--rsync-path=prog] src ... dst\n", |