<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to prevent non-root users from using su command? in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1894249#M225492</link>
    <description>&lt;P&gt;I can try the below commands to deny normal user su to root.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;root@imx6ulevk:~#&amp;nbsp;ls -l /bin/su*&lt;/P&gt;&lt;P&gt;lrwxrwxrwx 1 root root 14 Jun 21 18:47 /bin/su -&amp;gt; /bin/su.shadow&lt;BR /&gt;-rwsr-xr-x 1 root root 43628 May 6 2020 /bin/su.shadow&lt;/P&gt;&lt;P&gt;root@imx6ulevk:~# chmod 0750 /bin/su&lt;/P&gt;&lt;P&gt;root@imx6ulevk:~#&amp;nbsp;ls -l /bin/su*&lt;/P&gt;&lt;P&gt;lrwxrwxrwx 1 root root 14 Jun 20 15:43 su -&amp;gt; /bin/su.shadow&lt;BR /&gt;-rwxr-x--- 1 root root 43628 May 6 2020 su.shadow&lt;/P&gt;&lt;P&gt;root@imx6ulevk:~#&amp;nbsp;&amp;nbsp;su ap&lt;/P&gt;&lt;P&gt;ap@imx6ulevk:/bin$ su&lt;/P&gt;&lt;P&gt;-sh: su: Permission denied&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I want to set the permission of su in the same way under core-image-base image instead of console mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2024 08:48:43 GMT</pubDate>
    <dc:creator>TammyTsai</dc:creator>
    <dc:date>2024-06-26T08:48:43Z</dc:date>
    <item>
      <title>How to prevent non-root users from using su command?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1893586#M225438</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi NXP team,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I try to create a custom layer to change su permission.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The folder structure as shown below.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;meta-&lt;SPAN class=""&gt;custom&lt;/SPAN&gt;/ &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;├── conf &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;│&amp;nbsp; &amp;nbsp; &amp;nbsp; └── layer.conf &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;├── recipes-core&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;│&amp;nbsp; &amp;nbsp; &amp;nbsp; └── change-su-permissions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;│&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ├── change-su-permissions.bb &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;│&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; └── files &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The content of change-su-permissions.bb is as follows.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;SUMMARY = "Change permissions for su command"
LICENSE = "CLOSED"
PR = "r0"

do_install() {
    install -d ${D}${bindir}
    install -m 4750 ${WORKDIR}/rootfs/bin/su.shadow ${D}/bin/su.shadow
}

FILES_${PN} = "${bindir}/su"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The content of&amp;nbsp;&lt;SPAN&gt;layer.conf is as follows.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# We have a conf and classes directory, add to BBPATH
BBPATH := "${BBPATH}:${LAYERDIR}"

# We have recipes-* directories, add to BBFILES
BBFILES := "${BBFILES} ${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "change-su-permissions"
BBFILE_PATTERN_change-su-permissions := "^${LAYERDIR}/"
BBFILE_PRIORITY_change-su-permissions = "6"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The custom layer is also included in&amp;nbsp;&lt;SPAN&gt;build/conf/bblayers.conf file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;LCONF_VERSION = "7"

BBPATH = "${TOPDIR}"
BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"

BBFILES ?= ""
BBLAYERS = " \
  ${BSPDIR}/sources/poky/meta \
  ${BSPDIR}/sources/poky/meta-poky \
  \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  \
  ${BSPDIR}/sources/meta-freescale \
  ${BSPDIR}/sources/meta-freescale-3rdparty \
  ${BSPDIR}/sources/meta-freescale-distro \
  ${BSPDIR}/sources/meta-example \
  ${BSPDIR}/sources/meta-adduser \
  ${BSPDIR}/sources/meta-custom \
"

# i.MX Yocto Project Release layers
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-bsp "
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-sdk "

BBLAYERS += " ${BSPDIR}/sources/meta-browser "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-gnome "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-networking "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-python "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-filesystems "
BBLAYERS += " ${BSPDIR}/sources/meta-qt5 "&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Update build/conf/local.conf.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;IMAGE_INSTALL_append = ' change-su-permissions'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some errors occured while performing "bitbake core-image-base" to create image .&lt;/P&gt;&lt;P&gt;Please see the attached file "core-image-base_error_log.txt" for more details.&lt;/P&gt;&lt;P&gt;The log shows the path of su.shadow is not correct.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;| DEBUG: Executing shell function do_install&lt;BR /&gt;| install: &lt;FONT color="#FF0000"&gt;cannot stat '/home/west/yocto/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/change-su-permissions/1.0-r0/rootfs/bin/su.shadow': No such file or directory&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;My su.shadow is in the directory "/home/west/yocto/build/tmp/work/imx6ulevk-poky-linux-gnueabi/core-image-base/1.0-r0/rootfs/bin".&lt;/P&gt;&lt;P&gt;I run the following command and find out the ${WORKDIR} variable.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;$ bitbake -e core-image-base &amp;gt; build-env.txt&lt;/P&gt;&lt;P&gt;$ grep "^WORKDIR=" build-env.txt&lt;/P&gt;&lt;P&gt;WORKDIR="/home/west/yocto/build/tmp/work/imx6ulevk-poky-linux-gnueabi/core-image-base/1.0-r0"&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Why the path in the error message is not match ${WORKDIR}/rootfs/bin/su.shadow in the&amp;nbsp;&lt;SPAN&gt;change-su-permissions.bb?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How to solve this problem?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If the way of creating a custom layer can't change su permission, please help me how to achieve this requirement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 10:30:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1893586#M225438</guid>
      <dc:creator>TammyTsai</dc:creator>
      <dc:date>2024-06-25T10:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent non-root users from using su command?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1893823#M225454</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can look &lt;A href="https://ejaaskel.dev/yocto-hardening-non-root-users-sudo-configuration-disabling-root/" target="_self"&gt;this post&lt;/A&gt;, there is explained how to add users and manage the privileges in a Yocto environment using layers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;--... ...--&lt;/P&gt;
&lt;P&gt;Salas.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 18:48:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1893823#M225454</guid>
      <dc:creator>Manuel_Salas</dc:creator>
      <dc:date>2024-06-25T18:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent non-root users from using su command?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1894083#M225478</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/203368"&gt;@Manuel_Salas&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;There is no /etc/sudoers file in my i.MX6UL project.&lt;/P&gt;&lt;P&gt;I can't use sudo but only su.&lt;/P&gt;&lt;P&gt;How to set the permission of su?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Tammy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 06:39:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1894083#M225478</guid>
      <dc:creator>TammyTsai</dc:creator>
      <dc:date>2024-06-26T06:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent non-root users from using su command?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1894249#M225492</link>
      <description>&lt;P&gt;I can try the below commands to deny normal user su to root.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;root@imx6ulevk:~#&amp;nbsp;ls -l /bin/su*&lt;/P&gt;&lt;P&gt;lrwxrwxrwx 1 root root 14 Jun 21 18:47 /bin/su -&amp;gt; /bin/su.shadow&lt;BR /&gt;-rwsr-xr-x 1 root root 43628 May 6 2020 /bin/su.shadow&lt;/P&gt;&lt;P&gt;root@imx6ulevk:~# chmod 0750 /bin/su&lt;/P&gt;&lt;P&gt;root@imx6ulevk:~#&amp;nbsp;ls -l /bin/su*&lt;/P&gt;&lt;P&gt;lrwxrwxrwx 1 root root 14 Jun 20 15:43 su -&amp;gt; /bin/su.shadow&lt;BR /&gt;-rwxr-x--- 1 root root 43628 May 6 2020 su.shadow&lt;/P&gt;&lt;P&gt;root@imx6ulevk:~#&amp;nbsp;&amp;nbsp;su ap&lt;/P&gt;&lt;P&gt;ap@imx6ulevk:/bin$ su&lt;/P&gt;&lt;P&gt;-sh: su: Permission denied&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I want to set the permission of su in the same way under core-image-base image instead of console mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 08:48:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1894249#M225492</guid>
      <dc:creator>TammyTsai</dc:creator>
      <dc:date>2024-06-26T08:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent non-root users from using su command?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1898182#M225805</link>
      <description>&lt;P&gt;I add the below snippet of code to do_install() in the path&amp;nbsp;/source/poky/meta/recipes-extended/shadow/shadow.inc.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;chmod 4750 ${D}${bindir}/su&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;No normal user can use “su” after the above modification.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 08:35:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-prevent-non-root-users-from-using-su-command/m-p/1898182#M225805</guid>
      <dc:creator>TammyTsai</dc:creator>
      <dc:date>2024-07-03T08:35:26Z</dc:date>
    </item>
  </channel>
</rss>

