version 1.26, 2021/05/06 07:29:59 |
version 1.27, 2021/05/17 11:59:09 |
|
|
#include <sys/stat.h> |
#include <sys/stat.h> |
|
|
#include <assert.h> |
#include <assert.h> |
|
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <inttypes.h> |
#include <inttypes.h> |
|
|
struct upload *ul = NULL; |
struct upload *ul = NULL; |
mode_t oumask; |
mode_t oumask; |
|
|
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("pledge"); |
err(ERR_IPC, "pledge"); |
goto out; |
|
} |
|
|
|
/* Client sends zero-length exclusions. */ |
/* Client sends zero-length exclusions. */ |
|
|
if (!sess->opts->server && |
if (!sess->opts->server && !io_write_int(sess, fdout, 0)) { |
!io_write_int(sess, fdout, 0)) { |
|
ERRX1("io_write_int"); |
ERRX1("io_write_int"); |
goto out; |
goto out; |
} |
} |
|
|
*/ |
*/ |
|
|
if (!sess->opts->dry_run) { |
if (!sess->opts->dry_run) { |
if ((tofree = strdup(root)) == NULL) { |
if ((tofree = strdup(root)) == NULL) |
ERR("strdup"); |
err(ERR_NOMEM, NULL); |
goto out; |
if (mkpath(tofree) < 0) |
} else if (mkpath(tofree) < 0) { |
err(ERR_FILE_IO, "%s: mkpath", tofree); |
ERRX1("%s: mkpath", root); |
|
free(tofree); |
|
goto out; |
|
} |
|
free(tofree); |
free(tofree); |
} |
} |
|
|
|
|
|
|
if (!sess->opts->dry_run) { |
if (!sess->opts->dry_run) { |
dfd = open(root, O_RDONLY | O_DIRECTORY, 0); |
dfd = open(root, O_RDONLY | O_DIRECTORY, 0); |
if (dfd == -1) { |
if (dfd == -1) |
ERR("%s: open", root); |
err(ERR_FILE_IO, "%s: open", root); |
goto out; |
|
} |
|
} |
} |
|
|
/* |
/* |
|
|
* writing into other parts of the file-system. |
* writing into other parts of the file-system. |
*/ |
*/ |
|
|
if (unveil(root, "rwc") == -1) { |
if (unveil(root, "rwc") == -1) |
ERR("%s: unveil", root); |
err(ERR_IPC, "%s: unveil", root); |
goto out; |
if (unveil(NULL, NULL) == -1) |
} else if (unveil(NULL, NULL) == -1) { |
err(ERR_IPC, "unveil"); |
ERR("%s: unveil", root); |
|
goto out; |
|
} |
|
|
|
/* If we have a local set, go for the deletion. */ |
/* If we have a local set, go for the deletion. */ |
|
|