Changeset f53dc4c


Ignore:
Timestamp:
04/09/2012 10:17:30 AM (12 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
ablfs
Children:
d721466
Parents:
d6f2ebf
Message:

Change again the root commands, so that all control characters are escaped
Update the corresponding part in README.BLFS

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • BLFS/xsl/scripts.xsl

    rd6f2ebf rf53dc4c  
    437437        <xsl:when test="@role = 'root'">
    438438          <xsl:if test="$sudo = 'y'">
    439             <xsl:text>sudo sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
     439            <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
    440440          </xsl:if>
    441           <xsl:apply-templates select="userinput" mode="root"/>
     441          <xsl:apply-templates mode="root"/>
    442442          <xsl:if test="$sudo = 'y'">
    443443            <xsl:text>&#xA;ROOT_EOF</xsl:text>
     
    505505  </xsl:template>
    506506
    507   <xsl:template match="userinput" mode="root">
    508     <xsl:for-each select="child::node()">
    509       <xsl:choose>
    510         <xsl:when test="self::text()">
    511           <xsl:call-template name="output-root">
    512             <xsl:with-param name="out-string" select="string()"/>
    513           </xsl:call-template>
    514         </xsl:when>
    515         <xsl:otherwise>
    516           <xsl:apply-templates select="self::node()"/>
    517         </xsl:otherwise>
    518       </xsl:choose>
    519     </xsl:for-each>
     507  <xsl:template match="text()" mode="root">
     508    <xsl:call-template name="output-root">
     509      <xsl:with-param name="out-string" select="string()"/>
     510    </xsl:call-template>
    520511  </xsl:template>
    521512
     
    532523          <xsl:with-param name="out-string"
    533524                          select="substring-after($out-string,'make')"/>
     525        </xsl:call-template>
     526      </xsl:when>
     527      <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
     528        <xsl:call-template name="output-root">
     529          <xsl:with-param name="out-string"
     530                          select="substring-before($out-string,'$')"/>
     531        </xsl:call-template>
     532        <xsl:text>\$</xsl:text>
     533        <xsl:call-template name="output-root">
     534          <xsl:with-param name="out-string"
     535                          select="substring-after($out-string,'$')"/>
    534536        </xsl:call-template>
    535537      </xsl:when>
     
    568570  </xsl:template>
    569571
     572  <xsl:template match="replaceable" mode="root">
     573        <xsl:text>**EDITME</xsl:text>
     574        <xsl:apply-templates/>
     575        <xsl:text>EDITME**</xsl:text>
     576  </xsl:template>
     577
    570578</xsl:stylesheet>
  • README.BLFS

    rd6f2ebf rf53dc4c  
    274274     commands that require root privileges are run using sudo. Also make sure
    275275     necessary root privilege commands are visible in your PATH. Or use
    276      the `Defaults secure_path=' in /etc/sudoers. Also, the scripts use a
    277      fragile construct:
    278        sudo bash -c '<commands to be executed as root>'
    279      which fail if the commands to be executed contain themselves a ' or access
    280      a bash variable $XXX. So carefully review them. When you want to use
    281      environment variables, it is sometimes better to replace simple quotes
    282      with double quotes, but beware the construct is even more fragile.
    283      Carefully check it...
     276     the `Defaults secure_path=' in /etc/sudoers.
     277        For commands necessitating root privileges, the generated scripts wrap
     278     them with the construct:
     279       sudo -E sh << ROOT_EOF
     280         <commands to be executed as root with `$', ``', and `\' escaped>
     281       ROOT_EOF
     282     The -E switch ensures the whole environment is passed to the
     283     commands to be run with root privileges. It is effective only if the
     284     /etc/sudoers file contains `Defaults setenv', or SETENV in the user
     285     attributes. If you think it is a security issue, you may forbid this
     286     flag in /etc/sudoers, but then, you have to un-escape `$' for variables
     287     coming from the environment in the instructions.
     288        Although this construct is rather strong, it can fail in some corner
     289     cases, so carefully review those instructions.
    284290
    285291        Due to book layout issues, some sudo commands may be missing.
Note: See TracChangeset for help on using the changeset viewer.