chrome/updater/test/service/win/rpc_handler.py
def AnswerUpcomingUACPrompt(self,
                              actions,
                              timeout=10,
                              wait_child=False,
                              source=''):
    """Answers upcoming UAC prompt that does not require username/password.

    Args:
      actions: Actions to take in string, such as 'AADDA', 'A' to accept,
          'D' to deny.
      timeout: How long the child process should wait for each UAC click.
      wait_child: Whether this thread should wait the completion of child proc.
      source: Optional name of the source that triggers this action (for logging
          and debugging purpose).

    Returns:
      (pid, exit_code) of the created UAC-answering process. If the sub-process
      is not created, or did not finish in wait time, returns (None, None).
    """
    uac_tool = os.path.join(os.path.dirname(__file__), 'answer_uac.py')
    command = ('python %s --actions=%s --timeout=%d --source=%s' %
               (uac_tool, actions, timeout, source))
    logging.info('Running command: %s', command)

    if wait_child:
      if timeout > 0:
        # Each button click could take `timeout` seconds, and add 1 second
        # extra for child process to finish.
        timeout = timeout * len(actions) + 1
      else:
        # Negative timeout has special meanings, such as win32event.INFINITE.
        # Don't touch it.
        pass
    else:
      timeout = 0  # no wait

    # There could be multiple winlogon.exe instances when there are multiple
    # login sessions. For example, when there's remote desktop session. In this
    # case, find the active session where the UAC prompt is supposed to display.
    winlogon_pids = proc_util.GetPIDsWithName('winlogon.exe',
                                              proc_util.GetActiveSessionID())
    if not winlogon_pids:
      logging.error('Unexpected: no active session or no winlogon.exe in it.')
      return (None, None)
    elif len(winlogon_pids) > 1:
      logging.warning('Unexpected multiple winlogon.exe instances within '
                      'active session, the first instance will be used.')

    # Must spawn child process on the same desktop as the one that UAC prompts,
    # otherwise the child process will not be able to find the UAC dialog.
    # Please note that there is a slight race condition here as user could
    # change UAC desktop at any time. But we can tolerate this for the testing
    # purpose.
    desktop = 'winlogon' if uac.IsPromptingOnSecureDesktop() else 'default'

    logging.info('Spawn process [%s] for UAC on desktop [%s].',
                 command, desktop)
    pid, exit_code, stdout, stderr = impersonate.RunAsPidOnDeskstop(
        command, winlogon_pids[0], desktop=desktop, timeout=timeout)
    logging.info('Process [%s] is created to answer UAC, exit_code: %s', pid,
                 exit_code)
    if stdout and stdout.strip():
      logging.info('STDOUT: [%s]', stdout)
    if stderr and stderr.strip():
      logging.error('STDERR: [%s]', stderr)
    return (pid, exit_code)
Answers upcoming UAC prompt that does not require username/password.

    Args:
      actions: Actions to take in string, such as 'AADDA', 'A' to accept,
          'D' to deny.
      timeout: How long the child process should wait for each UAC click.
      wait_child: Whether this thread should wait the completion of child proc.
      source: Optional name of the source that triggers this action (for logging
          and debugging purpose).

    Returns:
      (pid, exit_code) of the created UAC-answering process. If the sub-process
      is not created, or did not finish in wait time, returns (None, None).
    
Answers upcoming UAC prompt that does not require username/password.
Answers upcoming UAC prompt that does not require username / password .
def AnswerUpcomingUACPrompt(self,
                              actions,
                              timeout=10,
                              wait_child=False,
                              source=''):
    uac_tool = os.path.join(os.path.dirname(__file__), 'answer_uac.py')
    command = ('python %s --actions=%s --timeout=%d --source=%s' %
               (uac_tool, actions, timeout, source))
    logging.info('Running command: %s', command)
    if wait_child:
      if timeout > 0:
        timeout = timeout * len(actions) + 1
      else:
        pass
    else:
      timeout = 0  
    winlogon_pids = proc_util.GetPIDsWithName('winlogon.exe',
                                              proc_util.GetActiveSessionID())
    if not winlogon_pids:
      logging.error('Unexpected: no active session or no winlogon.exe in it.')
      return (None, None)
    elif len(winlogon_pids) > 1:
      logging.warning('Unexpected multiple winlogon.exe instances within '
                      'active session, the first instance will be used.')
    desktop = 'winlogon' if uac.IsPromptingOnSecureDesktop() else 'default'
    logging.info('Spawn process [%s] for UAC on desktop [%s].',
                 command, desktop)
    pid, exit_code, stdout, stderr = impersonate.RunAsPidOnDeskstop(
        command, winlogon_pids[0], desktop=desktop, timeout=timeout)
    logging.info('Process [%s] is created to answer UAC, exit_code: %s', pid,
                 exit_code)
    if stdout and stdout.strip():
      logging.info('STDOUT: [%s]', stdout)
    if stderr and stderr.strip():
      logging.error('STDERR: [%s]', stderr)
    return (pid, exit_code)
def AnswerUpcomingUACPrompt ( self , actions , timeout = 10 , wait_child = False , source = '' ) : uac_tool = os . path . join ( os . path . dirname ( __file__ ) , 'answer_uac.py' ) command = ( 'python %s --actions=%s --timeout=%d --source=%s' % ( uac_tool , actions , timeout , source ) ) logging . info ( 'Running command: %s' , command ) if wait_child : if timeout > 0 : timeout = timeout * len ( actions ) + 1 else : pass else : timeout = 0 winlogon_pids = proc_util . GetPIDsWithName ( 'winlogon.exe' , proc_util . GetActiveSessionID ( ) ) if not winlogon_pids : logging . error ( 'Unexpected: no active session or no winlogon.exe in it.' ) return ( None , None ) elif len ( winlogon_pids ) > 1 : logging . warning ( 'Unexpected multiple winlogon.exe instances within ' 'active session, the first instance will be used.' ) desktop = 'winlogon' if uac . IsPromptingOnSecureDesktop ( ) else 'default' logging . info ( 'Spawn process [%s] for UAC on desktop [%s].' , command , desktop ) pid , exit_code , stdout , stderr = impersonate . RunAsPidOnDeskstop ( command , winlogon_pids [ 0 ] , desktop = desktop , timeout = timeout ) logging . info ( 'Process [%s] is created to answer UAC, exit_code: %s' , pid , exit_code ) if stdout and stdout . strip ( ) : logging . info ( 'STDOUT: [%s]' , stdout ) if stderr and stderr . strip ( ) : logging . error ( 'STDERR: [%s]' , stderr ) return ( pid , exit_code )
Answers upcoming UAC prompt that does not require username/password.
Answers upcoming UAC prompt that does not require username / password .
"""Answers upcoming UAC prompt that does not require username/password.

    Args:
      actions: Actions to take in string, such as 'AADDA', 'A' to accept,
          'D' to deny.
      timeout: How long the child process should wait for each UAC click.
      wait_child: Whether this thread should wait the completion of child proc.
      source: Optional name of the source that triggers this action (for logging
          and debugging purpose).

    Returns:
      (pid, exit_code) of the created UAC-answering process. If the sub-process
      is not created, or did not finish in wait time, returns (None, None).
    """ # Each button click could take `timeout` seconds, and add 1 second # extra for child process to finish. # Negative timeout has special meanings, such as win32event.INFINITE. # Don't touch it. # no wait # There could be multiple winlogon.exe instances when there are multiple # login sessions. For example, when there's remote desktop session. In this # case, find the active session where the UAC prompt is supposed to display. # Must spawn child process on the same desktop as the one that UAC prompts, # otherwise the child process will not be able to find the UAC dialog. # Please note that there is a slight race condition here as user could # change UAC desktop at any time. But we can tolerate this for the testing # purpose.
(pid, exit_code) of the created UAC-answering process. If the sub-process
is not created, or did not finish in wait time, returns (None, None).
( pid exit_code ) of the created UAC - answering process . If the sub - process is not created or did not finish in wait time returns ( None None ) .
self
actions
Actions to take in string, such as 'AADDA', 'A' to accept,
'D' to deny.
Actions to take in string such as ' AADDA ' ' A ' to accept ' D ' to deny .
timeout
None
wait_child
Whether this thread should wait the completion of child proc.
Whether this thread should wait the completion of child proc .
source
Optional name of the source that triggers this action (for logging
and debugging purpose).
Optional name of the source that triggers this action ( for logging and debugging purpose ) .