Exemple #1
0
    def decorated(self):
        pool = Pool(processes=1)
        with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as server:
            server.bind(('127.0.0.1', 0))

            with radius.connect(server.getsockname(), 'secret') as client:
                return fn(
                    self,
                    client,
                    pool.apply_async(read, (server,))
                )
Exemple #2
0
parser.add_argument(
    '--password',
    default='garbage',
    help='Auth password'
)

args = parser.parse_args()

# Nagios exit codes
OK = 0
WARNING = 1
CRITICAL = 2
UNKNOWN = 3

with radius.connect((args.host, args.port), args.secret, args.timeout) as conn:
    result = None
    try:
        result = conn.authenticate(args.username, args.password)
    except Exception as e:
        print('CRITICAL: Authentication failed: {error}'.format(
            error=str(e)
        ))
        exit(CRITICAL)

    if not result:
        print('WARNING: Authentication failed')
        exit(WARNING)

    print('OK: Authentication success')
    exit(OK)