#2966 Issue closed
: STDOUT_STDERR_FILE used but never defined - /rear.help.stdout_stderr file shouldn't be there¶
Labels: no-issue-activity
schlomo opened issue at 2023-04-04 13:46:¶
I tried running fakeroot reat
because I just wanted to check the help
output and was surprised by the many error messages:
$ fakeroot usr/sbin/rear
usr/sbin/rear: line 554: /rear.help.stdout_stderr: Permission denied
chmod: cannot access '/rear.help.stdout_stderr': No such file or directory
usr/sbin/rear: line 559: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
OS_VENDOR=Ubuntu
OS_VERSION=22.04
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
/home/schlomo/src/rear/usr/share/rear/lib/framework-functions.sh: line 45: /rear.help.stdout_stderr: Permission denied
Usage: rear [-h|--help] [-V|--version] [-dsSv] [-D|--debugscripts SET] [-c DIR] [-C CONFIG] [-r KERNEL] [--] COMMAND [ARGS...]
Relax-and-Recover comes with ABSOLUTELY NO WARRANTY; for details see
the GNU General Public License at: http://www.gnu.org/licenses/gpl.html
Available options:
-h --help usage information (this text)
It turns out that we use STDOUT_STDERR_FILE
but it seems like we never
set this variable
https://github.com/rear/rear/blob/ae9c64597d3b73112e8845e96ad1cb2ca40fac25/usr/share/rear/lib/framework-functions.sh#L45
Also, on my test system I find this file in /
[root@rear-ol8u7 ~]# ll /
total 32
lrwxrwxrwx. 1 root root 7 9. Okt 2021 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 5. Mär 03:26 boot
drwxr-xr-x. 19 root root 3320 3. Apr 14:17 dev
drwxr-xr-x. 150 root root 8192 3. Apr 20:49 etc
drwxr-xr-x. 3 root root 21 20. Feb 19:54 home
lrwxrwxrwx. 1 root root 7 9. Okt 2021 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 9. Okt 2021 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 9. Okt 2021 media
drwxr-xr-x. 2 root root 6 9. Okt 2021 mnt
drwxr-xr-x. 4 root root 49 20. Feb 20:18 opt
dr-xr-xr-x. 207 root root 0 3. Apr 14:17 proc
-rw-------. 1 root root 624 2. Apr 15:39 rear.help.stdout_stderr
drwxr-xr-x. 3 root root 17 5. Mär 21:38 rear-local
dr-xr-x---. 7 root root 4096 4. Apr 15:43 root
drwxr-xr-x. 39 root root 1220 3. Apr 14:19 run
lrwxrwxrwx. 1 root root 8 9. Okt 2021 sbin -> usr/sbin
drwxr-xr-x. 3 root root 18 3. Apr 20:56 src
drwxr-xr-x. 2 root root 6 9. Okt 2021 srv
dr-xr-xr-x. 13 root root 0 3. Apr 14:17 sys
drwxrwxrwt. 11 root root 4096 4. Apr 15:43 tmp
drwxr-xr-x. 13 root root 158 20. Feb 19:29 usr
drwxr-xr-x. 21 root root 4096 20. Feb 19:48 var
@jsmeix it seems like you worked on this in #2633, can you please have another look? Maybe some change broke that without anybody noticing it.
jsmeix commented at 2023-04-05 07:13:¶
With current GitHub master code I get
# find usr/sbin/rear usr/share/rear -type f | xargs grep 'STDOUT_STDERR_FILE='
usr/sbin/rear:
STDOUT_STDERR_FILE="/dev/null"
STDOUT_STDERR_FILE="$TMP_DIR/$PROGRAM.$WORKFLOW.stdout_stderr"
usr/share/rear/lib/_input-output-functions.sh:
# In non-debug modes stdout and stderr are redirected to STDOUT_STDERR_FILE="$TMP_DIR/rear.$WORKFLOW.stdout_stderr" if possible
# but in certain cases (e.g. for the 'help' workflow where no $TMP_DIR exists) STDOUT_STDERR_FILE=/dev/null
@schlomo
it seems in your special case $TMP_DIR is not set?
schlomo commented at 2023-04-05 16:55:¶
You are right and I failed to use my IDE... nevertheless we need to
solve the problem of creating this file in /
.
Yes, if TMP_DIR
is not set then the following line silently gives a
false positive:
https://github.com/rear/rear/blob/0093828651efe64407d51d4801aaba6fe4dee835/usr/sbin/rear#L549
because of this behaviour:
[root@rear-ol8u7 ~]# test -d $sfdkjashdkfjahfdjk && echo yes
yes
[root@rear-ol8u7 ~]#
And this is a case where quoting the variable (or checking it) would have helped:
[root@rear-ol8u7 ~]# test -d "$sfdkjashdkfjahfdjk" && echo yes
[root@rear-ol8u7 ~]#
The problem is actually specific to the help
workflow because of
this:
https://github.com/rear/rear/blob/0093828651efe64407d51d4801aaba6fe4dee835/usr/sbin/rear#L498-L513
I guess that we should do this basic setup also for the help
workflow
as the other ReaR code heavily relies on it.
jsmeix commented at 2023-04-06 10:56:¶
Via
https://github.com/rear/rear/commit/99110661fc75e243ccac308f0b12b11142999834
I fixed the test -d $TMP_DIR
issue.
By the way:
The root cause of my buggy code was
that 'test' behaves inconsistent
# test && echo y || echo n
n
# test '' && echo y || echo n
n
# test -d && echo y || echo n
y
# test -d '' && echo y || echo n
n
# test -e && echo y || echo n
y
# test -e '' && echo y || echo n
n
depending on whether or not an operator is used and
it behaves "very inconsistent" when the '-a' and '-o'
operators are used as file operator versus as
so called (according to 'help test') "other operator":
# test -a '' -a -a '' && echo y || echo n
n
# test -a -a -a && echo y || echo n
y
# test -o '' -o -o '' && echo y || echo n
n
# test -o -o -o && echo y || echo n
y
jsmeix commented at 2023-04-06 11:08:¶
Regarding test "$WORKFLOW" != "help"
:
We have that four times in sbin/rear
in current GitHub master code at
# cat -n usr/sbin/rear | grep 'test.*WORKFLOW.*help'
498 if test "$WORKFLOW" != "help" ; then
575 if test "$WORKFLOW" != "help" ; then
723 test "$WORKFLOW" != "help" && LogPrint "Saving $RUNTIME_LOGFILE as $LOGFILE"
735 if test "$WORKFLOW" != "help" ; then
In the past I already had "a lot of (not so) fun"
with the special behaviour of the 'help' workflow.
The special behaviour of the 'help' workflow was
already there when I encountered ReaR for the first time.
In general I would appreciate it if we could make
the 'help' workflow behave more like the other workflows.
schlomo commented at 2023-04-08 19:09:¶
Yes, totally agree with you. What would happen if we simply remove the special treatment? Maybe it's not so bad?
schlomo commented at 2023-04-23 09:23:¶
@rear/contributors any thoughts on completely removing the special
handling for the help
workflow to simplify things?
github-actions commented at 2023-06-23 02:48:¶
Stale issue message
github-actions commented at 2023-08-24 02:00:¶
Stale issue message
[Export of Github issue for rear/rear.]