=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rsync/main.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- src/usr.bin/rsync/main.c 2019/02/17 15:59:09 1.24 +++ src/usr.bin/rsync/main.c 2019/02/17 17:19:05 1.25 @@ -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 * @@ -98,18 +98,18 @@ /* 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 @@ 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 @@ 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 @@ } } 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 @@ 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_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 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ fprintf(stderr, "usage: %s [-Daglnoprtv] " "[-e ssh-prog] [--delete] [--rsync-path=prog] src ... dst\n", getprogname()); - return EXIT_FAILURE; + return 1; }