uint8_t HOSTNAME[1024];
uint8_t HOSTNAME_I[1024];
+uint8_t SQLPASS[1024];
//grabs auth info from the database
uint8_t* getDatabaseInfo(uint8_t type, uint8_t* a, uint8_t* b, uint8_t* c)
{
uint8_t* ret = NULL;
- MYSQL *conn;
- MYSQL_RES *res;
- MYSQL_ROW row;
- conn = mysql_init(NULL);
- FILE *f = fopen("/usr/share/estous/password", "r");
- if (!f)
+ MYSQL *conn;
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ conn = mysql_init(NULL);
+
+ if (!mysql_real_connect(conn, "localhost", HOSTNAME, SQLPASS, "RosadoAPI", 0, NULL, 0))
{
- fprintf(stderr, "Could not open /usr/share/estousapi/password\n");
- exit(1);
+ fprintf(stderr, "%s\n", mysql_error(conn));
+ return NULL;
}
- char* p = malloc(0);
- int c;
- while ( (c = fgetc(f)) != EOF)
-
- if (!mysql_real_connect(conn, "localhost", HOSTNAME, "", "APIService", 0, NULL, 0)) {
- fprintf(stderr, "%s\n", mysql_error(conn));
- return NULL;
- }
if (type == 1)
{
}
}
- uint8_t template[] = "/tmp/apiserviceXXXXXX";
+ uint8_t template[] = "/tmp/rosadoapiXXXXXX";
int8_t fd = mkstemp(template);
if (fd == -1)
{
httpEnd(session_fd);
}
+void get_sqlpass()
+{
+ FILE *f = fopen("/usr/share/rosadoapi/password", "r");
+ if (!f)
+ {
+ fprintf(stderr, "RosadoAPI: Could not access /usr/share/rosadoapi/password\n");
+ exit(1);
+ }
+ int c;
+ int plen = 0;
+ while ( (c = fgetc(f)) != EOF)
+ {
+ if (c == '\n' || c == '\r' || c == ' ') break;
+ SQLPASS[plen++] = c;
+ if (plen == sizeof(SQLPASS) - 2) break;
+ }
+ SQLPASS[plen] = 0;
+}
+
void get_hostname()
{
for (uint8_t i = 0; i <= 1; i++)
void main()
{
get_hostname();
-
+ get_sqlpass();
+
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
conn = mysql_init(NULL);
// Connect to the database
- if (!mysql_real_connect(conn, "localhost", HOSTNAME, "PAAAAAAAAAAAA", "APIService", 0, NULL, 0)) {
+ if (!mysql_real_connect(conn, "localhost", HOSTNAME, SQLPASS, "RosadoAPI", 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
return;
}
- if (mysql_query(conn, "select 1 from information_schema.tables where table_schema='APIService' and table_name='AuthInfo' limit 1;"))
+ if (mysql_query(conn, "select 1 from information_schema.tables where table_schema='RosadoAPI' and table_name='AuthInfo' limit 1;"))
{
fprintf(stderr, "%s\n", mysql_error(conn));
return;
}
mysql_free_result(res);
- if (mysql_query(conn, "select 1 from information_schema.tables where table_schema='APIService' and table_name='ServiceInfo' limit 1;"))
+ if (mysql_query(conn, "select 1 from information_schema.tables where table_schema='RosadoAPI' and table_name='ServiceInfo' limit 1;"))
{
fprintf(stderr, "%s\n", mysql_error(conn));
return;