If petitboot,password exists set it as the root password. This will be
the password used to authenticate clients.
This is the *hash* of a password as it would appear in /etc/shadow, not
the password itself.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
#include <list/list.h>
#include <log/log.h>
#include <process/process.h>
#include <list/list.h>
#include <log/log.h>
#include <process/process.h>
+#include <crypt/crypt.h>
#include "hostboot.h"
#include "platform.h"
#include "hostboot.h"
#include "platform.h"
static int load_config(struct platform *p, struct config *config)
{
struct platform_powerpc *platform = to_platform_powerpc(p);
static int load_config(struct platform *p, struct config *config)
{
struct platform_powerpc *platform = to_platform_powerpc(p);
int rc;
rc = parse_nvram(platform);
int rc;
rc = parse_nvram(platform);
config_get_active_consoles(config);
config_get_active_consoles(config);
+
+ hash = param_list_get_value(platform->params, "petitboot,password");
+ if (hash) {
+ rc = crypt_set_password_hash(platform, hash);
+ if (rc)
+ pb_log("Failed to set password hash\n");
+ }
+
+static bool restrict_clients(struct platform *p)
+{
+ struct platform_powerpc *platform = to_platform_powerpc(p);
+
+ return param_list_get_value(platform->params, "petitboot,password") != NULL;
+}
+
+static int set_password(struct platform *p, const char *hash)
+{
+ struct platform_powerpc *platform = to_platform_powerpc(p);
+
+ param_list_set(platform->params, "petitboot,password", hash, true);
+ write_nvram(platform);
+
+ return 0;
+}
+
static bool probe(struct platform *p, void *ctx)
{
struct platform_powerpc *platform;
static bool probe(struct platform *p, void *ctx)
{
struct platform_powerpc *platform;
.save_config = save_config,
.pre_boot = pre_boot,
.get_sysinfo = get_sysinfo,
.save_config = save_config,
.pre_boot = pre_boot,
.get_sysinfo = get_sysinfo,
+ .restrict_clients = restrict_clients,
+ .set_password = set_password,
};
register_platform(platform_powerpc);
};
register_platform(platform_powerpc);
"petitboot,console",
"petitboot,http_proxy",
"petitboot,https_proxy",
"petitboot,console",
"petitboot,http_proxy",
"petitboot,https_proxy",