Results 1 to 3 of 3

Thread: Daemon Idea

  1. #1

    Default Daemon Idea

    I am trying to write a daemon in perl that "watches" a directory (using perl-linux-Inotify2).

    I have written the script and am satisfied with it. I would like this to automatically start at boot and cleanly be started and stopped with an rc like command. I was able to put something together using Cool Solutions: Creating Custom init Scripts.

    However, I would like this script to run under an unprivileged daemon account (as many other daemons do). I don't know many options here. If I use sudo within the script, it spawns a new process and this is not cleaned up by the rc scripts. The setuid bit won't work because it is a script instead of a binary file, so this won't run as my unprivileged user.

    Any ideas? Should I just write this program in C, compile it, and use the setuid bit?

  2. #2

    Default Re: Daemon Idea

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Assuming you are using the CS exactly you are using startproc and
    killproc, presumably. Thankfully, those are good commands.

    man startproc

    -u user
    Sets the user ID of the process to user.

    There ya go.

    Good luck.






    pwright2 wrote:
    > I am trying to write a daemon in perl that "watches" a directory (using
    > perl-linux-Inotify2).
    >
    > I have written the script and am satisfied with it. I would like this
    > to automatically start at boot and cleanly be started and stopped with
    > an rc like command. I was able to put something together using 'Cool
    > Solutions: Creating Custom init Scripts'
    > (http://www.novell.com/coolsolutions/feature/15380.html).
    >
    > However, I would like this script to run under an unprivileged daemon
    > account (as many other daemons do). I don't know many options here. If I
    > use sudo within the script, it spawns a new process and this is not
    > cleaned up by the rc scripts. The setuid bit won't work because it is a
    > script instead of a binary file, so this won't run as my unprivileged
    > user.
    >
    > Any ideas? Should I just write this program in C, compile it, and use
    > the setuid bit?
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.9 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

    iQIcBAEBAgAGBQJKvSuhAAoJEF+XTK08PnB55fkQAJUwPqE/so+MqWqUSMawKB1y
    LrpMpnBgg7BmITrZfEtf6Fp9BekkF89cjIMJ/UJ20aJL5J0LoEBAy98ywgw265CZ
    G0TeHpH002u1ely1xWAMzkPYTiEr5QAzrsN8QyAzpEdf7LHJU0Ph+rvBC94lx7UL
    8B3tDao6cMFRoFc9LB8lVviJCqzVtSeVUwGr03kmqzsmqs9fn1C9hSQDYedgLv30
    M0i2CrWkqM/7GbPbcY7FeH7+Z/VGzspzbA5dJEBKBFACfQEaKQ2owVPBcCyf93Qo
    zrTyJBz5dmLxU96os23Cbfd6sfAKM5ri6u8TvM7kaJa0HBgUvMYSE7g1CVMpOYbn
    /On6xPr2YxHEEjrIu6vxOdHoVcP1kfP9esgdiUS1CiRyszQJMBryoOB3cJLH7/Pd
    732ALZXHc+LU//SYFyfgzkronkZGwHxV4/Ga40pO2jGQuytNz+N8z8rx9D88qN4w
    qADEzEdtOrmWd2dA3lNeMGTs51kKxEDcF0Q8txWGL1abq9Ba6drD6rNbI+4pSSNl
    E5yYHqlDd2JCg7qKqCvKpUCM9Vcs/97dlvw5Q71Icfv9VOqOzXNx+aLHZWaOClWH
    L/Tgk5S0O284lgkWrA/gGvpwvp21l5OnL8KwVLyuZiwEDBE3UQgsTd5z3J9dqXQ8
    5dC82iPJR5Z2fG5LJpDt
    =iMqU
    -----END PGP SIGNATURE-----

  3. #3

    Default Re: Daemon Idea

    Write a C wrapper to start (and stop) the process. There's an example of a small C wrapper for a Perl script in the camel book. The compiled C wrapper may, of course, have the setuid bit set.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •