// // Set telnet pw // #include #include #include #include #include "console/cmd_common.h" #include #include #include static int cmd_clear(console_ctx_t *ctx, cmd_signature_t *reg) { EMPTY_CMD_SETUP("Clear access password"); console_printf("Access password cleared.\n"); gSettings.console_pw[0] = 0; settings_persist(SETTINGS_console_pw); return 0; } static int cmd_set(console_ctx_t *ctx, cmd_signature_t *reg) { static struct { struct arg_str *pw; struct arg_end *end; } args; if (reg) { args.pw = arg_str1(NULL, NULL, "", EXPENDABLE_STRING("New password")); args.end = arg_end(1); reg->argtable = &args; reg->help = EXPENDABLE_STRING("Set access password"); return CONSOLE_OK; } strncpy(gSettings.console_pw, args.pw->sval[0], CONSOLE_PW_LEN - 1); console_printf("Access pw set to: \"%.*s\"\n", CONSOLE_PW_LEN, args.pw->sval[0]); settings_persist(SETTINGS_console_pw); return 0; } void register_cmd_pw(void) { console_group_add("pw", "Access password"); console_cmd_register(cmd_set, "pw set"); console_cmd_register(cmd_clear, "pw clear"); }