Bug 4676 - Can't use '#' in mdev.conf CMD
Summary: Can't use '#' in mdev.conf CMD
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.18.x
Hardware: Other Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-06 09:56 UTC by Nikolay.Yaroshevich
Modified: 2012-01-10 23:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Proposed patch (2.10 KB, patch)
2012-01-10 17:39 UTC, Denys Vlasenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay.Yaroshevich 2012-01-06 09:56:29 UTC
Sample string from my mdev.conf:

dvb[0123]\..*                   0:0     660     @N=${MDEV%.*}; N=${N#dvb}; D=${MDEV#dvb?.}; mkdir -p dvb/adapter${N}; chmod 755 dvb dvb/adapter${N}; mv MDEV dvb/adapter${N}/${D}

Executing that cmd on corresponding event causes error:
sh: syntax error: missing '}'

After some tracing it looks like '#' is treated as start of comment. 

in util-linux/mdev.c:
            if (ENABLE_FEATURE_MDEV_EXEC && command) {
                /* setenv will leak memory, use putenv/unsetenv/free */
                char *s = xasprintf("%s=%s", "MDEV", node_name);
                char *s1 = xasprintf("%s=%s", "SUBSYSTEM", G.subsystem);
                putenv(s);
                putenv(s1);
        ------> bb_error_msg("\n*** trying to exec '%s' ***\n", command);
                if (system(command) == -1)
                    bb_perror_msg("can't run '%s'", command);
                bb_unsetenv_and_free(s1);
                bb_unsetenv_and_free(s);
                free(command);
            }

Resulting output:

mdev: 
*** trying to exec 'N=${MDEV%.*}; N=${N' ***

sh: syntax error: missing '}'
mdev: 
*** trying to exec 'N=${MDEV%.*}; N=${N' ***

sh: syntax error: missing '}'
Comment 1 Denys Vlasenko 2012-01-10 17:39:33 UTC
Created attachment 3956 [details]
Proposed patch