Tiny Core Extensions > TCE Q&A Forum
How to create an extension for a daemon (user creation)
destroyedlolo:
Hello,
I'm building an extension for a daemon ... and for security reason, I would like this daemon to run with a dedicated user.
What would be the smarter way to create this issuer ? Add user in the /tmp/package/usr/local/tce.installed script ?
Thanks
Rich:
Hi destroyedlolo
The tce.installed script sounds like a good place. I would do something like this:
--- Code: ---if ! cat /etc/passwd | cut -d: -f1 | grep -q SpecialUser
then
add user SpecialUser
any additional commands required if adding a user
fi
--- End code ---
The first line tests if SpecialUser already exists on the system. If it doesn't, then
the user gets added.
destroyedlolo:
Thanks for the confirmation and the code : I'll do it :)
Rich:
Hi destroyedlolo
Remember, usr/local/tce.installed/ExtensionName is a script. So
don't forget to include:
--- Code: ---#!/bin/sh
--- End code ---
on the first line.
destroyedlolo:
Hum, my user is
--- Code: ---daemon:x:100:65534:Linux User,,,:/tmp:/bin/false
--- End code ---
and my command is :
--- Code: ---su -c '/usr/local/sbin/PubSysFigures -Hbpi.chez.moi -s30' daemon
--- End code ---
but when I'm launching from my shell
--- Code: ---sudo su -c '/usr/local/sbin/PubSysFigures -Hbpi.chez.moi -s30' daemon
--- End code ---
the process is not launched and
--- Code: ---$ echo $?
1
--- End code ---
Do you what can create this issue ?
Navigation
[0] Message Index
[#] Next page
Go to full version