NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Linux file ownership

I have some RT code running on my cRIO-9045 which creates a handful of files. I then used the Web-based Configuration interface to make duplicates of those files, but it seems the owner got changed from "lvuser" to "webserv". When attempting to use "Read from Binary File" on the duplicates it fails with error code 8 "File permission error. You do not have the correct permissions for the file."

My Linux knowledge is poor, so I'm not sure what the simplest solution is here.

 

Can I programmatically change the owner from webserv to lvuser for any file? If so I can prevent the error 8 when attempting to read the files. (Note: using Set Permissions fails because I don't have permissions to change permissions.)

 

Can I manually change the owner in the Linux desktop or via a shell command (I'm unfamiliar with such an approach)? This wouldn't be preferable because I'd prefer my LabVIEW code to be able to handle the situation automatically.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 1 of 9
(3,842 Views)

Hmm, I can't seem to achieve anything. The Linux desktop is "lvuser" so it hasn't permission to change the owner of these new files that belong to "webserv". I can understand why, but how do I get around that?

I tried a "sudo chown" command to change the owner, but it appears "sudo" is not installed.

 

I need a solution that works on a vanilla Linux RT cRIO. This code will be deployed on other new machines and if files get created from the web service interface I need them to be readable from within the code. This is becoming a serious inconvenience.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 9
(3,829 Views)

I've tried looking at the umask lines in the bash profiles for the webserv user but it didn't seem to make a difference.

 

Also gone through system web server config files and don't see any references to this. NI have their own custom webdav module so not expecting to find any details on configuration online.


The only way I can see to have a one-time config change would be:

  • NI can provide a config token for the webdav server to set it to 66x (or 77x for dirs) - or preserve them on copy (could this be a bug?)
  • Not sure if it is possible to install ACL to the cRIO. Its not there by default but may give other options.
James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 3 of 9
(3,802 Views)

I'd actually call it a bug, or at least a serious inconvenience:

 

- When creating new files through the web interface, the owner is set to webserv:ni and the umask is set to 664 - great!

- But when duplicating existing files the umask is set to 600 - not so great...

 

I spent an hour today with su / sudo - even though that wouldn't work on a vanilla controller either, and despite the fact that messing around with su/sudo should be avoided - trying to make LabVIEW execute them via system exec.vi, so I could use chmod to programmatically correct the wrong umask, but to no avail...

 

There were error messages like "su: must be run from a terminal" or "sudo: sorry, you must have a tty to run sudo" or "sudo: no tty present and no askpass program specified". I'd have thought that adding the "Defaults: !requiretty" directive to the sudoers file would remedy that, but it didn't.




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )


Message 4 of 9
(3,797 Views)

Thoric, you can use chmod to set permissions on specific folder or file. If you set permissions to allow anyone to read a file, you should be able to avoid the error, see below. You could also System Exec.vi to run this command from your application. 

 

chmod 777 /path/to/folderOrFile
0 Kudos
Message 5 of 9
(3,787 Views)

Nope, you cannot, not without admin rights, which you cannot achieve without sudo, which is not installed.

 

To be clear - I'm working in an environment where I don't necessarily have control of the CompactRIOs installed, but I am responsible for the underlying framework of software. If my code is installed by a developer and encounters a file it cannot read, error code 8, it seems like there is nothing the code can do to rectify the problem.

Trying to set permissions on folders or files requires Admin level access, which the application will not have. Creating custom flavours of cRIO images requires control over the deployments, which I don't have.

 

The NI WebDAV toolkit needs to be investigated to understand why copying files creates permissions issues whereas creating files does not, and maybe a patch released to repair the bug. I appreciate that's time intensive however and won't be completed anytime soon.

 

Not sure what I'm going to do with my situation right now however....

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 6 of 9
(3,781 Views)

You can ssh into the cRIO as admin and run that command (if you are allowed to Enable Secure Shell Server (sshd) in MAX). See:

 

Accessing the Shell on NI Linux Real-Time Devices

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P8bQSAS&l=en-US

 

0 Kudos
Message 7 of 9
(3,770 Views)

fblerg: I appreciate your points, but this doesn't help me because I'm not in an environment where I can administer these CompactRIOs. I need my code to manage this scenario itself, and it cannot do what you're suggesting.

I'd much prefer a fix for the bug so that the complication doesn't occur. In the meantime I did solve my problem on my CompactRIO by using Putty and SSH, but in the future on other people's cRIOs I won't have access to, or awareness of, these files. 

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 8 of 9
(3,762 Views)

I'm running into a similar problem. I have some files that could be uploaded to the cRIO without the correct read permissions.  I have installed sudo and modified the the permissions of the sudo file using visudo. I can change the file permissions easily from the shell (either via admin or lvuser login) but System Exec gives me a command not found when using chmod (see screen shot). 

If I don't prepend sudo I get Operation not per chmod:
/c/config/config.dat: Operation not permitted

so I know the sudo file is set up correctly.  But i was reading this post https://blog.sasworkshops.com/crio-tips-running-linux-command-as-root-from-labview/ and thought that by adding lvuser to the sudoers list would allow chmod to be run from the System Exec.vi 
Any clues why it doesn't work?

nibuddy1777_0-1731098000167.png

 

0 Kudos
Message 9 of 9
(165 Views)