summaryrefslogtreecommitdiff
path: root/usr.bin/rsync
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-02-17 17:19:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-02-17 17:19:06 +0000
commit330f7183b064904c9a53f06db7c77b82b3d67dc5 (patch)
tree969da65a1bd7a0fa6704f4192fdf4bc0e9ebf6fa /usr.bin/rsync
parent3c98bd5641a03bf8e776ed6beac90f864d2ff787 (diff)
rsync has a large number of failure exit codes, so don't get used to this
weak sauce EXIT_SUCCESS / EXIT_FAILURE model (in our tree very few programs use this failed concept, almost as bad as sysexits.h)
Diffstat (limited to 'usr.bin/rsync')
-rw-r--r--usr.bin/rsync/child.c10
-rw-r--r--usr.bin/rsync/main.c62
2 files changed, 36 insertions, 36 deletions
diff --git a/usr.bin/rsync/child.c b/usr.bin/rsync/child.c
index 04a7b14ecbd..3045d3926ee 100644
--- a/usr.bin/rsync/child.c
+++ b/usr.bin/rsync/child.c
@@ -1,4 +1,4 @@
-/* $Id: child.c,v 1.4 2019/02/17 16:34:04 deraadt Exp $ */
+/* $Id: child.c,v 1.5 2019/02/17 17:19:05 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -46,7 +46,7 @@ rsync_child(const struct opts *opts, int fd, const struct fargs *f)
if ((args = fargs_cmdline(&sess, f)) == NULL) {
ERRX1(&sess, "fargs_cmdline");
- exit(EXIT_FAILURE);
+ exit(1);
}
for (i = 0; args[i] != NULL; i++)
@@ -56,10 +56,10 @@ rsync_child(const struct opts *opts, int fd, const struct fargs *f)
if (dup2(fd, STDIN_FILENO) == -1) {
ERR(&sess, "dup2");
- exit(EXIT_FAILURE);
+ exit(1);
} if (dup2(fd, STDOUT_FILENO) == -1) {
ERR(&sess, "dup2");
- exit(EXIT_FAILURE);
+ exit(1);
}
/* Here we go... */
@@ -67,6 +67,6 @@ rsync_child(const struct opts *opts, int fd, const struct fargs *f)
execvp(args[0], args);
ERR(&sess, "%s: execvp", args[0]);
- exit(EXIT_FAILURE);
+ exit(1);
/* NOTREACHED */
}
diff --git a/usr.bin/rsync/main.c b/usr.bin/rsync/main.c
index e6f0e610333..061e0e94634 100644
--- a/usr.bin/rsync/main.c
+++ b/usr.bin/rsync/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.24 2019/02/17 15:59:09 deraadt Exp $ */
+/* $Id: main.c,v 1.25 2019/02/17 17:19:05 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -98,18 +98,18 @@ fargs_parse(size_t argc, char *argv[])
/* Allocations. */
if ((f = calloc(1, sizeof(struct fargs))) == NULL)
- err(EXIT_FAILURE, "calloc");
+ err(1, "calloc");
f->sourcesz = argc - 1;
if ((f->sources = calloc(f->sourcesz, sizeof(char *))) == NULL)
- err(EXIT_FAILURE, "calloc");
+ err(1, "calloc");
for (i = 0; i < argc - 1; i++)
if ((f->sources[i] = strdup(argv[i])) == NULL)
- err(EXIT_FAILURE, "strdup");
+ err(1, "strdup");
if ((f->sink = strdup(argv[i])) == NULL)
- err(EXIT_FAILURE, "strdup");
+ err(1, "strdup");
/*
* Test files for its locality.
@@ -124,16 +124,16 @@ fargs_parse(size_t argc, char *argv[])
if (fargs_is_remote(f->sink)) {
f->mode = FARGS_SENDER;
if ((f->host = strdup(f->sink)) == NULL)
- err(EXIT_FAILURE, "strdup");
+ err(1, "strdup");
}
if (fargs_is_remote(f->sources[0])) {
if (f->host != NULL)
- errx(EXIT_FAILURE, "both source and "
+ errx(1, "both source and "
"destination cannot be remote files");
f->mode = FARGS_RECEIVER;
if ((f->host = strdup(f->sources[0])) == NULL)
- err(EXIT_FAILURE, "strdup");
+ err(1, "strdup");
}
if (f->host != NULL) {
@@ -143,7 +143,7 @@ fargs_parse(size_t argc, char *argv[])
len = strlen(f->host) - 8 + 1;
memmove(f->host, f->host + 8, len);
if ((cp = strchr(f->host, '/')) == NULL)
- errx(EXIT_FAILURE, "rsync protocol "
+ errx(1, "rsync protocol "
"requires a module name");
*cp++ = '\0';
f->module = cp;
@@ -164,9 +164,9 @@ fargs_parse(size_t argc, char *argv[])
}
}
if ((len = strlen(f->host)) == 0)
- errx(EXIT_FAILURE, "empty remote host");
+ errx(1, "empty remote host");
if (f->remote && strlen(f->module) == 0)
- errx(EXIT_FAILURE, "empty remote module");
+ errx(1, "empty remote module");
}
/* Make sure we have the same "hostspec" for all files. */
@@ -176,7 +176,7 @@ fargs_parse(size_t argc, char *argv[])
for (i = 0; i < f->sourcesz; i++) {
if (!fargs_is_remote(f->sources[i]))
continue;
- errx(EXIT_FAILURE, "remote file in "
+ errx(1, "remote file in "
"list of local sources: %s",
f->sources[i]);
}
@@ -186,22 +186,22 @@ fargs_parse(size_t argc, char *argv[])
!fargs_is_daemon(f->sources[i]))
continue;
if (fargs_is_daemon(f->sources[i]))
- errx(EXIT_FAILURE, "remote "
+ errx(1, "remote "
"daemon in list of "
"remote sources: %s",
f->sources[i]);
- errx(EXIT_FAILURE, "local file in "
+ errx(1, "local file in "
"list of remote sources: %s",
f->sources[i]);
}
} else {
if (f->mode != FARGS_RECEIVER)
- errx(EXIT_FAILURE, "sender mode for remote "
+ errx(1, "sender mode for remote "
"daemon receivers not yet supported");
for (i = 0; i < f->sourcesz; i++) {
if (fargs_is_daemon(f->sources[i]))
continue;
- errx(EXIT_FAILURE, "non-remote daemon file "
+ errx(1, "non-remote daemon file "
"in list of remote daemon sources: "
"%s", f->sources[i]);
}
@@ -245,7 +245,7 @@ fargs_parse(size_t argc, char *argv[])
cp += 8;
if (strncmp(cp, f->host, len) ||
(cp[len] != '/' && cp[len] != '\0'))
- errx(EXIT_FAILURE, "different remote "
+ errx(1, "different remote "
"host: %s", f->sources[i]);
memmove(f->sources[i],
f->sources[i] + len + 8 + 1,
@@ -258,7 +258,7 @@ fargs_parse(size_t argc, char *argv[])
/* host::path */
if (strncmp(cp, f->host, len) ||
(cp[len] != ':' && cp[len] != '\0'))
- errx(EXIT_FAILURE, "different remote "
+ errx(1, "different remote "
"host: %s", f->sources[i]);
memmove(f->sources[i], f->sources[i] + len + 2,
j - len - 1);
@@ -269,7 +269,7 @@ fargs_parse(size_t argc, char *argv[])
/* host:path */
if (strncmp(cp, f->host, len) ||
(cp[len] != ':' && cp[len] != '\0'))
- errx(EXIT_FAILURE, "different remote "
+ errx(1, "different remote "
"host: %s", f->sources[i]);
memmove(f->sources[i],
f->sources[i] + len + 1, j - len);
@@ -321,7 +321,7 @@ main(int argc, char *argv[])
if (pledge("stdio unix rpath wpath cpath dpath inet fattr chown dns getpw proc exec unveil",
NULL) == -1)
- err(EXIT_FAILURE, "pledge");
+ err(1, "pledge");
memset(&opts, 0, sizeof(struct opts));
@@ -401,7 +401,7 @@ main(int argc, char *argv[])
if (opts.server) {
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1)
- err(EXIT_FAILURE, "pledge");
+ err(1, "pledge");
return rsync_server(&opts, (size_t)argc, argv);
}
@@ -428,7 +428,7 @@ main(int argc, char *argv[])
assert(fargs->mode == FARGS_RECEIVER);
if (pledge("stdio unix rpath wpath cpath dpath inet fattr chown dns getpw unveil",
NULL) == -1)
- err(EXIT_FAILURE, "pledge");
+ err(1, "pledge");
rc = rsync_socket(&opts, fargs);
fargs_free(fargs);
return rc;
@@ -438,29 +438,29 @@ main(int argc, char *argv[])
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw proc exec unveil",
NULL) == -1)
- err(EXIT_FAILURE, "pledge");
+ err(1, "pledge");
/* Create a bidirectional socket and start our child. */
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds) == -1)
- err(EXIT_FAILURE, "socketpair");
+ err(1, "socketpair");
if ((child = fork()) == -1) {
close(fds[0]);
close(fds[1]);
- err(EXIT_FAILURE, "fork");
+ err(1, "fork");
}
/* Drop the fork possibility. */
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw exec unveil", NULL) == -1)
- err(EXIT_FAILURE, "pledge");
+ err(1, "pledge");
if (child == 0) {
close(fds[0]);
fds[0] = -1;
if (pledge("stdio exec", NULL) == -1)
- err(EXIT_FAILURE, "pledge");
+ err(1, "pledge");
rsync_child(&opts, fds[1], fargs);
/* NOTREACHED */
}
@@ -468,7 +468,7 @@ main(int argc, char *argv[])
close(fds[1]);
fds[1] = -1;
if (pledge("stdio unix rpath wpath cpath dpath fattr chown getpw unveil", NULL) == -1)
- err(EXIT_FAILURE, "pledge");
+ err(1, "pledge");
rc = rsync_client(&opts, fds[0], fargs);
fargs_free(fargs);
@@ -484,8 +484,8 @@ main(int argc, char *argv[])
}
if (waitpid(child, &st, 0) == -1)
- err(EXIT_FAILURE, "waitpid");
- if (!(WIFEXITED(st) && WEXITSTATUS(st) == EXIT_SUCCESS))
+ err(1, "waitpid");
+ if (!(WIFEXITED(st) && WEXITSTATUS(st) == 0))
rc = 0;
if (fds[0] != -1)
@@ -495,5 +495,5 @@ usage:
fprintf(stderr, "usage: %s [-Daglnoprtv] "
"[-e ssh-prog] [--delete] [--rsync-path=prog] src ... dst\n",
getprogname());
- return EXIT_FAILURE;
+ return 1;
}