Answer the question
In order to leave comments, you need to log in
How to add root rights to node.js addons (c++)?
There was a need to write a simple "C \ C ++" script, and although I don't know "C" from the word at all, I wrote it, compiled it, checked it, everything is ok! (launched from sudo because inside it uses either requiring root).
My main language is js and, as a result, Node.js, I wanted to run the script through exec \ spawn, but then I saw / remembered that Node has built-in support for C ++ code in the form of modules.
With the help of Google and such and such a mother, I adapted the code to the Nod wrapper, connected the libs I needed, node-gyp compiled it into a module, the module connects perfectly in the Node, it is called, it even works (i.e. does not throw exсeptina-mi) for except for one .. code without root rights is not executed.
Well, actually the question is, how to give him root rights? so to speak, delegate root already to the module. Or in "C" make a call to a third-party lib method from root.
PS. I ran app.js with sudo, but it doesn't seem to apply to the module.
Thank you.
Answer the question
In order to leave comments, you need to log in
I apologize to the community. I wrote a post last night, when Moscow was clearly sick of everything.
When writing the sheet, I also thought that, after all, the FS module is also implemented in C, and running "sudo node app.js" is enough for it, which means that, in theory, it should be enough here .. but I was tired.
But he was tired and decided to try to shift the problem to the community, and he went to bed. :)
This morning, with a fresh mind, I realized that I connected Libu in C code and described how to work with it, but I DID NOT INITIALIZE !!! Fixed, checked - everything works fine!
In general, I repent. fool.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question