return 0;
}
-int mod_auth(const char* username, const char* password, void** ptr) {
+int mod_auth(const char* username, const char* password, char** ptr) {
*ptr = NULL;
struct ms_db* db = mandshurica_db_open(config->mandshurica_get_param("CookieDB"));
if(db != NULL) {
char* sh = config->mandshurica_sha512(password);
if(strcmp(sh, pwd) == 0) {
free(sh);
+ *ptr = mandshurica_strdup("what");
return MS_AUTH_OK;
}
free(sh);
const char* httppath = (const char*)dlsym((*config->libs)[j]->lib, "mod_http_path");
if(httppath != NULL) {
if(strcmp(httppath, path) == 0) {
- int (*mod_auth)(const char*, const char*, void**) = (int (*)(const char*, const char*, void**))dlsym((*config->libs)[j]->lib, "mod_auth");
+ int (*mod_auth)(const char*, const char*, char**) = (int (*)(const char*, const char*, char**))dlsym((*config->libs)[j]->lib, "mod_auth");
char* usr = mandshurica_parse_form(postbuf, "username");
char* pwd = mandshurica_parse_form(postbuf, "password");
if(usr != NULL && pwd != NULL) {
- void* ptr;
+ char* ptr;
int res = mod_auth(usr, pwd, &ptr);
if(res == MS_AUTH_OK) {
- printf("%llx\n", ptr);
char* type;
uint64_t len;
char* data = NULL;
send(sock, "Content-Length: 0\r\n", 19, 0);
send(sock, "\r\n", 2, 0);
}
+ free(ptr);
} else if(res == MS_AUTH_ERROR) {
send(sock, "HTTP/1.1 400 Bad Request\r\n", 17 + 9, 0);
send(sock, "Connection: keep-alive\r\n", 24, 0);