Return ContextService arguments for sudo as a become method.
434278
def _connect_sudo(spec):
    
    return {
        'method': 'sudo',
        'enable_lru': True,
        'kwargs': {
            'username': spec.become_user(),
            'password': spec.become_pass(),
            'python_path': spec.python_path(),
            'sudo_path': spec.become_exe(),
            'connect_timeout': spec.timeout(),
            'sudo_args': spec.sudo_args(),
            'remote_name': get_remote_name(spec),
        }
    }
547273
def _authn_context_decl(decl, authn_auth=None):
    
    return factory(saml.AuthnContext,
                   authn_context_decl=decl,
                   authenticating_authority=factory(
                       saml.AuthenticatingAuthority, text=authn_auth))
239180
def from_context(cls, ctx, config_paths=None, project=None):
        """"""
        if ctx.obj is None:
            ctx.obj = Bunch()
        ctx.obj.cfg = cls(ctx.info_name, config_paths, project=project)
        return ctx.obj.cfg
926602
def execute(context)
      cmd       = context[:cmd]
      opts      = context[:opts] || {}
      args      = context[:args] || []
      cmd_args  = context[:cmd_args]
      cli_shell = context[:shell] || shell

      unless cmd.callable?
        return root['help'].call(opts, cmd_args, shell)
      end

      cmd = handle_callable_option(root, cmd)
      cmd.call(opts, args, cli_shell)

    end
527064
def login_required(method):
    """"""
    def wrapper(self, *arg, **karg):
        if not self.user:
            if self.request.method == "GET":
                self.redirect(settings.LOGIN_PATH)
            else:
                self.error(403)
        else:
            method(self, *arg, **karg)
    return wrapper
138198
def get_context_data(self, **kwargs):
        
        context = super(UserServiceUpdateView, self).get_context_data(**kwargs)
        context['service_name_alone'] = self.object.name.name.rsplit('Service')[1]
        context['service_name'] = self.object.name.name
        context['SERVICES_AUTH'] = settings.SERVICES_AUTH
        context['SERVICES_HOSTED_WITH_AUTH'] = settings.SERVICES_HOSTED_WITH_AUTH
        context['SERVICES_NEUTRAL'] = settings.SERVICES_NEUTRAL

        context['action'] = 'edit'
        return context
332328
def context_factory(apply_globally=False, api=None):
    """"""
    def decorator(context_factory_):
        if apply_globally:
            hug.defaults.context_factory = context_factory_
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(context_factory_)
            apply_to_api.context_factory = context_factory_
        return context_factory_
    return decorator
1068843
def sudo(cmd)
      cmd = "sudo #{cmd}" unless  Process.euid == 0

      RightScale::Log.info("LoginUserManager command: #{cmd}")
      output = %x(#{cmd})
      result = $?
      RightScale::Log.info("LoginUserManager result: #{$?.exitstatus}; output: #{cmd}")

      result
    end
1337158
def cli(env, identifier):
    """"""

    mgr = SoftLayer.UserManager(env.client)
    user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
    object_mask = "mask[id, permissions, isMasterUserFlag, roles]"

    user = mgr.get_user(user_id, object_mask)
    all_permissions = mgr.get_all_permissions()
    user_permissions = perms_to_dict(user['permissions'])

    if user['isMasterUserFlag']:
        click.secho('This account is the Master User and has all permissions enabled', fg='green')

    env.fout(roles_table(user))
    env.fout(permission_table(user_permissions, all_permissions))
53076
def getContext(self):
        """"""
        ctx = SSL.Context(SSL.SSLv23_METHOD)
        ctx.use_certificate_file('server.pem')
        ctx.use_privatekey_file('server.pem')
        return ctx
244432
@Override
    public void contextualize(Context context) throws ContextException {
        authConfigFactory = new AuthConfigFactory((PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY));
    }
353697
def getContext(self):
        """"""
        ctx = ClientContextFactory.getContext(self)
        ctx.set_options(OP_NO_SSLv3)
        return ctx
593524
def make_context(self, **kwargs):
        """"""
        self.check_schema()
        return Context(self.driver, self.config, **kwargs)
578715
def options(self, context, module_options):
        '''
           
        '''
        self.command = 'privilege::debug sekurlsa::logonpasswords exit'
        if module_options and 'COMMAND' in module_options:
            self.command = module_options['COMMAND']

        self.ps_script = obfs_ps_script('powersploit/Exfiltration/Invoke-Mimikatz.ps1')
388026
def get(self, sid):
        
        return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid, )
563742
def get(context, resource, **kwargs):
    """"""
    uri = '%s/%s/%s' % (context.dci_cs_api, resource, kwargs.pop('id'))
    r = context.session.get(uri, timeout=HTTP_TIMEOUT, params=kwargs)
    return r
430517
def make_command(
    command,
    env=None,
    su_user=None,
    sudo=False,
    sudo_user=None,
    preserve_sudo_env=False,
):
    '''
    
    '''

    debug_meta = {}

    for key, value in (
        ('sudo', sudo),
        ('sudo_user', sudo_user),
        ('su_user', su_user),
        ('env', env),
    ):
        if value:
            debug_meta[key] = value

    logger.debug('Building command ({0}): {1}'.format(' '.join(
        '{0}: {1}'.format(key, value)
        for key, value in six.iteritems(debug_meta)
    ), command))

    # Use env & build our actual command
    if env:
        env_string = ' '.join([
            '{0}={1}'.format(key, value)
            for key, value in six.iteritems(env)
        ])
        command = 'export {0}; {1}'.format(env_string, command)

    # Quote the command as a string
    command = shlex_quote(command)

    # Switch user with su
    if su_user:
        command = 'su {0} -c {1}'.format(su_user, command)

    # Otherwise just sh wrap the command
    else:
        command = 'sh -c {0}'.format(command)

    # Use sudo (w/user?)
    if sudo:
        sudo_bits = ['sudo', '-H']

        if preserve_sudo_env:
            sudo_bits.append('-E')

        if sudo_user:
            sudo_bits.extend(('-u', sudo_user))

        command = '{0} {1}'.format(' '.join(sudo_bits), command)

    return command