FAQ
I wish to switch my nodejs server user to a different one. I can find the
current user and UID but not others. What is the best way to switch the
process uid to a different one, e.g. www-data? This is probably a Linux
only question..

--
<surgemcgee> Systems/Software Engineer

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • José F. Romaniello at Nov 8, 2013 at 4:48 pm
    I usually register my node.js servers as daemons (services) with upstart.
    Upstar scripts can have "setuid" :

    http://upstart.ubuntu.com/cookbook/#setuid

    To run a command from the CLI as another user you can use "sudo -u user
    command" eg: sudo -u user node server.js







    2013/11/8 Robert Steckroth <robertsteckroth@gmail.com>
    I wish to switch my nodejs server user to a different one. I can find the
    current user and UID but not others. What is the best way to switch the
    process uid to a different one, e.g. www-data? This is probably a Linux
    only question..

    --
    <surgemcgee> Systems/Software Engineer



    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Robert Steckroth at Nov 8, 2013 at 5:11 pm
    Hell ya, upstart is your friend, but I want to set the user to www-data in
    the nodejs script for development purposes as well.
    I can set the user with a process.setuid(uid) command but this
    requires knowledge of the UID of the user I need. I was hoping for
    a different/better solution than
    manually parsing the /etc/passwd file.


    On Fri, Nov 8, 2013 at 11:48 AM, José F. Romaniello
    wrote:
    I usually register my node.js servers as daemons (services) with upstart.
    Upstar scripts can have "setuid" :

    http://upstart.ubuntu.com/cookbook/#setuid

    To run a command from the CLI as another user you can use "sudo -u user
    command" eg: sudo -u user node server.js







    2013/11/8 Robert Steckroth <robertsteckroth@gmail.com>
    I wish to switch my nodejs server user to a different one. I can find the
    current user and UID but not others. What is the best way to switch the
    process uid to a different one, e.g. www-data? This is probably a Linux
    only question..

    --
    <surgemcgee> Systems/Software Engineer



    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    <surgemcgee> Systems/Software Engineer

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • José F. Romaniello at Nov 8, 2013 at 5:16 pm
    Sorry , I didn't understand the question in the first mail, maybe this:

    exec('id -u username', function (err, stdout) {
       var user_id = stdout;
       process.setiuid(user_id)
    }) ;


    2013/11/8 Robert Steckroth <robertsteckroth@gmail.com>
    Hell ya, upstart is your friend, but I want to set the user to www-data in
    the nodejs script for development purposes as well.
    I can set the user with a process.setuid(uid) command but this
    requires knowledge of the UID of the user I need. I was hoping for
    a different/better solution than
    manually parsing the /etc/passwd file.


    On Fri, Nov 8, 2013 at 11:48 AM, José F. Romaniello <
    jfromaniello@gmail.com> wrote:
    I usually register my node.js servers as daemons (services) with upstart.
    Upstar scripts can have "setuid" :

    http://upstart.ubuntu.com/cookbook/#setuid

    To run a command from the CLI as another user you can use "sudo -u user
    command" eg: sudo -u user node server.js







    2013/11/8 Robert Steckroth <robertsteckroth@gmail.com>
    I wish to switch my nodejs server user to a different one. I can find
    the current user and UID but not others. What is the best way to switch the
    process uid to a different one, e.g. www-data? This is probably a Linux
    only question..

    --
    <surgemcgee> Systems/Software Engineer



    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    <surgemcgee> Systems/Software Engineer



    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Sam Roberts at Nov 8, 2013 at 5:20 pm

    On Fri, Nov 8, 2013 at 9:11 AM, Robert Steckroth wrote:
    I can set the user with a process.setuid(uid) command but this requires
    knowledge of the UID of the user I need. I was hoping for a different/better
    solution than manually parsing the /etc/passwd file.
    ???

    Sets the user identity of the process. (See setuid(2).) This accepts
    either a numerical ID or a username string. If a username is
    specified, this method blocks while resolving it to a numerical ID.

    - http://nodejs.org/api/process.html#process_process_setuid_id

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Robert Steckroth at Nov 8, 2013 at 7:55 pm
    Perfect; I suppose I skimmed over the docs. Thanks

         process.initgroups('www-data', 'www-data') // add group www-data

         process.setgid(process.getgroups()[0]) // set user to www-data




    On Fri, Nov 8, 2013 at 12:20 PM, Sam Roberts wrote:

    On Fri, Nov 8, 2013 at 9:11 AM, Robert Steckroth
    wrote:
    I can set the user with a process.setuid(uid) command but this requires
    knowledge of the UID of the user I need. I was hoping for a
    different/better
    solution than manually parsing the /etc/passwd file.
    ???

    Sets the user identity of the process. (See setuid(2).) This accepts
    either a numerical ID or a username string. If a username is
    specified, this method blocks while resolving it to a numerical ID.

    - http://nodejs.org/api/process.html#process_process_setuid_id

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    <surgemcgee> Systems/Software Engineer

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedNov 8, '13 at 4:38p
activeNov 8, '13 at 7:55p
posts6
users3
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase