Código de Google OS.
--------------------------------------------------------------------------------------
GOOGLE_ACCOUNTS_URL = 'https://www.google.com/accounts'
LOGIN_SOURCE = 'test_harness'
class CookieCollectorRedirectHandler(urllib2.HTTPRedirectHandler):
def __init__(self):
self.__cookie_headers = []
@property
def cookie_headers(self):
return self.__cookie_headers
def http_error_302(self, req, fp, code, msg, headers):
self.__cookie_headers.extend(fp.info().getallmatchingheaders('Set-Cookie'))
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp,
code, msg, headers)
return result
def Authenticate(email, password):
opener = urllib2.build_opener()
payload = urllib.urlencode({'Email': email,
'Passwd': password,
'PersistentCookie': 'true',
'accountType' : 'HOSTED_OR_GOOGLE',
'source' : LOGIN_SOURCE})
request = urllib2.Request(GOOGLE_ACCOUNTS_URL + '/ClientLogin', payload)
response = opener.open(request)
data = response.read().rstrip()
# Convert the SID=xxx\nLSID=yyy\n response into a dict.
l = [p.split('=') for p in data.split('\n')]
cookies = dict((i[0], i[1]) for i in l)
payload = urllib.urlencode({'SID': cookies['SID'],
'LSID': cookies['LSID'],
'source': LOGIN_SOURCE,
'service': 'gaia'})
request = urllib2.Request(GOOGLE_ACCOUNTS_URL + '/IssueAuthToken', payload)
response = opener.open(request)
--------------------------------------------------------------------------------------
class PamClient {
public:
/*
* Struct representing the username / password. This is assumed to
* be passed to the callback function
*/
struct UserCredentials {
std::string username;
std::string password;
};
/*
* Calls pam_start and initializes the pam environment
*/
explicit PamClient(UserCredentials* user_credentials);
/*
* Calls pam_end and frees memory
*/
virtual ~PamClient();
/*
* Starts the authentication loop. This initiates the call to the
* pam library and back to the conversation callback before returning
* Returns true on success, false on error
*/
bool Authenticate();
/*
* Sets the credentials obtained from authenticate and starts a session
* with the pam library
*/
bool StartSession();
Y sobre todo, ten paciencia.
Relacionado.
Demasiado "moderno" para mí, que aún ando peleándome con la versión 1.0 del kernel. También muy recomendable el anexo del libro de Tanenbaum con los fuentes de MINIX.
ResponderEliminarsaludos y enhorabuen por el blog ;)
#anónimo, buen apunte!, gracias. :-)
ResponderEliminarAwesome blog, I hadn't noticed www.logadmin.net previously during my searches!
ResponderEliminarContinue the wonderful work!
Thanks for sharing this link, but unfortunately it seems to be offline... Does anybody have a mirror or another source? Please reply to my post if you do!
ResponderEliminarI would appreciate if a staff member here at www.logadmin.net could post it.
Thanks,
Oliver
Hey,
ResponderEliminarThis is a inquiry for the webmaster/admin here at www.logadmin.net.
Can I use part of the information from this post right above if I give a backlink back to your site?
Thanks,
Harry
Hey webmaster I love the blog
ResponderEliminar