You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2017/04/07 17:10:30 UTC

[GitHub] brooklyn-server pull request #624: Adds authSudo support (for sudo’ing wit...

GitHub user aledsage opened a pull request:

    https://github.com/apache/brooklyn-server/pull/624

    Adds authSudo support (for sudo\u2019ing with password)

    Required for some clouds (e.g. azure-arm), when using `useJcloudsSshInit: false`
    
    Tested on `azure-arm` using a location like that below (which previously failed):
    
    ```
    brooklyn.catalog:
      id: azure-arm-lon-centos7
      name: "Azure ARM UK South Centos 7.3"
      itemType: location
      item:
        type: jclouds:azurecompute-arm
        brooklyn.config:
          identity: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
          credential: xxxxxxxx
          endpoint: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
          oauth.endpoint: https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/token
          jclouds.azurecompute.arm.publishers: OpenLogic
          jclouds.azurecompute.operation.timeout: 120000
      
          jclouds.compute.resourcename-prefix: myprefix
          useJcloudsSshInit: false
          destroyOnFailure: false
          machineCreateAttempts: 1
          logCredentials: true
    
          installDevUrandom: true
          osVersionRegex: 7.3
          region: uksouth
          minRam: 2000
          waitForSshable: 10m
          waitForConnectable: 10m
          user: myname
    ```

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aledsage/brooklyn-server add-authSudo

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/624.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #624
    
----
commit 0ef4256e76e787415c033e6dbdb6122922172f15
Author: Aled Sage <al...@gmail.com>
Date:   2017-04-07T17:07:32Z

    Adds authSudo support (for sudo\u2019ing with password)
    
    Required for some clouds (e.g. azure-arm), when using 
    `useJcloudsSshInit: false`

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #624: Adds authSudo support (for sudo’ing wit...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/624#discussion_r110630192
  
    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/ssh/BashCommands.java ---
    @@ -91,12 +91,23 @@ public static String ok(String command) {
          * If null is supplied, it is returned (sometimes used to indicate no command desired).
          */
         public static String sudo(String command) {
    +        if (command==null) return null;
             if (command.startsWith("( ") || command.endsWith(" &"))
                 return sudoNew(command);
             else
                 return sudoOld(command);
         }
     
    +    public static String authSudo(String command, String password) {
    +        checkNotNull(password, "password must not be null");
    +        if (command==null) return null;
    +        if (command.startsWith("( ") || command.endsWith(" &")) {
    +            throw new UnsupportedOperationException("authSudo supports only simple commands, not those wrapped in parentheses or backgrounded: cmd="+command);
    +        }
    +        // some OS's (which?) fail if you try running sudo when you're already root (dumb but true)
    +        return format("( if test \"$UID\" -eq 0; then ( %s ); else echo -e '%s\\n' | sudo -E -S -- %s; fi )", command, password, command);
    --- End diff --
    
    Will fail if `password` contains single quotes. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #624: Adds authSudo support (for sudo’ing with passw...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the issue:

    https://github.com/apache/brooklyn-server/pull/624
  
    +1 apart from password escape concern.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #624: Adds authSudo support (for sudo’ing wit...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/624


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---