unit: Tools: unitc: empty $ERROR_LOG

$ sudo ./tools/unitc GET /config >/dev/null
./tools/unitc: line 183: $ERROR_LOG: ambiguous redirect

The following diff disables the error message, but it redirects from a file with an empty file name, so it is probably wrong to do that. I just did it for checking that the error is caused exactly at that line. Please revise the logic.

$ git diff HEAD^
diff --git a/tools/unitc b/tools/unitc
index c53c4429..fc16ebcd 100755
--- a/tools/unitc
+++ b/tools/unitc
@@ -180,7 +180,7 @@ fi
 # Get current length of error log before we make any changes
 #
 if [ -f $ERROR_LOG ] && [ -r $ERROR_LOG ]; then
-       LOG_LEN=$(wc -l < $ERROR_LOG)
+       LOG_LEN=$(wc -l < "$ERROR_LOG")
 else
        NOLOG=1
 fi

This is one of the issues that appear in the https://github.com/nginx/unit/issues/875 issue.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (16 by maintainers)

Commits related to this issue

Most upvoted comments

@mattxtaz I suspect this might be one of the problems you’re experiencing. Could you try removing any /tmp/unitc.* files and running again as root? And then reproducing it again by removing again the tmp files and running as non-root? @ac000 what do you think?

You mean like this? This doesn’t look like it makes any difference as I’m running it directly as root here. I’ve edited the prompts because otherwise github treats it as markup text and screws up the formatting.

root% ls -al /tmp/unitc* -rw-r–r-- 1 root wheel 31 17 May 19:24 /tmp/unitc.10878.env root% rm /tmp/unitc.10878.env root% unitc /status unknown option “(unitd)”, try “/usr/local/sbin/unitd -h” for available options unknown option “(unitd)”, try “/usr/local/sbin/unitd -h” for available options /usr/local/bin/unitc: line 183: $ERROR_LOG: ambiguous redirect unitc: ERROR: curl(1) exited with an error (6) unitc: Trying to access http:///status % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0curl: (6) Could not resolve host: status

And then if I remove the files and run it as non-root, same thing again:

root% ls -al /tmp/unitc* -rw-r–r-- 1 root wheel 31 17 May 19:25 /tmp/unitc.10878.env root% rm /tmp/unitc.10878.env user% unitc /status unknown option “(unitd)”, try “/usr/local/sbin/unitd -h” for available options unknown option “(unitd)”, try “/usr/local/sbin/unitd -h” for available options /usr/local/bin/unitc: line 183: $ERROR_LOG: ambiguous redirect unitc: ERROR: curl(1) exited with an error (6) unitc: Trying to access http:///status % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0curl: (6) Could not resolve host: status user% ls -al /tmp/unitc* -rw-r–r-- 1 user wheel 31 17 May 19:31 /tmp/unitc.10878.env

@lcrilly that patch you just posted works for me. Solves the issue.