public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] pxe: Allow use of environment variables in append string
Date: Mon, 04 Aug 2014 20:29:33 +0200	[thread overview]
Message-ID: <53DFD10D.6010501@redhat.com> (raw)
In-Reply-To: <53DBE56C.9020308@wwwdotorg.org>

Hi,

On 08/01/2014 09:07 PM, Stephen Warren wrote:
> On 08/01/2014 03:21 AM, Hans de Goede wrote:
>> Use run_command("setenv bootargs <label->append>") so that environment
>> variables (e.g. $console) can be used in append strings.
> 
> I'm slightly worried that this changes the semantics of the append line in the PXE/extlinux config file. Namely, you suddenly have to start worrying about escaping any $ signs or semi-colons etc..

I'm not that worried about $ needing escaping, as I cannot think
of any kernel commandline options using $, maybe they exist but if
they do they are quite rare.

But you make a good point about the ; I know some kernel cmdline
options which use those...

> 
>> diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
> 
>>       if (!localcmd)
>>           return -ENOENT;
>>
>> -    if (label->append)
>> -        setenv("bootargs", label->append);
>> +    if (label->append) {
>> +        bootargs = malloc(strlen("setenv bootargs ") +
>> +                  strlen(label->append) + 1);
>> +        if (!bootargs)
>> +            return 1;
> 
> Shouldn't this return a -ve error code for consistency with the other pre-existing error case I quoted above.

Yeah this is weird, I copy pasted this from
the label_boot() function, of which is a special version,
also label_boot() is the only caller of label_localboot()
(where this hunk applies), and it does not check the return
value at all...

I could make it -ENOMEM if you prefer.


>> +        strcpy(bootargs, "setenv bootargs ");
>> +        strcat(bootargs, label->append);
>> +        run_command(bootargs, 0);
> 
> Using whatever C function that the shell uses to expand variable references in the command-line, rather than run_command(), would at least avoid the issue of ; in label->append causing part of label->append after the ; to be execututed as a separate command.

Ack, I'll look into that and post a v2 with that change.

> There would still be the issue of $ suddenly meaning something different.

Right, but as said I'm not really worried about that.

Regards,

Hans

      reply	other threads:[~2014-08-04 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01  9:21 [U-Boot] [PATCH] pxe: Allow use of environment variables in append string Hans de Goede
2014-08-01 19:07 ` Stephen Warren
2014-08-04 18:29   ` Hans de Goede [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53DFD10D.6010501@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox