static void command_manageauth(client_t *client, source_t *source, int response) { xmlDocPtr doc; xmlNodePtr node, srcnode, msgnode; char *action = NULL; char *username = NULL; char *password = NULL; char *message = NULL; int ret = AUTH_OK; if((COMMAND_OPTIONAL(client, "action", action))) { if (!strcmp(action, "add")) { COMMAND_REQUIRE(client, "username", username); COMMAND_REQUIRE(client, "password", password); ret = auth_adduser(source, username, password); if (ret == AUTH_FAILED) { message = strdup("User add failed - check the icecast error log"); } if (ret == AUTH_USERADDED) { message = strdup("User added"); } if (ret == AUTH_USEREXISTS) { message = strdup("User already exists - not added"); } } if (!strcmp(action, "delete")) { COMMAND_REQUIRE(client, "username", username); ret = auth_deleteuser(source, username); if (ret == AUTH_FAILED) { message = strdup("User delete failed - check the icecast error log"); } if (ret == AUTH_USERDELETED) { message = strdup("User deleted"); } } } doc = xmlNewDoc("1.0"); node = xmlNewDocNode(doc, NULL, "icestats", NULL); srcnode = xmlNewChild(node, NULL, "source", NULL); xmlSetProp(srcnode, "mount", source->mount); if (message) { msgnode = xmlNewChild(node, NULL, "iceresponse", NULL); xmlNewChild(msgnode, NULL, "message", message); } xmlDocSetRootElement(doc, node); auth_get_userlist(source, srcnode); admin_send_response(doc, client, response, MANAGEAUTH_TRANSFORMED_REQUEST); if (message) { free(message); } xmlFreeDoc(doc); client_destroy(client); }
static void init_testuser1(void) { uint64_t user_idnr; if (! (auth_user_exists("testuser1",&user_idnr))) auth_adduser("testuser1","test", "md5", 101, 1024000, &user_idnr); }