4 Replies Latest reply on Jun 11, 2020 8:56 AM by Bill Robinson

    Is there a way to list/update permissions on Custom Commands using the CustomCmd BLCLI namespace

    Paul Williamson
      Share This:

      Trying to list/update permissions in Custom Commands using BLCLI, does anyone know of a way to achieve this?

        • 1. Re: Is there a way to list/update permissions on Custom Commands using the CustomCmd BLCLI namespace
          Bill Robinson

          blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true

          blcli_setoption serviceProfileName defaultProfile

          blcli_setoption roleName BLAdmins

          blcli_connect

           

           

          blcli_execute CustomCmd findAll

          blcli_execute Utility storeTargetObject cmds

          blcli_execute Utility listLength

          blcli_storeenv listLength

           

           

          for i in {0..$((listLength-1))}

                  do

                  blcli_execute Utility setTargetObject cmds

                  blcli_execute Utility listItemSelect ${i}

                  blcli_execute Utility setTargetObject

                  blcli_execute CustomCmd getDisplayName

                  blcli_storeenv cmdName

                  blcli_execute CustomCmd getBlAcl

                  blcli_execute Utility setTargetObject

                  blcli_execute Utility storeTargetObject blAcl

                  blcli_execute BlAcl aclToString NAMED_OBJECT=blAcl

                  blcli_storeenv aclText

                  echo "*************** ${cmdName} **************"

                  echo "${aclText}"

                  echo "*****************************************"

          done

          • 3. Re: Is there a way to list/update permissions on Custom Commands using the CustomCmd BLCLI namespace
            Paul Williamson

            Bill

            Now trying to add new permissions to the custom commands, I can see BlAcl addPermission allows me to add to a BlSecureObject, how do I do this for a Custom Command?

            • 4. Re: Is there a way to list/update permissions on Custom Commands using the CustomCmd BLCLI namespace
              Bill Robinson

              this should be all the permission actions:

               

              # acl policy add

              blcli_execute CustomCmd findByTypeAndName ${customCmdType} "${customCmd}"

              blcli_execute Utility storeTargetObject cmd

              blcli_execute BlAclPolicy findByName "${aclPolicy}"

              blcli_execute Utility setTargetObject

              blcli_execute Utility storeTargetObject policy

              blcli_execute BlAclPolicy applyAclPolicy_api NAMED_OBJECT=policy NAMED_OBJECT=cmd

              blcli_execute Utility setTargetObject

              blcli_execute Utility storeTargetObject obj

              blcli_execute CustomCmd update NAMED_OBJECT=obj

               

              # acl policy remove

              blcli_execute CustomCmd findByTypeAndName ${customCmdType} "${customCmd}"

              blcli_execute Utility storeTargetObject cmd

              blcli_execute BlAclPolicy findByName "${aclPolicy}"

              blcli_execute Utility setTargetObject

              blcli_execute Utility storeTargetObject policy

              blcli_execute BlAclPolicy removeAclPolicy_api NAMED_OBJECT=policy NAMED_OBJECT=cmd

              blcli_execute Utility setTargetObject

              blcli_execute Utility storeTargetObject obj

              blcli_execute CustomCmd update NAMED_OBJECT=obj

              # add permission

              blcli_execute CustomCmd findByTypeAndName ${customCmdType} "${customCmd}"

              blcli_execute Utility storeTargetObject cmd

              blcli_execute BlAcl addPermission NAMED_OBJECT=cmd "${roleName}" "${aclName}"

              blcli_execute Utility setTargetObject cmd

              blcli_execute CustomCmd update NAMED_OBJECT=cmd

               

               

              # remove permission

              blcli_execute CustomCmd findByTypeAndName ${customCmdType} "${customCmd}"

              blcli_execute Utility storeTargetObject cmd

              blcli_execute BlAcl removePermission NAMED_OBJECT=cmd "${roleName}" "${aclName}"

              blcli_execute Utility setTargetObject cmd

              blcli_execute CustomCmd update NAMED_OBJECT=cmd

               

              # apply acl tempalte

              blcli_execute CustomCmd findByTypeAndName ${customCmdType} "${customCmd}"

              blcli_execute Utility storeTargetObject cmd

              blcli_execute BlAclTemplate findByName "${aclTemplate}"

              blcli_execute Utility setTargetObject

              blcli_execute Utility storeTargetObject template

              blcli_execute BlAclTemplate applyAclTemplate_api NAMED_OBJECT=template NAMED_OBJECT=cmd false

              blcli_execute Utility setTargetObject

              blcli_execute Utility storeTargetObject obj

              blcli_execute CustomCmd update NAMED_OBJECT=obj

               

              i wrote a script to show them all in action, w/ a reset at the end.