Topic
  • 9 replies
  • Latest Post - ‏2014-03-27T07:35:43Z by aovictor
d.limanov
d.limanov
21 Posts

Pinned topic Run as current user on OS X?

‏2013-10-03T18:53:13Z |

I apologize in advance if this is trivial, but I can't seem to find the ability to run things interactively under the context of currently logged on user. Kind of like 'runascurrentuser' utility in Windows version of TEM.

Thanks much!

  • Lee Wei
    Lee Wei
    296 Posts

    Re: Run as current user on OS X?

    ‏2013-10-03T19:24:59Z  

    I don't have direct experience with this, but I suspect it is easier on Mac OS X compared with Windows.

    The Agent is running as root, so all you have to do is to "su" (switch user) to another user id.

    For example:

    wait su {name of current user} -c [you commands]

    Lee Wei

  • aovictor
    aovictor
    5 Posts

    Re: Run as current user on OS X?

    ‏2014-03-05T18:17:32Z  
    • Lee Wei
    • ‏2013-10-03T19:24:59Z

    I don't have direct experience with this, but I suspect it is easier on Mac OS X compared with Windows.

    The Agent is running as root, so all you have to do is to "su" (switch user) to another user id.

    For example:

    wait su {name of current user} -c [you commands]

    Lee Wei

    Just to clarify, if I wanted to install a current package it would be:

    wait su {name of current user} -c installer -pkg "__Download/package.pkg" -target /

    However, running this only gives back an exit code=1 and package is not installed.

  • jgstew
    jgstew
    410 Posts

    Re: Run as current user on OS X?

    ‏2014-03-06T22:55:07Z  
    • aovictor
    • ‏2014-03-05T18:17:32Z

    Just to clarify, if I wanted to install a current package it would be:

    wait su {name of current user} -c installer -pkg "__Download/package.pkg" -target /

    However, running this only gives back an exit code=1 and package is not installed.

    That would try to install the package as the current user, which would only work if the current user has the correct permissions to actually do the install. It would also only work if there is a user logged in at the time.

    Normally this is not how you would install something unless there was something odd about the package that required it to run as the current user.

  • aovictor
    aovictor
    5 Posts

    Re: Run as current user on OS X?

    ‏2014-03-25T00:32:48Z  
    • jgstew
    • ‏2014-03-06T22:55:07Z

    That would try to install the package as the current user, which would only work if the current user has the correct permissions to actually do the install. It would also only work if there is a user logged in at the time.

    Normally this is not how you would install something unless there was something odd about the package that required it to run as the current user.

    Correct, I am trying to get the installer to run this particular pkg as there are some components that will need to run as user.  I ensured that the package had full perms to read write and execute.  Additionally, all of our users have local admin rights.

    I usually do not like to go this method but the installer I have right now is made for ARD but I am trying to use BigFix to push it out.  IE - installing as root will give root full functionality but not all the users.

    In the past, I have gone back to the vendor to have them re-make the packge.  However, this becomes daunting because each subsequent update will require me to go back to the vendor as well.

    That is why I am trying to find a way to run as current user.

  • jgstew
    jgstew
    410 Posts

    Re: Run as current user on OS X?

    ‏2014-03-25T02:40:53Z  
    • aovictor
    • ‏2014-03-25T00:32:48Z

    Correct, I am trying to get the installer to run this particular pkg as there are some components that will need to run as user.  I ensured that the package had full perms to read write and execute.  Additionally, all of our users have local admin rights.

    I usually do not like to go this method but the installer I have right now is made for ARD but I am trying to use BigFix to push it out.  IE - installing as root will give root full functionality but not all the users.

    In the past, I have gone back to the vendor to have them re-make the packge.  However, this becomes daunting because each subsequent update will require me to go back to the vendor as well.

    That is why I am trying to find a way to run as current user.

    Did you try getting the package to install using SU in the terminal before trying in the IEM console?

  • aovictor
    aovictor
    5 Posts

    Re: Run as current user on OS X?

    ‏2014-03-25T03:42:10Z  
    • jgstew
    • ‏2014-03-25T02:40:53Z

    Did you try getting the package to install using SU in the terminal before trying in the IEM console?

    I was able to successfully install it by running:

    su root

    Then running the installer command from terminal as root yield a positive result.

    Additionally, running sudo installer also works.

    It is only when  I run it through big fix, that it fails.

  • jgstew
    jgstew
    410 Posts

    Re: Run as current user on OS X?

    ‏2014-03-25T13:46:29Z  
    • aovictor
    • ‏2014-03-25T03:42:10Z

    I was able to successfully install it by running:

    su root

    Then running the installer command from terminal as root yield a positive result.

    Additionally, running sudo installer also works.

    It is only when  I run it through big fix, that it fails.

     

    I don't mean to run it as "su root" in the terminal, I mean run it as "su <userWithAdminNotCurrentUser>" in the terminal.

    Then in bigfix run it as "su <User>" like:

     

    wait su {name of current user} -c <command>

     

    or

     

    wait su <name of user you are installing this for> -c <command>

  • aovictor
    aovictor
    5 Posts

    Re: Run as current user on OS X?

    ‏2014-03-25T18:07:23Z  
    • jgstew
    • ‏2014-03-25T13:46:29Z

     

    I don't mean to run it as "su root" in the terminal, I mean run it as "su <userWithAdminNotCurrentUser>" in the terminal.

    Then in bigfix run it as "su <User>" like:

     

    wait su {name of current user} -c <command>

     

    or

     

    wait su <name of user you are installing this for> -c <command>

    su <userWithAdminNotCurrentUser> -c installer /path/to/pkg -target /

    - yields syntax error due to the -c

    su <userWithAdminNotCurrentUser> installer /path/to/pkg -target /

    - yields "cannot execute binary file"

    wait su {name of current user} -c <command> installer /path/to/pkg -target /

    - yields Exit code 1 and nothing installed.  {name of current user} does correctly identify the user.

    wait su <name of user you are installing this for> -c <command>

    - Is not going to work since I will not manually input 7000 different users into the field. 

  • aovictor
    aovictor
    5 Posts

    Re: Run as current user on OS X?

    ‏2014-03-27T07:35:43Z  
    • aovictor
    • ‏2014-03-25T18:07:23Z

    su <userWithAdminNotCurrentUser> -c installer /path/to/pkg -target /

    - yields syntax error due to the -c

    su <userWithAdminNotCurrentUser> installer /path/to/pkg -target /

    - yields "cannot execute binary file"

    wait su {name of current user} -c <command> installer /path/to/pkg -target /

    - yields Exit code 1 and nothing installed.  {name of current user} does correctly identify the user.

    wait su <name of user you are installing this for> -c <command>

    - Is not going to work since I will not manually input 7000 different users into the field. 

    Upon further investigation, I was able to run the following command from root as the current user successfully from terminal:

    su <current user name> -c 'sudo installer -pkg /path/to/pkg -target /'

    I was only able to do this after editing the /etc/sudoers file with the following line:

    <current user name> ALL=(ALL) NOPASSWD: /usr/local/installer

     

    However, after applying those changes to my big fix actions, I get an exit code =2 for:

     

    wait su {name of current user} -c 'sudo installer -pkg /path/to/pkg -target /'

     

    or

     

    wait su {name of current user} -c 'sudo /usr/sbin/installer -pkg /path/to/pkg -target /'

     

    Not sure why its kicking back a exit code =2 / unknown command.