LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-01-2022, 07:00 AM   #1
Sol33t303
Member
 
Registered: Jul 2017
Distribution: gentoo
Posts: 115

Rep: Reputation: Disabled
Getting a permission error when running command as root due to command not being able to access some files


So I found the source of the problem that I posted about yesterday here. The problem is I get the following error when I run the following command with sudo (although the command runs fine without sudo):
Code:
sudo nvidia-container-cli info
Password: 
nvidia-container-cli: initialization error: nvml error: insufficient permissions
After some further digging on my system I traced the issue to the following files in /dev. When I set the permissions of the files to 777 I have no problem running the above command as sudo, this is the ls -l output of the files as they are on a fresh boot:
Code:
crw-rw---- 1 root video 195, 255 Jan  1 04:34 /dev/nvidiactl
crw-rw---- 1 root video 195, 0 Jan  1 04:34 /dev/nvidia0
crw-rw---- 1 root video 195, 1 Jan  1 04:34 /dev/nvidia1
crw-rw---- 1 root video 195, 2 Jan  1 04:34 /dev/nvidia2
I'm hoping somebody here can shed some light on whats happening here and why the command cannot access those files. Given it's being run with sudo that should mean the command should be able to access any files it wants regardless of permissions right? The only possible situation I can imagine would be the command (when run as root and not a regular user) tries to access that file as another user, how would I find out which user this is so I can add them to the video group? The only thing I can find in /etc/passwd that might be a relevent user is the nvpd user which is already in the video group:
Code:
nvpd:x:458:27:User for nvidia-persistenced:/dev/null:/sbin/nologin
video:x:27:root,sol33t303,boinc,greetd,nvpd
How should I proceed from here? I assume anybody within the video group should be able to access the files fine, so how can I figure out who is trying to access the files so I can add them to the video group? Unless there is actually something wrong with root and root can't access those files for some reason?

EDIT:
Found the config file for the command I am running and heres it's contents, I assume I should change the "user" setting to something else but what? It seems like it should be working the way it currently is:

Code:
disable-require = false
#swarm-resource = "DOCKER_RESOURCE_GPU"

[nvidia-container-cli]
#root = "/run/nvidia/driver"
#path = "/usr/bin/nvidia-container-cli"
environment = []
#debug = "/var/log/nvidia-container-toolkit.log"
#ldcache = "/etc/ld.so.cache"
load-kmods = true
#no-cgroups = false
user = "root:video"
ldconfig = "@/sbin/ldconfig"
#alpha-merge-visible-devices-envvars = false

[nvidia-container-runtime]
debug = "/var/log/nvidia-container-runtime.log"
I also tried setting user to "root:root" but that didn't work either.

Last edited by Sol33t303; 01-01-2022 at 01:16 PM.
 
Old 01-01-2022, 08:03 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
probably this: https://github.com/NVIDIA/nvidia-docker/issues/1547
 
Old 01-01-2022, 09:46 AM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Have you tried adding your user to the videos group?
The command 'groups' will tell you what croups your user already belongs to.
If not already in the videos group then the command below will add your user to that group
sudo usermod -a -G videos yourusername
You will have to log out and back in for the change to take affect.
 
Old 01-01-2022, 10:09 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
Have you tried adding your user to the videos group?
Yes:
Quote:
Originally Posted by Sol33t303 View Post
Code:
nvpd:x:458:27:User for nvidia-persistenced:/dev/null:/sbin/nologin
video:x:27:root,sol33t303,boinc,greetd,nvpd
 
Old 01-01-2022, 01:13 PM   #5
Sol33t303
Member
 
Registered: Jul 2017
Distribution: gentoo
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
Have you tried adding your user to the videos group?
The command 'groups' will tell you what croups your user already belongs to.
If not already in the videos group then the command below will add your user to that group
sudo usermod -a -G videos yourusername
You will have to log out and back in for the change to take affect.
Quote:
Originally Posted by pan64 View Post
Thank you, I did notice that in my searches, if you have a look at my edit I said I tried that, sadly it didn't seem to do anything as far as I could tell.

And cumputersavvy I am apart of the video group, if you look in the output I posted that my username is in the video group, along with root, boinc, greetd and nvpd.
 
Old 01-01-2022, 01:31 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by Sol33t303 View Post
And cumputersavvy I am apart of the video group, if you look in the output I posted that my username is in the video group, along with root, boinc, greetd and nvpd.
What you posted is not the output of the groups command, but instead a line out of the /etc/group file, so it was not completely clear that your user was in that group (especially since you had not stated your username and we had no way to know your username here is the same as the username on your PC.)

If the program runs properly as your regular user, then why would you need to use sudo or run it as the root user? The linux/unix policy is to run everything with the least permissions possible so if root is not needed then you really should not use it.

In fact there are several programs (and more all the time) that check and will not run if started as root (uid=0).
 
Old 01-01-2022, 01:43 PM   #7
Sol33t303
Member
 
Registered: Jul 2017
Distribution: gentoo
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
What you posted is not the output of the groups command, but instead a line out of the /etc/group file, so it was not completely clear that your user was in that group (especially since you had not stated your username and we had no way to know your username here is the same as the username on your PC.)

If the program runs properly as your regular user, then why would you need to use sudo or run it as the root user? The linux/unix policy is to run everything with the least permissions possible so if root is not needed then you really should not use it.

In fact there are several programs (and more all the time) that check and will not run if started as root (uid=0).
Yeah fair enough I probably should have done it using the groups command, that would have made it clearer, I'm sorry.

The reason I need to be able use it with sudo is because LXD is root and uses the same utilities, and when LXD tries to use these utilities since it's root they don't work, I was told this by the lead LXD dev here.

Last edited by Sol33t303; 01-01-2022 at 01:45 PM.
 
Old 01-03-2022, 12:33 PM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Most of the time programs need to presume that, when they attempt to open a file, they may or may not succeed in doing so for any number of reasons. They need to be prepared to gracefully handle that possibility, and inform the user as required.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] slackpkg is not able to update due to a certificate error. Post install, slackpkg running for 1st time (Slackware 14.2). fighter_fish Slackware - Installation 2 02-07-2021 09:27 PM
Root/non-user not able to delete files, Read only permission issue sukhdip Linux - Newbie 7 03-15-2013 10:25 AM
Find out if slow internet access is due to being attacked Ulysses_ Linux - Security 11 09-29-2011 04:58 AM
nero not getting permission to access some of my music files? noncomputergeek Linux - Software 4 11-02-2009 09:21 AM
Error USB-HUC on booting due in mdk10 due to mx700 Boudewijn Mandriva 4 10-09-2004 08:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration