-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
driver/sshdriver: extend with su handling
Add two new attributes to the driver which will use su to switch to a user to run a command. The su_password is required for this feature to be used, su_username only needs to be set if another user than root should be switched to. Signed-off-by: Rouven Czerwinski <[email protected]> Co-developed-by: Jan Luebbe <[email protected]>
- Loading branch information
Showing
4 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
targets: | ||
main: | ||
resources: | ||
NetworkService: | ||
address: 127.0.0.1 | ||
username: <login_username> | ||
drivers: | ||
SSHDriver: | ||
su_password: <the_password> | ||
su_username: <the_username> | ||
stderr_merge: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import logging | ||
|
||
from labgrid import Environment | ||
|
||
logging.basicConfig( | ||
level=logging.DEBUG | ||
) | ||
|
||
env = Environment("conf.yaml") | ||
target = env.get_target() | ||
ssh = target.get_driver("SSHDriver") | ||
out, _, code = ssh.run("ps -p $PPID") | ||
print(code) | ||
print(out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters