[sr-dev] [tracker] Comment added: make install fails with a bash syntax error

sip-router admin at sip-router.org
Wed Sep 8 13:31:58 CEST 2010


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#87 - make install fails with a bash syntax error
User who did this - Dmitry Goncharov (Dmitry)

----------
make install-sr-man runs w/o errors.
Adding a whitespace between "" and ; makes no difference.

The following is a verbose run which produces an error.
$ git diff |cat
diff --git a/Makefile b/Makefile
index 210d277..cdfc687 100644
--- a/Makefile
+++ b/Makefile
@@ -918,7 +918,7 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
                        fi; \
                fi
                @# other configs
-               @for r in $(C_INSTALL_CFGS) ""; do \
+               for r in $(C_INSTALL_CFGS) ""; do \
                        if [ -n "$$r" ]; then \
                                if [ -f "$$r" ]; then \
                                        n=`basename "$$r"` ; \
$
$
$ make install-cfg
Makefile.defs defs skipped
for r in  ""; do \
                        if [ -n "$r" ]; then \
                                if [ -f "$r" ]; then \
                                        n=`basename "$r"` ; \
                                        sed  -e "s#/usr/[^:]*lib/kamailio/modules\([:/\"]\)#/usr/local/lib/kamailio/modules\1#g"  -e "s#/usr/[^:]*lib/kamailio/modules_k\([:/\"]\)#/usr/local/lib/kamailio/modules_k\1#g" \
                                                < "$r" \
                                                > "//etc/kamailio/$n.sample" ; \
                                        chmod 644 "//etc/kamailio/$n.sample" ; \
                                        if [ -z "" -a \
                                                        ! -f "//etc/kamailio/$n" ]; \
                                        then \
                                                mv -f "//etc/kamailio/$n.sample" \
                                                                "//etc/kamailio/$n"; \
                                        fi ; \
                                else \
                                        echo "ERROR: $r not found" ; \
                                        if [ 1 =hen \; then \
                                                exit 1; \
                                        fi ; \
                                fi ; \
                        fi ; \
                done; true
/bin/sh: -c: line 18: syntax error near unexpected token `fi'
/bin/sh: -c: line 18: `                         fi ; \'
make: *** [install-cfg] Error 1
$


Note, the line "if [ 1 =hen \; then \". This is the syntax error.
"hen" is a part of "then".


This run  with the sed expression moved left a couple of tabs.
$ git diff | cat
diff --git a/Makefile b/Makefile
index 210d277..8ce9429 100644
--- a/Makefile
+++ b/Makefile
@@ -918,12 +918,12 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
                        fi; \
                fi
                @# other configs
-               @for r in $(C_INSTALL_CFGS) ""; do \
+               for r in $(C_INSTALL_CFGS) ""; do \
                        if [ -n "$$r" ]; then \
                                if [ -f "$$r" ]; then \
                                        n=`basename "$$r"` ; \
                                        sed $(foreach m,$(modules_dirs),\
-                                                       -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
+                                       -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
                                                < "$$r" \
                                                > "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
                                        chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
$
$
$
$ make install-cfg
Makefile.defs defs skipped
for r in  ""; do \
                        if [ -n "$r" ]; then \
                                if [ -f "$r" ]; then \
                                        n=`basename "$r"` ; \
                                        sed  -e "s#/usr/[^:]*lib/kamailio/modules\([:/\"]\)#/usr/local/lib/kamailio/modules\1#g"  -e "s#/usr/[^:]*lib/kamailio/modules_k\([:/\"]\)#/usr/local/lib/kamailio/modules_k\1#g" \
                                                < "$r" \
                                                > "//etc/kamailio/$n.sample" ; \
                                        chmod 644 "//etc/kamailio/$n.sample" ; \
                                        if [ -z "" -a \
                                                        ! -f "//etc/kamailio/$n" ]; \
                                        then \
                                                mv -f "//etc/kamailio/$n.sample" \
                                                                "//etc/kamailio/$n"; \
                                        fi ; \
                                else \
                                        echo "ERROR: $r not found" ; \
                                        if [ 1 = then \then \
                                                exit 1; \
                                        fi ; \
                                fi ; \
                        fi ; \
                done; true
/bin/sh: -c: line 18: syntax error near unexpected token `fi'
/bin/sh: -c: line 18: `                         fi ; \'
make: *** [install-cfg] Error 1
$

The offending line is different.


"do" moved to the next line.
$ git diff | cat
diff --git a/Makefile b/Makefile
index 210d277..11531bf 100644
--- a/Makefile
+++ b/Makefile
@@ -918,7 +918,8 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
                        fi; \
                fi
                @# other configs
-               @for r in $(C_INSTALL_CFGS) ""; do \
+               for r in $(C_INSTALL_CFGS) ""; \
+               do \
                        if [ -n "$$r" ]; then \
                                if [ -f "$$r" ]; then \
                                        n=`basename "$$r"` ; \
$
$
$ make install-cfg
Makefile.defs defs skipped
for r in  ""; \
                do \
                        if [ -n "$r" ]; then \
                                if [ -f "$r" ]; then \
                                        n=`basename "$r"` ; \
                                        sed  -e "s#/usr/[^:]*lib/kamailio/modules\([:/\"]\)#/usr/local/lib/kamailio/modules\1#g"  -e "s#/usr/[^:]*lib/kamailio/modules_k\([:/\"]\)#/usr/local/lib/kamailio/modules_k\1#g" \
                                                < "$r" \
                                                > "//etc/kamailio/$n.sample" ; \
                                        chmod 644 "//etc/kamailio/$n.sample" ; \
                                        if [ -z "" -a \
                                                        ! -f "//etc/kamailio/$n" ]; \
                                        then \
                                                mv -f "//etc/kamailio/$n.sample" \
                                                                "//etc/kamailio/$n"; \
                                        fi ; \
                                else \
                                        echo "ERROR: $r not found" ; \
                                        if [ 1 = 1 ] ; then \
                                                exit 1; \
                                        fi ; \
                                fi ; \
                        fi ; \
                done; true
# radius dictionary
touch           //etc/kamailio//dictionary.kamailio
install -m 644 etc/dictionary.kamailio //etc/kamailio/
$

The offending line is okay.

Placing a space between , and \ in the sed expression makes the offending line syntactically correct.

The issue looks like a buffer overflow.
Also tried with bash-3.2.51. The result is the same.
HTH
----------

More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=87#comment123

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.



More information about the sr-dev mailing list