Uploaded image for project: 'OpenICF'
  1. OpenICF
  2. OPENICF-719

ScriptedSSH sample - group members create/update is not working

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: SSH Connector
    • Environment:
      Java 1.7.0_101, OpenIDM 4.5.0 snapshot #69
    • Story Points:
      2

      Description

      ScriptedSSH sample have group defined as gid and members. Members attribute is not correctly handled for create and update.
      That leaves this attribute always empty. when group is created. If group is only updated, member attribute will remain same as nothing happened.
      I updated CreateLinux.groovy and UpdateLinux.groovy to fix this issues - added as attachements as well.

      CreateLinux.groovy - update line 178

      // Need to deal with members of groups
      if (objectClass.getObjectClassValue() == ObjectClass.GROUP_NAME) {
          if (attrs.findString("members") != null && promptReady(2)) {
              log.info "Setting members for $id"
              success = false
              for (member in attrs.findString("members").split(',')) {
                  command = new CommandLineBuilder("/usr/sbin/usermod")
                          .a()
                          .G(id)
                          .append(member)
                          .build()
                  log.info("Add user to group command: $command")
                  sudo command
                  expect prompt, { sendln "echo \$?" }         // Check returned code
                  expect(
                      [
                          match("0") {
                                  success = true
                          },
                          regexp("([1-6])\r\n") {
                              message = "Unexpected error"
                              exception = new ConnectorException(message)
                          }
                      ]
                  )
              }
          }
      }
      

      CreateLinux.groovy - update line 212

      if (!success && objectClass.getObjectClassValue() == ObjectClass.GROUP_NAME) {
          log.info("Adding user to group $id failed: $message")
          throw exception
      }
      

      UpdateLinux.groovy - update line 205

      // Need to deal with members of groups
      if (objectClass.getObjectClassValue() == ObjectClass.GROUP_NAME) {
          if (updateAttributes.findString("members") != null && promptReady(2)) {
              log.info "Setting members for $id"
              success = false
              def members = updateAttributes.findString("members")
              command = "sed -r -i.bak \'s/(^$id:x:[0-9]+:)(.*)/\\1$members/g\' /etc/group"
              log.info "Command for members update: $command"
              sudo command
              expect prompt, { sendln "echo \$?" }         // Check returned code
              expect(
                  [
                      match("0") {
                              success = true
                      },
                      regexp("([1-6])\r\n") {
                          message = "Unexpected error"
                          exception = new ConnectorException(message)
                      }
                  ]
              )
          }
      

      Provisioner file

      Member attribute for group is set as required, which is *not correct*. Group on Unix machine can be created empty and is not required for group creation.
      Fix is to remove it as required attribute.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              michal.orlik@profiq.cz Michal Orlik
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: