--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2023 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <pakfire/buildservice.h>
+
+#include "auth.h"
+#include "command.h"
+#include "pakfire.h"
+
+static const char* args_doc = "USERNAME [OPTIONS...]";
+
+static const char* doc = "Authenticate a user against the build service";
+
+struct cli_local_args {
+ const char* username;
+ const char* password;
+};
+
+static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
+ struct cli_local_args* args = data;
+
+ switch (key) {
+ case ARGP_KEY_ARG:
+ if (!args->username)
+ args->username = arg;
+
+ else if (!args->password)
+ args->password = arg;
+
+ else
+ argp_usage(state);
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+
+ return 0;
+}
+
+int cli_auth(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
+ struct pakfire_buildservice* service = NULL;
+ int r;
+
+ // Parse the command line
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
+ if (r)
+ goto ERROR;
+
+ // Connect to the build service
+ r = cli_setup_buildservice(&service, global_args);
+ if (r < 0)
+ goto ERROR;
+
+ // Authenticate
+ r = pakfire_buildservice_auth_user(service, local_args.username, local_args.password);
+ if (r < 0)
+ goto ERROR;
+
+ERROR:
+ if (service)
+ pakfire_buildservice_unref(service);
+
+ return r;
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2025 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#ifndef PAKFIRE_CLI_AUTH_H
+#define PAKFIRE_CLI_AUTH_H
+
+int cli_auth(void* data, int argc, char* argv[]);
+
+#endif /* PAKFIRE_CLI_AUTH_H */
#include <pakfire/ctx.h>
+#include "lib/auth.h"
#include "lib/client-build.h"
#include "lib/command.h"
#include "lib/config.h"
const char* argp_program_version = PACKAGE_FULLVERSION;
static const struct command commands[] = {
+ { "auth", cli_auth, 2, 2, 0 },
{ "build", cli_client_build, 1, -1, 0 },
{ "repo", cli_repo_client, -1, -1, 0 },
{ "upload", cli_upload, -1, -1, 0 },
};
static const char* args_doc =
+ "auth ...\n"
"repo ...\n"
"upload ...";