}
static int auth_callback(struct pakfire_client* client, void* data) {
- // XXX DEBUG
- return pakfire_client_auth_user(client, "ms", "XXX");
+ struct pakfire_config* config = data;
+ const char* username = NULL;
+ const char* password = NULL;
+
+ // Fetch the credentials from the configuration
+ username = pakfire_config_get(config, "client", "username", NULL);
+ password = pakfire_config_get(config, "client", "password", NULL);
+
+ // Fail if we have no credentials
+ if (!username || !password) {
+ fprintf(stderr, "Client credentials are missing\n");
+ return -EINVAL;
+ }
+
+ // Authenticate!
+ return pakfire_client_auth_user(client, username, password);
}
int cli_setup_client(struct pakfire_client** client, struct cli_global_args* args) {
}
// Set authentication callback
- pakfire_client_set_auth_callback(*client, auth_callback, NULL);
+ pakfire_client_set_auth_callback(*client, auth_callback, config);
ERROR:
if (config)