Pages: 1 [2]   Go Down
Author Topic: Ask your nix questions here instead?  (Read 2149 times)
0 Members and 1 Guest are viewing this topic.
Dubuque, Iowa, USA
Offline Offline
Faraday Member
**
Karma: 49
Posts: 2551
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry -- I'm just trying to be terse, not rude. I'm not sure how far we can overwhelm Liudr before he smashes the Pi with a hammer smiley-wink. Judging from earlier posts I get the feeling that Liudr would rather have everything performed in the executable rather than using nohup or other scripty methods (cron, xinetd, etc.).
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4836
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A little Perl can go a long way....

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry -- I'm just trying to be terse, not rude. I'm not sure how far we can overwhelm Liudr before he smashes the Pi with a hammer smiley-wink. Judging from earlier posts I get the feeling that Liudr would rather have everything performed in the executable rather than using nohup or other scripty methods (cron, xinetd, etc.).


Keeping my cool here (at least until I get a good box for the pi to smash against the wall with minimal damage). At the start of the day I knew nothing about background processes end at logout, daemons /etc/init.d/ etc. and now I have my basic understanding. I have several books but they are thick and don't talk to me. I am very appreciative with what you all provided here. I have just installed a simple script with update-rc.d that just runs the daemon I wrote (it deletes delete.txt in my home director every 5 seconds). I'm in a good position to read more books and online references. I think cron is possibly next. Also need to know how to tweak make files created by eclipse IDE. It's too massive to run on raspberry pi but did create a makefile. After some more reading I might be able to compile my projects with this makefile in console to save time. Then maybe look for solutions to cross compiling so I can develop the project on a Debian laptop, and occasionally cross compile for raspberry pi to test it out. Many things to learn.
Logged


Maine
Offline Offline
Sr. Member
****
Karma: 14
Posts: 418
Caution: Explosives in use.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have several books but they are thick and don't talk to me.

http://i.imgur.com/avBnKVV.jpg

It even doubles as a personal defense weapon if anyone sneaks up on me while i'm working.

You might have better luck starting out with a version of Ubuntu. Its a lot easier to find new user help threads for Ubuntu, and most of the settings will transfer over to Debian.
Logged

"Anyone who isn't confused really doesn't understand the situation."

Electronic props for Airsoft, paintball, and laser tag -> www.nightscapetech.com

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4836
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a thought. What if you start the daemon as administrator?
IIRC admin is always "on" but that is only poor memory.
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Maine
Offline Offline
Sr. Member
****
Karma: 14
Posts: 418
Caution: Explosives in use.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a thought. What if you start the daemon as administrator?
IIRC admin is always "on" but that is only poor memory.


Or even better, create a new user that only has permission to do what you need it to do. Like the Apache user is for the Apache webserver.
Logged

"Anyone who isn't confused really doesn't understand the situation."

Electronic props for Airsoft, paintball, and laser tag -> www.nightscapetech.com

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a thought. What if you start the daemon as administrator?
IIRC admin is always "on" but that is only poor memory.


Or even better, create a new user that only has permission to do what you need it to do. Like the Apache user is for the Apache webserver.

Sounds like the best and safest way to do things if I knew how to deal with user account already smiley-wink I am behind on my linux cookbook, which is a book on how to use linux. This motivates me. So is there a programmatic way to create such a user name? I wanted to spend the least time to set up and tweak each unit after my program is ready. If I can run a script or c program to create this account, it will be even more attractive option.

If I just installed the script that calls my daemon with sudo update-rc.d, the daemon will run as root, at system boot, correct? There's no need for anyone to log on for daemons to start, right?

I feel like different linux flavors are equally difficult to me since there is a command for everything and most of which I don't know. Programming on linux is probably not related to ease of use of GUI. I have a pidora image that I have not touched yet. Since raspberry pi recommends the raspbian distribution, I followed along with installing debian on my older laptop. Installation was not bad neither was GUI under KDE. It's relatively responsive on a 2.4GB core 2 duo and seems to run fine with 3GB ram. My main laptop with 4GB ram always fills up easily when windows vista loads up and I felt like it needs 6GB to do "blink" smiley-wink
Logged


Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a thought. What if you start the daemon as administrator?
IIRC admin is always "on" but that is only poor memory.


Not sure what account starts the daemon  smiley-red

I did sudo update-rc.d script_name

root I guess?
Logged


Maine
Offline Offline
Sr. Member
****
Karma: 14
Posts: 418
Caution: Explosives in use.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a thought. What if you start the daemon as administrator?
IIRC admin is always "on" but that is only poor memory.


Not sure what account starts the daemon  smiley-red

I did sudo update-rc.d script_name

root I guess?

Don't quote me on it, but i'm pretty sure sudo just gives your current account certain elevated permissions (that are specified in the sudo configuration). I think you can do something like sudo update-rc.d script_name.sh -u USER.
Logged

"Anyone who isn't confused really doesn't understand the situation."

Electronic props for Airsoft, paintball, and laser tag -> www.nightscapetech.com

Dubuque, Iowa, USA
Offline Offline
Faraday Member
**
Karma: 49
Posts: 2551
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"sudo" is "su" on steroids. "su" allows you to switch between users (e.g. "su - root" to switch to the root user) while sudo allows a more fine-grained configuration to allow the execution of a limited number of commands with the privileges of another user.

init.d scripts always execute with the privileges of the root user. The "init" process (process #1, the parent process of all, the head honcho, etc.) uses /etc/inittab as its configuration file. In /etc/inittab you'll see that the script /etc/init.d/rc is launched when the runlevel changes, and /etc/init.d/rc executes the appropriate scripts within /etc/rcX.d (where "X" is the runlevel) in the proper order.

After your script launches your executable your executable would switch to an unprivileged user using the setuid() and setgid() functions. You do have the issue that if you switch to an unprivileged user that you won't be able to access the hardware USB port, so you have to order your program so it opens the USB port first and then switches to an unprivileged user. Or adjust the privileges of the USB port (the device file) appropriately. Adjusting those privileges are kinda tricky so I'd suggest just running with the root user for the present time.

The only thing that update-rc.d does is create symlinks (in Windows parlance a "shortcut") from the various /etc/rcX.d directories to the script in /etc/init.d/. It's a handy tool but I'd suggest creating those symlinks manually so it doesn't feel like voodoo. Again, try to make your setup look like all of the other stuff that's already present -- compare to how other init scripts for ssh, cron, etc. are being run.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the detailed explanation. I just checked the daemon I installed to my raspbian. I did ps -u root and found it running as root. I have setsid in my code but not setuid or setgid. Is this the reason it is still a root priveleged process?
Logged


Pages: 1 [2]   Go Up
Jump to: