so all i want is a smaal program wich is called in command line:
and then it waits for username and password
and it should return OK or ERR
it should only check one username and password and it would be hardcoded in it
so I have somthing like this (parts of it stolen from somewhere):
Code:
#!/usr/bin/python
import sys
import socket
def matchpasswd(login, password):
if login == "user" and password == "passwd":
x = 1
else:
x = 0
while True:
line = sys.stdin.readline()
line = sys.stdin.strip()
username = line[:line.find(' ')]
password = line[line.fine(' ')+1:]
if matchpasswd(username, password):
sys.stdout.write('OK\n')
else:
sys.stdout.write('ERR\n')
sys.stdout.flush()
but when running it gives this:
Code:
root@monstrs:/etc/squid# ./custom_auth.py
Traceback (most recent call last):
File "./custom_auth.py", line 16, in <module>
line = sys.stdin.strip()
AttributeError: 'file' object has no attribute 'strip'
root@monstrs:/etc/squid#
i don't even supply a username and password, just pressed enter, the same if isuply a user