Forum > Embedded - ARM

calling internal procedures/functions with root rights - not external calls

<< < (2/2)

lucamar:

--- Quote from: ThomasK on May 28, 2021, 06:04:54 pm ---Anyway, if everything in Linux is a file O:-), is there a way to grant the user root access rights to the 'file' canx?
--- End quote ---

Several but one of the more common us to make canx accessible to some group with the proper rights and make the user part of that group. Not a cup of tea, for normal "dummie" users, but relatively easy and less dangereous than making them 'sudo' to execute the program ;)

MarkMLl:

--- Quote from: lucamar on May 28, 2021, 06:24:11 pm ---
--- Quote from: ThomasK on May 28, 2021, 06:04:54 pm ---Anyway, if everything in Linux is a file O:-), is there a way to grant the user root access rights to the 'file' canx?
--- End quote ---

Several but one of the more common us to make canx accessible to some group with the proper rights and make the user part of that group. Not a cup of tea, for normal "dummie" users, but relatively easy and less dangereous than making them 'sudo' to execute the program ;)

--- End quote ---

Agreed, which is where files installed in /etc/udev/rules.d come in. However that doesn't help for the creation of unix-domain sockets in /var/run, or the creation of low-numbered TCP or UDP ports... network resources (i.e. ports and interfaces) are of course completely out of the normal namespace.

MarkMLl

ThomasK:
I would be happy if I could do the following tasks with the application:
* Start the interface
* Stop the interface
* Reset the interfaceSince the Raspi would work headless, there is no need to be very flexible with the data rate.
I am no Linux guy at all, and also no C programmer so this is all very new to me.

I got canconfig to work, some commands need sudo some not, and I have no clue how to find out if there is data to retrieve from the input.

Also the response "ERROR_ACTIVE" for the interface beeing up but less than 96 errors is scary.
 
Since the application would be the "master" I would know when to poll, but this is weird. As far as I am concerned an eventhandler is a better solution.

About RTFM, there is a difference between a manual and a recipe (which I don't expect here, btw.)
A manual is like a standard, the smallest common base, created with minumum effort.
As cheap as possible and instead of having all information collected for the topic in the relevant chapter it points to other files, paragraphs etc. In some cases created by an algorithm.

MarkMLl:

--- Quote from: ThomasK on May 29, 2021, 05:29:56 pm ---About RTFM, there is a difference between a manual and a recipe (which I don't expect here, btw.)
A manual is like a standard, the smallest common base, created with minumum effort.
As cheap as possible and instead of having all information collected for the topic in the relevant chapter it points to other files, paragraphs etc. In some cases created by an algorithm.

--- End quote ---

Fine, so have you RTFMed yet? because I'm happy to talk you through code if it looks like you might use it, but have no intention of wasting my time if not.

MarkMLl

ThomasK:
I decided to do it using Tprocess.

I adapted the example in the Wiki and it works fine for me.
Since those commands are not required in a time critical path it is ok.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFCANTest.dothingsassudo(cmds2exec : string);  var    AProcess     : TProcess;    OutputLines  :  TStringList; begin    OutputLines := TStringList.Create;    AProcess    := TProcess.Create(nil);    AProcess.Executable := '/bin/sh';    AProcess.Parameters.Add('-c');    AProcess.Parameters.Add(cmds2exec);    AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];    AProcess.Execute;    OutputLines.LoadFromStream(Aprocess.Output);    if length(Outputlines.text)>0 then      FCANTest.mlog.lines.addstrings(Outputlines.text);    OutputLines.LoadFromStream(AProcess.Stderr);    if length(Outputlines.text)>0 then      FCANTest.mlog.lines.addstrings(Outputlines.text);    AProcess.Free;    OutputLines.Free;end;    
I can parse the output / error strings if necessary or display them only. Right now, it was just a proof of concept to communicate using CAN.

Thomas

Navigation

[0] Message Index

[*] Previous page

Go to full version