← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1954789] Re: FreeBSD - double quotes for rc.conf

 

I don't think this has anything to do with "_unquote()", which is used
for parsing the file.

The behavior you are seeing is due to shlex.quote()[1][2], which
produces POSIX shell tokens:

>  shlex.quote(s)
>
> Return a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list.

Without a compelling reason to make this change, it would likely be
better to stick with a library implementation than to roll our own. If
this behavior were the result of a function that was part of cloud-init
function, then I would tend to agree with you; neat & tidy would be
better than the alternative. As it stands I don't think current behavior
is broken and shlex provides some security, so I'm going to close this.

Feel free to reopen if you still think this is worthwhile behavior to
change and we can discuss further.


[1] https://github.com/canonical/cloud-init/blob/a97fd062f7dbd4b824fd006edd08927ef9dbf24a/cloudinit/distros/bsd_utils.py#L32
[2] https://docs.python.org/3/library/shlex.html#shlex.quote

** Changed in: cloud-init
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1954789

Title:
  FreeBSD - double quotes for rc.conf

Status in cloud-init:
  Invalid

Bug description:
  Please ensure all variable values are double quoted in "etc/rc.conf".

  While rc.conf(5) does not explicitly call for the use of single or
  double quotes in ${rc_conf_files}, "etc/defaults/rc.conf" does.
  rc.conf(5) does, in fact, use double quotes '"' in all of it's
  examples. It is best practice to keep "etc/rc.conf" neat and tidy with
  the use of double quotes around all variable values.

  The bsd_utils.py (https://github.com/canonical/cloud-
  init/blob/main/cloudinit/distros/bsd_utils.py#L15) script has a
  "_unquote" function, that seems counterintuitive to the formatting of
  this file.

  ## etc/defaults/rc.conf
  <snip>
  # All arguments must be in double or single quotes.
  #
  # For a more detailed explanation of all the rc.conf variables, please
  # refer to the rc.conf(5) manual page.
  <snip>

  ## etc/rc.conf with a mix of quotes and no quotes, as applied by cloud-init
  $ cat /etc/rc.conf
  sshd_enable="YES"
  cloudinit_enable="YES"
  qemu_guest_agent_enable="YES"
  qemu_guest_agent_flags="-d -v -l /var/log/qemu-ga.log"
  ntpdate_enable="YES"
  ntpdate_flags="ntp.domain.net"
  ntpd_enable="YES"
  ifconfig_vtnet0_name=eth0
  defaultrouter=1.2.3.1
  ifconfig_eth0='1.2.3.4 netmask 255.255.255.0'
  hostname=freebsd13-short.localdomain

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1954789/+subscriptions



References