run-as support on Linux or UNIX
run-as support on Linux/UNIX enables you to execute any program or command using a different user account other than the currently logged in user (you). To use this feature, set the following attributes:
- run-as
- user-name
- password
Before you begin
The Command Line adapter uses the sudo command to support the run-as feature. To use the sudo command to support run-as on Linux or UNIX platform, an administrator must add an entry for users with the level of authorization in the /etc/sudoers file.
The following table describes the adapter request attributes for the Command Line adapter to support the run-as feature on Linux and UNIX.
Adapter request attributes for the run-as feature in the Command Line adapter for Linux and UNIX
The following figure shows a sample adapter request for the Command Line adapter to support the run-as feature on Linux or UNIX using simple commands.
XML sample of the Command Line adapter request for the run-as feature and simple commands format for Linux or UNIX
<command-request>
<commands>
<command run-as="true" user-name="root" password="mypassword">whoami</command>
<command run-as="true" user-name="user1" password="mypassword">whoami</command>
</commands>
</command-request>
The following figure shows a sample adapter response for the Command Line adapter to support the run-as feature on Linux or UNIX using simple commands.
XML sample of the Command Line adapter response for the run-as feature and simple commands format for Linux or UNIX
<command-result>
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output>
<metadata>
<os-id>Linux</os-id>
<os-version>2.6.9-22.ELsmp</os-version>
<os-arch>i386</os-arch>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>whoami</command>
<line-count>1</line-count>
<execution-milliseconds>68</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">root</line>
</output>
</command-output>
<command-output>
<metadata>
<command>whoami</command>
<line-count>1</line-count>
<execution-milliseconds>71</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">user1</line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</command-result>
The following figure shows a sample adapter request for the Command Line adapter to support the run-as feature on Linux or UNIX using a command group.
XML sample of the Command Line adapter request for the run-as feature and command group format for Linux or UNIX
<command-request>
<commands>
<command-group>
<command run-as="true" user-name="user1" password="mypassword">whoami</command>
<command run-as="true" user-name="root" password="mypassword">whoami</command>
</command-group>
</commands>
</command-request>
The following figure shows a sample adapter response for the Command Line adapter to support the run-as feature on Linux or UNIX using a command group.
XML sample of the Command Line adapter response for the run-as feature and command group format for Linux or UNIX
<command-result>
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output>
<metadata>
<os-id>Linux</os-id>
<os-version>2.6.9-22.ELsmp</os-version>
<os-arch>i386</os-arch>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>whoami</command>
<line-count>1</line-count>
<execution-milliseconds>66</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">user1</line>
</output>
</command-output>
<command-output>
<metadata>
<command>whoami</command>
<line-count>1</line-count>
<execution-milliseconds>67</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">root</line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</command-result>
The following figure shows a sample adapter request for the Command Line adapter to support the run-as feature on Linux or UNIX using FAT commands.
XML sample of the Command Line adapter request for the run-as feature and FAT command format for Linux or UNIX
<command-request>
<commands>
<fat-command>
<command os-id="Linux" run-as="true" user-name="root" password="mypassword">whoami</command>
</fat-command>
</commands>
</command-request>
The following figure shows a sample adapter response for the Command Line adapter to support the run-as feature on Linux or UNIX using FAT commands.
XML sample of the Command Line adapter response for the run-as feature and FAT command format for Linux or UNIX
<command-result>
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output>
<metadata>
<os-id>Linux</os-id>
<os-version>2.6.9-22.ELsmp</os-version>
<os-arch>i386</os-arch>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>whoami</command>
<line-count>1</line-count>
<execution-milliseconds>68</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">root</line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</command-result>