logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 46ef35c35f6398d59ae4ed58eb247c0016f5122a
parent 7aa790a03f458ab41a4dc7b0b0810921ee5086ab
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 12 Feb 2026 01:41:55 +0100

cmd/tee: pass file-mode to open() for O_CREAT

Bug introduced in 69cbb114a926327ac256e2007d4208ba734e1fad

Diffstat:

Mcmd/tee.c2+-
Mtest-cmd/tee.sh9++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmd/tee.c b/cmd/tee.c @@ -86,7 +86,7 @@ main(int argc, char *argv[]) assert(argv[argi]); // POSIX: implementations shouldn't treat '-' as stdin - fds[argi] = open(argv[argi], mode); + fds[argi] = open(argv[argi], mode, 0666); if(fds[argi] < 0) { diff --git a/test-cmd/tee.sh b/test-cmd/tee.sh @@ -1,8 +1,10 @@ #!/bin/sh # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> # SPDX-License-Identifier: MPL-2.0 + +plans=20 + WD=$(dirname "$0") -plans=17 target="${WD}/../cmd/tee" . "${WD}/tap.sh" @@ -21,6 +23,11 @@ t_file --infile="${WD}/inputs/all_bytes" appendfile "${WD}/inputs/all_bytes" -a t_cmd writefile:cmp '' cmp "${tmp_appendfile}" "${WD}/outputs/tee/hello_all_bytes" t_cmd appendfile:rm '' rm "${tmp_appendfile}" +tmp_createfile="${tmp_appendfile}.new" +t_file --infile="${WD}/inputs/all_bytes" createfile "${WD}/inputs/all_bytes" "${tmp_createfile}" +t_cmd createfile:cmp '' cmp "${tmp_createfile}" "${WD}/inputs/all_bytes" +t_cmd createfile:rm '' rm "${tmp_createfile}" + if [ "x${LOGNAME}" = 'xroot' ]; then skip noperm:chmod_0000 'ran as root, ignoring' skip noperm 'ran as root, ignoring'