697 """
698 Verify that the specified user exists on this system, and can execute
699 sudo without being prompted for a password.
700 """
701 testcmd = [SUDO, '-n', '-u', user, TRUE]
702 can_sudo = exists = True
703
704 if user in Cmd.verified_users:
705 return True
706
707 try:
708 _ = getpwnam(user)
709 except KeyError:
710 exists = False
711 logger.info("Warning: user '%s' does not exist.", user)
712 return False
713
714 p = Popen(testcmd)
715 p.wait()
716 if p.returncode is not 0:
717 logger.info("Warning: user '%s' cannot use paswordless sudo.", user)
718 return False
719 else:
720 Cmd.verified_users.append(user)
721
722 return True
723
724
725 def find_tests(testrun, options):
726 """
727 For the given list of pathnames, add files as Tests. For directories,
728 if do_groups is True, add the directory as a TestGroup. If False,
729 recursively search for executable files.
730 """
731
732 for p in sorted(options.pathnames):
733 if os.path.isdir(p):
734 for dirname, _, filenames in os.walk(p):
735 if options.do_groups:
736 testrun.addtestgroup(dirname, filenames, options)
737 else:
|
697 """
698 Verify that the specified user exists on this system, and can execute
699 sudo without being prompted for a password.
700 """
701 testcmd = [SUDO, '-n', '-u', user, TRUE]
702 can_sudo = exists = True
703
704 if user in Cmd.verified_users:
705 return True
706
707 try:
708 _ = getpwnam(user)
709 except KeyError:
710 exists = False
711 logger.info("Warning: user '%s' does not exist.", user)
712 return False
713
714 p = Popen(testcmd)
715 p.wait()
716 if p.returncode is not 0:
717 logger.info("Warning: user '%s' cannot use passwordless sudo.", user)
718 return False
719 else:
720 Cmd.verified_users.append(user)
721
722 return True
723
724
725 def find_tests(testrun, options):
726 """
727 For the given list of pathnames, add files as Tests. For directories,
728 if do_groups is True, add the directory as a TestGroup. If False,
729 recursively search for executable files.
730 """
731
732 for p in sorted(options.pathnames):
733 if os.path.isdir(p):
734 for dirname, _, filenames in os.walk(p):
735 if options.do_groups:
736 testrun.addtestgroup(dirname, filenames, options)
737 else:
|