Incorrect permissions for the “sudo” command in 6.12.20

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Incorrect permissions for the “sudo” command in 6.12.20

跳至解决方案
1,499 次查看
cedric_starke
Contributor III

Hello community,

I have tried to change the user rights management of the Linux system I am using.
Instead of using root, I would like to add two new users. One as a “normal” user and one as a “sudo” user.

To solve this, I added the following lines to my local.conf:

inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd -M -N -G sudo -p 'test01' sudo_user; \
    useradd -M -N -G users -p 'test02' normal_user; \
    "

 

This seems to work, as the users are listed in /etc/passwd and /etc/shadow.

To execute root commands, I also need the sudo command. To include this in my package, I added the following to local.conf:

IMAGE_INSTALL:append = " sudo"

 

This installs the sudo command in my package, but the permissions are incorrect and result in the following output:

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

 

To solve this problem, I can change the permissions in the running system as follows:

chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo

 

But I need this directly as bitbake output.

 

Does anyone have any idea what I might have overlooked?

 

I am using Linux 6.12.20 for an iMX8M Mini based on the DDR4 EVK and the Bitbake image "fsl-image-machine-test".

The image “imx-image-multimedia” already includes sudo, but the permissions appear to be the same.

0 项奖励
回复
1 解答
987 次查看
cedric_starke
Contributor III

Hi @Oswalag,

Thanks for your reply, but when I run “bitbake”, with this option, I get an error.

In the end, I solved the problem by using a “bbappend” in my own layer, as shown in this example:
https://github.com/stromerbike/meta-medusa-dist/blob/master/recipes-extended/sudo/sudo_%25.bbappend

 

Maybe this will help someone else.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
1,445 次查看
Oswalag
NXP TechSupport
NXP TechSupport
0 项奖励
回复
1,414 次查看
cedric_starke
Contributor III

Hi @Oswalag,

Thanks for your reply, but the link has nothing to do with my problem.

I didn't mention in my question that I had already decided to change the sudoers file and comment out the line:

# %sudo ALL=(ALL) ALL

So my sudo user could run sudo IF the sudo command itself had the correct permissions.

 

However, after the YOCTO build, the sudo command shows me the following permissions:

---x--x--x 1 root root 334976 Mar  9  2018 /usr/bin/sudo

To run it as a member of the sudo group, the following is required:

-rwsr-xr-x 1 root root 334976 Mar  9  2018 /bin/sudo

 

Do you have any thoughts on this point

0 项奖励
回复
1,287 次查看
Oswalag
NXP TechSupport
NXP TechSupport

I understand, please try to add to your local.conf

EXTRA_IMAGE_FEATURES += "allow-setuid"

0 项奖励
回复
988 次查看
cedric_starke
Contributor III

Hi @Oswalag,

Thanks for your reply, but when I run “bitbake”, with this option, I get an error.

In the end, I solved the problem by using a “bbappend” in my own layer, as shown in this example:
https://github.com/stromerbike/meta-medusa-dist/blob/master/recipes-extended/sudo/sudo_%25.bbappend

 

Maybe this will help someone else.

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2306097%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E6.12.20%20%E4%B8%AD%20%22sudo%20%22%E5%91%BD%E4%BB%A4%E7%9A%84%E6%9D%83%E9%99%90%E4%B8%8D%E6%AD%A3%E7%A1%AE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2306097%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%A4%A7%E5%AE%B6%E5%A5%BD%3C%2FP%3E%3CP%3E%E6%88%91%E6%9B%BE%E5%B0%9D%E8%AF%95%E6%9B%B4%E6%94%B9%E6%88%91%E6%89%80%E4%BD%BF%E7%94%A8%E7%9A%84%20Linux%20%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%94%A8%E6%88%B7%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E3%80%82%3CBR%20%2F%3E%E6%88%91%E6%83%B3%E6%B7%BB%E5%8A%A0%E4%B8%A4%E4%B8%AA%E6%96%B0%E7%94%A8%E6%88%B7%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E4%BD%BF%E7%94%A8%20root%20%E7%94%A8%E6%88%B7%E3%80%82%E4%B8%80%E4%B8%AA%E6%98%AF%20%22%E6%99%AE%E9%80%9A%20%22%E7%94%A8%E6%88%B7%EF%BC%8C%E4%B8%80%E4%B8%AA%E6%98%AF%20%22sudo%20%22%E7%94%A8%E6%88%B7%E3%80%82%3C%2FP%3E%3CP%3E%E4%B8%BA%E4%BA%86%E8%A7%A3%E5%86%B3%E8%BF%99%E4%B8%AA%E9%97%AE%E9%A2%98%EF%BC%8C%E6%88%91%E5%9C%A8%20local.conf%20%E4%B8%AD%E6%B7%BB%E5%8A%A0%E4%BA%86%E4%BB%A5%E4%B8%8B%E5%87%A0%E8%A1%8C%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3Einherit%20extrausers%0AEXTRA_USERS_PARAMS%20%3D%20%22%5C%0A%20%20%20%20useradd%20-M%20-N%20-G%20sudo%20-p%20'test01'%20sudo_user%3B%20%5C%0A%20%20%20%20useradd%20-M%20-N%20-G%20users%20-p%20'test02'%20normal_user%3B%20%5C%0A%20%20%20%20%22%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%E8%BF%99%E4%BC%BC%E4%B9%8E%E6%9C%89%E6%95%88%EF%BC%8C%E5%9B%A0%E4%B8%BA%E7%94%A8%E6%88%B7%E5%B7%B2%E5%9C%A8%20%2Fetc%2Fpasswd%20%E5%92%8C%20%2Fetc%2Fshadow%20%E4%B8%AD%E5%88%97%E5%87%BA%E3%80%82%3C%2FP%3E%3CP%3E%E8%A6%81%E6%89%A7%E8%A1%8C%20root%20%E5%91%BD%E4%BB%A4%EF%BC%8C%E6%88%91%E8%BF%98%E9%9C%80%E8%A6%81%E4%BD%BF%E7%94%A8%20sudo%20%E5%91%BD%E4%BB%A4%E3%80%82%E4%B8%BA%E4%BA%86%E5%B0%86%E5%85%B6%E5%8C%85%E5%90%AB%E5%9C%A8%E6%88%91%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%8C%85%E4%B8%AD%EF%BC%8C%E6%88%91%E5%9C%A8%20local.conf%20%E4%B8%AD%E6%B7%BB%E5%8A%A0%E4%BA%86%E4%BB%A5%E4%B8%8B%E5%86%85%E5%AE%B9%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3EIMAGE_INSTALL%3Aappend%20%3D%20%22%20sudo%22%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%E8%BF%99%E4%BC%9A%E5%B0%86sudo%E5%91%BD%E4%BB%A4%E5%AE%89%E8%A3%85%E5%88%B0%E6%88%91%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%8C%85%E4%B8%AD%EF%BC%8C%E4%BD%86%E6%98%AF%E6%9D%83%E9%99%90%E4%B8%8D%E6%AD%A3%E7%A1%AE%E5%B9%B6%E5%AF%BC%E8%87%B4%E4%BB%A5%E4%B8%8B%E8%BE%93%E5%87%BA%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3Esudo%3A%20%2Fusr%2Fbin%2Fsudo%20must%20be%20owned%20by%20uid%200%20and%20have%20the%20setuid%20bit%20set%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%E4%B8%BA%E4%BA%86%E8%A7%A3%E5%86%B3%E8%BF%99%E4%B8%AA%E9%97%AE%E9%A2%98%EF%BC%8C%E6%88%91%E5%8F%AF%E4%BB%A5%E5%9C%A8%E8%BF%90%E8%A1%8C%E7%B3%BB%E7%BB%9F%E4%B8%AD%E6%9B%B4%E6%94%B9%E6%9D%83%E9%99%90%EF%BC%8C%E5%85%B7%E4%BD%93%E5%A6%82%E4%B8%8B%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3Echown%20root%3Aroot%20%2Fusr%2Fbin%2Fsudo%0Achmod%204755%20%2Fusr%2Fbin%2Fsudo%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%E4%BD%86%E6%88%91%E9%9C%80%E8%A6%81%E7%9B%B4%E6%8E%A5%E5%B0%86%E5%85%B6%E4%BD%9C%E4%B8%BA%20bitbake%20%E8%BE%93%E5%87%BA%E3%80%82%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%E6%9C%89%E4%BA%BA%E7%9F%A5%E9%81%93%E6%88%91%E5%8F%AF%E8%83%BD%E5%BF%BD%E7%95%A5%E4%BA%86%E4%BB%80%E4%B9%88%E5%90%97%EF%BC%9F%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E4%BD%BF%E7%94%A8%E5%9F%BA%E4%BA%8E%20DDR4%20EVK%20%E7%9A%84%20iMX8M%20Mini%20%E7%9A%84%20Linux%206.12.20%20%E5%92%8C%20Bitbake%20%E6%98%A0%E5%83%8F%22fsl-image-machine-test%22%20%E3%80%82%3C%2FP%3E%3CP%3E%E5%9B%BE%E5%83%8F%20%22imx-image-multimedia%20%22%E5%B7%B2%E5%8C%85%E5%90%AB%20sudo%EF%BC%8C%E4%BD%86%E6%9D%83%E9%99%90%E4%BC%BC%E4%B9%8E%E7%9B%B8%E5%90%8C%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2306097%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELinux%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EYocto%20Project%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314045%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Incorrect%20permissions%20for%20the%20%E2%80%9Csudo%E2%80%9D%20command%20in%206.12.20%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314045%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%3C%2FP%3E%0A%3CP%3E%E8%AF%B7%E6%9F%A5%E7%9C%8B%E4%B8%8B%E9%9D%A2%E7%9A%84%E9%93%BE%E6%8E%A5%EF%BC%9A%20%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F375433%2Fetc-sudoers-vs-etc-sudoers-d-file-for-enabling-sudo-for-a-user%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Funix.stackexchange.com%2Fquestions%2F375433%2Fetc-sudoers-vs-etc-sudoers-d-file-for-enabling-sudo-for-a-user%3C%2FA%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314370%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Incorrect%20permissions%20for%20the%20%E2%80%9Csudo%E2%80%9D%20command%20in%206.12.20%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314370%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%97%A8%EF%BC%8C%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F199933%22%20target%3D%22_blank%22%3E%40Oswalag%3C%2FA%3E%E3%80%81%3C%2FP%3E%3CP%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E5%9B%9E%E5%A4%8D%EF%BC%8C%E4%BD%86%E8%AF%A5%E9%93%BE%E6%8E%A5%E4%B8%8E%E6%88%91%E7%9A%84%E9%97%AE%E9%A2%98%E6%97%A0%E5%85%B3%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%9C%A8%E9%97%AE%E9%A2%98%E4%B8%AD%E6%B2%A1%E6%9C%89%E6%8F%90%E5%88%B0%E6%88%91%E5%B7%B2%E7%BB%8F%E5%86%B3%E5%AE%9A%E4%BF%AE%E6%94%B9%20sudoers%20%E6%96%87%E4%BB%B6%E5%B9%B6%E6%B3%A8%E9%87%8A%E6%8E%89%E8%BF%99%E4%B8%80%E8%A1%8C%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3E%23%20%25sudo%20ALL%3D(ALL)%20ALL%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E5%9B%A0%E6%AD%A4%EF%BC%8C%E5%A6%82%E6%9E%9C%20sudo%20%E5%91%BD%E4%BB%A4%E6%9C%AC%E8%BA%AB%E6%9C%89%E6%AD%A3%E7%A1%AE%E7%9A%84%E6%9D%83%E9%99%90%EF%BC%8C%E6%88%91%E7%9A%84%20sudo%20%E7%94%A8%E6%88%B7%E5%B0%B1%E5%8F%AF%E4%BB%A5%E8%BF%90%E8%A1%8C%20sudo%E3%80%82%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%E4%BD%86%E6%98%AF%EF%BC%8C%E5%9C%A8%20YOCTO%20%E7%89%88%E6%9C%AC%E4%B9%8B%E5%90%8E%EF%BC%8Csudo%20%E5%91%BD%E4%BB%A4%E5%90%91%E6%88%91%E6%98%BE%E7%A4%BA%E4%BA%86%E4%BB%A5%E4%B8%8B%E6%9D%83%E9%99%90%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3E---x--x--x%201%20root%20root%20334976%20Mar%20%209%20%202018%20%2Fusr%2Fbin%2Fsudo%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E8%A6%81%E4%BB%A5%20sudo%20%E7%BB%84%E7%9A%84%E6%88%90%E5%91%98%E8%BA%AB%E4%BB%BD%E8%BF%90%E8%A1%8C%E5%AE%83%EF%BC%8C%E9%9C%80%E8%A6%81%E6%BB%A1%E8%B6%B3%E4%BB%A5%E4%B8%8B%E6%9D%A1%E4%BB%B6%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3E-rwsr-xr-x%201%20root%20root%20334976%20Mar%20%209%20%202018%20%2Fbin%2Fsudo%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%E6%82%A8%E5%AF%B9%E6%AD%A4%E6%9C%89%E4%BB%80%E4%B9%88%E7%9C%8B%E6%B3%95%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321433%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Incorrect%20permissions%20for%20the%20%E2%80%9Csudo%E2%80%9D%20command%20in%206.12.20%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321433%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E6%88%91%E6%98%8E%E7%99%BD%EF%BC%8C%E8%AF%B7%E5%B0%9D%E8%AF%95%E5%9C%A8%E6%82%A8%E7%9A%84%20local.conf%20%E4%B8%AD%E6%B7%BB%E5%8A%A0%E4%BB%A5%E4%B8%8B%E5%86%85%E5%AE%B9%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EEXTRA_IMAGE_FEATURES%20%2B%3D%22allow-setuid%22%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2343496%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Incorrect%20permissions%20for%20the%20%E2%80%9Csudo%E2%80%9D%20command%20in%206.12.20%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2343496%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%97%A8%EF%BC%8C%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F199933%22%20target%3D%22_blank%22%3E%40Oswalag%3C%2FA%3E%E3%80%81%3C%2FP%3E%3CP%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E5%9B%9E%E5%A4%8D%EF%BC%8C%E4%BD%86%E5%BD%93%E6%88%91%E4%BD%BF%E7%94%A8%E8%AF%A5%E9%80%89%E9%A1%B9%E8%BF%90%E8%A1%8C%20%22bitbake%20%22%E6%97%B6%EF%BC%8C%E5%8D%B4%E5%87%BA%E7%8E%B0%E4%BA%86%E9%94%99%E8%AF%AF%E3%80%82%3C%2FP%3E%3CP%3EIn%20the%20end%2C%20I%20solved%20the%20problem%20by%20using%20a%20%E2%80%9Cbbappend%E2%80%9D%20in%20my%20own%20%E5%B1%82%2C%20as%20shown%20in%20this%20example%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fstromerbike%2Fmeta-medusa-dist%2Fblob%2Fmaster%2Frecipes-extended%2Fsudo%2Fsudo_%2525.bbappend%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fstromerbike%2Fmeta-medusa-dist%2Fblob%2Fmaster%2Frecipes-extended%2Fsudo%2Fsudo_%2525.bbappend%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%E4%B9%9F%E8%AE%B8%E8%BF%99%E8%83%BD%E5%B8%AE%E5%88%B0%E5%88%AB%E4%BA%BA%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E