diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2021-10-24 21:24:23 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2021-10-24 21:24:23 +0000 |
commit | acc343614063e6fcbfd2871022b325f7f58f01cf (patch) | |
tree | 116317e06df569f5951d37b46db5c27b2326b826 /usr.bin/rsync | |
parent | 45b1bea4b11d2420bea5874f47944b05075dd1b0 (diff) |
For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef.
ok millert
Diffstat (limited to 'usr.bin/rsync')
-rw-r--r-- | usr.bin/rsync/copy.c | 6 | ||||
-rw-r--r-- | usr.bin/rsync/downloader.c | 4 | ||||
-rw-r--r-- | usr.bin/rsync/receiver.c | 4 | ||||
-rw-r--r-- | usr.bin/rsync/uploader.c | 6 |
4 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/rsync/copy.c b/usr.bin/rsync/copy.c index 737234d2269..f133508cda0 100644 --- a/usr.bin/rsync/copy.c +++ b/usr.bin/rsync/copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: copy.c,v 1.1 2021/10/22 11:10:34 claudio Exp $ */ +/* $OpenBSD: copy.c,v 1.2 2021/10/24 21:24:17 deraadt Exp $ */ /* * Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org> * @@ -67,11 +67,11 @@ copy_file(int rootfd, const char *basedir, const struct flist *f) { int fromfd, tofd, dfd; - dfd = openat(rootfd, basedir, O_RDONLY | O_DIRECTORY, 0); + dfd = openat(rootfd, basedir, O_RDONLY | O_DIRECTORY); if (dfd == -1) err(ERR_FILE_IO, "%s: openat", basedir); - fromfd = openat(dfd, f->path, O_RDONLY | O_NOFOLLOW, 0); + fromfd = openat(dfd, f->path, O_RDONLY | O_NOFOLLOW); if (fromfd == -1) err(ERR_FILE_IO, "%s/%s: openat", basedir, f->path); close(dfd); diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c index cb84c2bfcd9..cab6eb23f9f 100644 --- a/usr.bin/rsync/downloader.c +++ b/usr.bin/rsync/downloader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: downloader.c,v 1.22 2021/06/30 13:10:04 claudio Exp $ */ +/* $OpenBSD: downloader.c,v 1.23 2021/10/24 21:24:17 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -350,7 +350,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd) p->state = DOWNLOAD_READ_LOCAL; f = &p->fl[idx]; - p->ofd = openat(p->rootfd, f->path, O_RDONLY | O_NONBLOCK, 0); + p->ofd = openat(p->rootfd, f->path, O_RDONLY | O_NONBLOCK); if (p->ofd == -1 && errno != ENOENT) { ERR("%s: openat", f->path); diff --git a/usr.bin/rsync/receiver.c b/usr.bin/rsync/receiver.c index 02e1a58d7c4..90f54189415 100644 --- a/usr.bin/rsync/receiver.c +++ b/usr.bin/rsync/receiver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: receiver.c,v 1.30 2021/10/22 11:10:34 claudio Exp $ */ +/* $OpenBSD: receiver.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> @@ -267,7 +267,7 @@ rsync_receiver(struct sess *sess, int fdin, int fdout, const char *root) oumask = umask(0); if (!sess->opts->dry_run) { - dfd = open(root, O_RDONLY | O_DIRECTORY, 0); + dfd = open(root, O_RDONLY | O_DIRECTORY); if (dfd == -1) err(ERR_FILE_IO, "%s: open", root); } diff --git a/usr.bin/rsync/uploader.c b/usr.bin/rsync/uploader.c index 254e1be0791..32cf4ec0ff6 100644 --- a/usr.bin/rsync/uploader.c +++ b/usr.bin/rsync/uploader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uploader.c,v 1.30 2021/10/22 11:10:34 claudio Exp $ */ +/* $OpenBSD: uploader.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2019 Florian Obser <florian@openbsd.org> @@ -736,7 +736,7 @@ pre_file(const struct upload *p, int *filefd, off_t *size, const char *root = sess->opts->basedir[i]; int dfd, x; - dfd = openat(p->rootfd, root, O_RDONLY | O_DIRECTORY, 0); + dfd = openat(p->rootfd, root, O_RDONLY | O_DIRECTORY); if (dfd == -1) err(ERR_FILE_IO, "%s: openat", root); x = check_file(dfd, f, &st); @@ -771,7 +771,7 @@ pre_file(const struct upload *p, int *filefd, off_t *size, } *size = st.st_size; - *filefd = openat(p->rootfd, f->path, O_RDONLY | O_NOFOLLOW, 0); + *filefd = openat(p->rootfd, f->path, O_RDONLY | O_NOFOLLOW); if (*filefd == -1 && errno != ENOENT) { ERR("%s: openat", f->path); return -1; |