sudo broke - "/usr/bin/sudo must be owned by uid 0 and have the setuid bit set"
#1
I don't have half a clue how this happened.  I was trying to install BitWarden desktop app from source and ran into a few snags with node-gyp during build

Below is just some random stuff I was doing in the terminal.

On the first line below, sudo worked. On the last line, sudo suddenly failed and has been broken ever since.  Either something I did in the log below somehow broke sudo, or something in the background of PMOS broke it.

Any idea what's going on here?  Is there any way to recover other than wiping my phone and reinstalling?

This is a mostly clean install.. PMOS only on the device for about 1 hour, and I only installed some dev libs, git.. basic stuff.  

PMOS 21.03.1


Code:
pine64-pinephone:~/Source/desktop$ sudo npm install node-gyp -g added 91 packages, and audited 92 packages in 25s 3 packages are looking for funding   run `npm fund` for details found 0 vulnerabilities pine64-pinephone:~/Source/desktop$ node-gyp rebuild gyp info it worked if it ends with ok gyp info using node-gyp@8.1.0 gyp info using node@14.16.1 | linux | arm64 gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args  '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args  'binding.gyp', gyp info spawn args  '-f', gyp info spawn args  'make', gyp info spawn args  '-I', gyp info spawn args  '/home/user/Source/desktop/build/config.gypi', gyp info spawn args  '-I', gyp info spawn args  '/usr/lib/node_modules/node-gyp/addon.gypi', gyp info spawn args  '-I', gyp info spawn args  '/home/user/.cache/node-gyp/14.16.1/include/node/common.gypi', gyp info spawn args  '-Dlibrary=shared_library', gyp info spawn args  '-Dvisibility=default', gyp info spawn args  '-Dnode_root_dir=/home/user/.cache/node-gyp/14.16.1', gyp info spawn args  '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp', gyp info spawn args  '-Dnode_lib_file=/home/user/.cache/node-gyp/14.16.1/<(target_arch)/node.lib', gyp info spawn args  '-Dmodule_root_dir=/home/user/Source/desktop', gyp info spawn args  '-Dnode_engine=v8', gyp info spawn args  '--depth=.', gyp info spawn args  '--no-parallel', gyp info spawn args  '--generator-output', gyp info spawn args  'build', gyp info spawn args  '-Goutput_dir=.' gyp info spawn args ] gyp: binding.gyp not found (cwd: /home/user/Source/desktop) while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack    at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:353:16) gyp ERR! stack    at ChildProcess.emit (events.js:315:20) gyp ERR! stack    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) gyp ERR! System Linux 5.11.0 gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild" gyp ERR! cwd /home/user/Source/desktop gyp ERR! node -v v14.16.1 gyp ERR! node-gyp -v v8.1.0 gyp ERR! not ok pine64-pinephone:~/Source$ cd .. pine64-pinephone:~/Source$ find . -name "binding*" ./node-gyp/docs/binding.gyp-files-in-the-wild.md ./node-gyp/test/node_modules/hello_world/binding.gyp pine64-pinephone:~/Source$ cd node-gyp/test/node_modules/hello_world/ pine64-pinephone:~/Source/node-gyp/test/node_modules/hello_world$ node-gyp rebuild gyp info it worked if it ends with ok gyp info using node-gyp@8.1.0 gyp info using node@14.16.1 | linux | arm64 gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args  '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args  'binding.gyp', gyp info spawn args  '-f', gyp info spawn args  'make', gyp info spawn args  '-I', gyp info spawn args  '/home/user/Source/node-gyp/test/node_modules/hello_world/build/config.gypi', gyp info spawn args  '-I', gyp info spawn args  '/usr/lib/node_modules/node-gyp/addon.gypi', gyp info spawn args  '-I', gyp info spawn args  '/home/user/.cache/node-gyp/14.16.1/include/node/common.gypi', gyp info spawn args  '-Dlibrary=shared_library', gyp info spawn args  '-Dvisibility=default', gyp info spawn args  '-Dnode_root_dir=/home/user/.cache/node-gyp/14.16.1', gyp info spawn args  '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp', gyp info spawn args  '-Dnode_lib_file=/home/user/.cache/node-gyp/14.16.1/<(target_arch)/node.lib', gyp info spawn args  '-Dmodule_root_dir=/home/user/Source/node-gyp/test/node_modules/hello_world', gyp info spawn args  '-Dnode_engine=v8', gyp info spawn args  '--depth=.', gyp info spawn args  '--no-parallel', gyp info spawn args  '--generator-output', gyp info spawn args  'build', gyp info spawn args  '-Goutput_dir=.' gyp info spawn args ] internal/modules/cjs/loader.js:883   throw err;   ^ Error: Cannot find module 'nan' Require stack: - /home/user/Source/node-gyp/test/node_modules/hello_world/[eval]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)     at Function.Module._load (internal/modules/cjs/loader.js:725:27)     at Module.require (internal/modules/cjs/loader.js:952:19)     at require (internal/modules/cjs/helpers.js:88:18)     at [eval]:1:1     at Script.runInThisContext (vm.js:133:18)     at Object.runInThisContext (vm.js:310:38)     at internal/process/execution.js:77:19     at [eval]-wrapper:6:22     at evalScript (internal/process/execution.js:76:60) {   code: 'MODULE_NOT_FOUND',   requireStack: [ '/home/user/Source/node-gyp/test/node_modules/hello_world/[eval]' ] } gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack    at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:353:16) gyp ERR! stack    at ChildProcess.emit (events.js:315:20) gyp ERR! stack    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) gyp ERR! System Linux 5.11.0 gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild" gyp ERR! cwd /home/user/Source/node-gyp/test/node_modules/hello_world gyp ERR! node -v v14.16.1 gyp ERR! node-gyp -v v8.1.0 gyp ERR! not ok pine64-pinephone:~/Source/node-gyp/test/node_modules/hello_world$ sudo apk add g++ sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set



Code:
pine64-pinephone:~$ ls -l /usr/bin/sudo -rwxr-xr-x    1 root    1000        141224 Jan 26 19:06 /usr/bin/sudo


Any help appreciated.  Thanks
  Reply
#2
Hi, not sure how that could have happened, but it should be easy to fix.

As the error message suggests, you have to set the setuid bit. This is what allows the `sudo` binary to elevate its privileges.
To do so, you need to become root first, and since `sudo` is broken you have to use `su`. After that run the following command:
Code:
chmod u+s /usr/bin/sudo

The error message also says that `sudo` must be owned by uid 0 (root). Yours is owned by uid 0, but the group is set to gid 1000, so you might also want to change that to 0, although it's probably not necessary:
Code:
chown root:root /usr/bin/sudo


Hope that fixes it.
  Reply
#3
(07-07-2021, 04:26 AM)jlucas Wrote: Hi, not sure how that could have happened, but it should be easy to fix.

As the error message suggests, you have to set the setuid bit. This is what allows the `sudo` binary to elevate its privileges.
To do so, you need to become root first, and since `sudo` is broken you have to use `su`. After that run the following command:
Code:
chmod u+s /usr/bin/sudo

The error message also says that `sudo` must be owned by uid 0 (root). Yours is owned by uid 0, but the group is set to gid 1000, so you might also want to change that to 0, although it's probably not necessary:
Code:
chown root:root /usr/bin/sudo


Hope that fixes it.


Thank you.  I ended up wiping the phone.  I tried su, but I couldn't get it to accept a password.  I tried my lockscreen password as well as the default 147147. 

Weird issue
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PMOS test image: failed EG25 test broke modem fw MtnSk8 4 11,182 02-28-2021, 02:20 PM
Last Post: MtnSk8
  Can't find "sudo gedit" alternative mh4it 3 7,256 09-10-2020, 03:48 AM
Last Post: User 18618

Forum Jump:


Users browsing this thread: 1 Guest(s)