summaryrefslogtreecommitdiff
path: root/usr.bin/rsync
diff options
context:
space:
mode:
authorSebastian Benoit <benno@cvs.openbsd.org>2019-02-21 22:07:46 +0000
committerSebastian Benoit <benno@cvs.openbsd.org>2019-02-21 22:07:46 +0000
commit762ea3dec65248f335e94fdb69c317c854684a1f (patch)
treea017e800be54f15e3551964681206ceed4d7290f /usr.bin/rsync
parent3798de5e8e462bc9d4e1463cfb04b6ac0b94ac9c (diff)
kristaps acb8f263717f27691f0318d4b7154f854b7206b3
As found by benno@, if --numeric-ids is passed in, rsync does not send or receive the uid/gid lists at all. This also means that we need not process the lists, as we're simply going to copy around the same value.
Diffstat (limited to 'usr.bin/rsync')
-rw-r--r--usr.bin/rsync/flist.c14
-rw-r--r--usr.bin/rsync/ids.c15
2 files changed, 13 insertions, 16 deletions
diff --git a/usr.bin/rsync/flist.c b/usr.bin/rsync/flist.c
index 69abbf41cfd..6ccf871df49 100644
--- a/usr.bin/rsync/flist.c
+++ b/usr.bin/rsync/flist.c
@@ -1,4 +1,4 @@
-/* $Id: flist.c,v 1.17 2019/02/16 16:25:45 florian Exp $ */
+/* $Id: flist.c,v 1.18 2019/02/21 22:07:44 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2019 Florian Obser <florian@openbsd.org>
@@ -387,7 +387,7 @@ flist_send(struct sess *sess, int fdin, int fdout, const struct flist *fl,
/* Conditionally write identifier lists. */
- if (sess->opts->preserve_uids) {
+ if (sess->opts->preserve_uids && !sess->opts->numeric_ids) {
LOG2(sess, "sending uid list: %zu", uidsz);
if (!idents_send(sess, fdout, uids, uidsz)) {
ERRX1(sess, "idents_send");
@@ -395,7 +395,7 @@ flist_send(struct sess *sess, int fdin, int fdout, const struct flist *fl,
}
}
- if (sess->opts->preserve_gids) {
+ if (sess->opts->preserve_gids && !sess->opts->numeric_ids) {
LOG2(sess, "sending gid list: %zu", gidsz);
if (!idents_send(sess, fdout, gids, gidsz)) {
ERRX1(sess, "idents_send");
@@ -739,7 +739,7 @@ flist_recv(struct sess *sess, int fd, struct flist **flp, size_t *sz)
/* Conditionally read the user/group list. */
- if (sess->opts->preserve_uids) {
+ if (sess->opts->preserve_uids && !sess->opts->numeric_ids) {
if (!idents_recv(sess, fd, &uids, &uidsz)) {
ERRX1(sess, "idents_recv");
goto out;
@@ -747,7 +747,7 @@ flist_recv(struct sess *sess, int fd, struct flist **flp, size_t *sz)
LOG2(sess, "received uid list: %zu", uidsz);
}
- if (sess->opts->preserve_gids) {
+ if (sess->opts->preserve_gids && !sess->opts->numeric_ids) {
if (!idents_recv(sess, fd, &gids, &gidsz)) {
ERRX1(sess, "idents_recv");
goto out;
@@ -765,12 +765,12 @@ flist_recv(struct sess *sess, int fd, struct flist **flp, size_t *sz)
/* Conditionally remap and reassign identifiers. */
- if (sess->opts->preserve_uids) {
+ if (sess->opts->preserve_uids && !sess->opts->numeric_ids) {
idents_remap(sess, 0, uids, uidsz);
idents_assign_uid(sess, fl, flsz, uids, uidsz);
}
- if (sess->opts->preserve_gids) {
+ if (sess->opts->preserve_gids && !sess->opts->numeric_ids) {
idents_remap(sess, 1, gids, gidsz);
idents_assign_gid(sess, fl, flsz, gids, gidsz);
}
diff --git a/usr.bin/rsync/ids.c b/usr.bin/rsync/ids.c
index 1494effdc70..b1a1a07b5c4 100644
--- a/usr.bin/rsync/ids.c
+++ b/usr.bin/rsync/ids.c
@@ -1,4 +1,4 @@
-/* $Id: ids.c,v 1.6 2019/02/21 22:06:26 benno Exp $ */
+/* $Id: ids.c,v 1.7 2019/02/21 22:07:45 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -52,6 +52,8 @@ idents_assign_gid(struct sess *sess, struct flist *fl, size_t flsz,
{
size_t i, j;
+ assert(!sess->opts->numeric_ids);
+
for (i = 0; i < flsz; i++) {
if (fl[i].st.gid == 0)
continue;
@@ -72,6 +74,8 @@ idents_assign_uid(struct sess *sess, struct flist *fl, size_t flsz,
{
size_t i, j;
+ assert(!sess->opts->numeric_ids);
+
for (i = 0; i < flsz; i++) {
if (fl[i].st.uid == 0)
continue;
@@ -99,14 +103,7 @@ idents_remap(struct sess *sess, int isgid, struct ident *ids, size_t idsz)
struct passwd *usr;
int32_t id;
- if (sess->opts->numeric_ids) {
- for (i = 0; i < idsz; i++) {
- assert(ids[i].id != 0);
- ids[i].mapped = ids[i].id;
- }
- LOG4(sess, "did not remap identifiers");
- return;
- }
+ assert(!sess->opts->numeric_ids);
for (i = 0; i < idsz; i++) {
assert(ids[i].id != 0);