Исправлена логика comboBox "Имя пользователя меню загрузки:" и "Пароль пользователя меню загрузки:"

pull/11/head
Igor Belitskiy 3 years ago
parent a02a270030
commit f83ed53d20

@ -234,31 +234,36 @@ void MainWindow::set_download_mode(string cmd="") {
map_cmd_selection["GRUB_BOOT_SILENT"] = key;
}
void MainWindow::set_security_login(string cmd="") {
void MainWindow::set_security_login(string cmd = "", string cmd_remove = "") {
int index = chbSecurityLogin->get_active_row_number();
string key = "";
if (index == 0){
// TODO:
// Не правильно
key = "superadmin";
if (index == 0) {
key = "";
if (cmd_remove.length() != 0) {
wrapper_system(cmd_remove, "");
}
else {
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
}
}
else if (index == 1) {
key = entrySecurityLogin->get_text();
if (cmd.length() != 0) {
entrySecurityLogin->set_text(key);
cmd = cmd + "\"" + key + "\"";
wrapper_system(cmd, "");
}
else {
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
}
}
else if (index == -1) {
return;
}
if (cmd.length() != 0) {
entrySecurityLogin->set_text(key);
cmd = cmd + "\"" + key + "\"";
wrapper_system(cmd, "");
}
else {
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
}
map_cmd_selection["GRUB_USER"] = key;
}
@ -271,16 +276,11 @@ void MainWindow::get_security_login(string cmd, std::map <string, string> &map_t
if (res_response.error == 0) {
str_replace_all(res_response.response, " ","");
str_replace_all(res_response.response, "\"","");
entrySecurityLogin->set_text(res_response.response);
if (res_response.response != default_login) {
if (res_response.response.length() > 0) {
chbSecurityLogin->set_active(1);
entrySecurityLogin->set_sensitive(true);
map_temp["GRUB_USER"] = res_response.response;
}
else if (res_response.response == default_login) {
chbSecurityLogin->set_active(0);
map_temp["GRUB_USER"] = default_login;
entrySecurityLogin->set_sensitive(true);
entrySecurityLogin->set_text(res_response.response);
}
else {
chbSecurityLogin->set_active(-1);
@ -289,11 +289,13 @@ void MainWindow::get_security_login(string cmd, std::map <string, string> &map_t
}
}
else if (res_response.error == 3) {
chbSecurityLogin->set_active(-1);
map_temp["GRUB_USER"] = "";
if (start_error != index_error) {
index_error = start_error;
}
chbSecurityLogin->set_active(0);
entrySecurityLogin->set_text("");
entrySecurityLogin->set_sensitive(false);
}
else {
chbSecurityLogin->set_active(-1);
@ -302,37 +304,35 @@ void MainWindow::get_security_login(string cmd, std::map <string, string> &map_t
}
void MainWindow::set_password_protec(string cmd = "", string cmd_remove = "") {
// TODO:
// Не работает
int index = chbPasswordProtecc->get_active_row_number();
string key = "";
if (index == 0){
key = "";
if (cmd_remove.length() != 0) {
wrapper_system(cmd_remove, "");
}
else {
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
}
}
else if (index == 1) {
key = entryPasswordProtecc->get_text();
}
else if (index == 2) {
key = "";
if (cmd_remove.length() != 0) {
wrapper_system(cmd_remove, "");
if (cmd.length() != 0) {
entryPasswordProtecc->set_text(key);
cmd = cmd + "\"" + key + "\"";
wrapper_system(cmd, "");
}
else {
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
}
cmd = "";
}
else if (index == -1) {
return;
}
if (cmd.length() != 0 && cmd_remove.length() != 0) {
entryPasswordProtecc->set_text(key);
cmd = cmd + key;
wrapper_system(cmd, "");
}
else {
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
}
map_cmd_selection["GRUB_PASSWORD"] = key;
}
@ -341,16 +341,11 @@ void MainWindow::get_password_protec(string cmd, std::map <string, string> &map_
struct Result<string> res_response = this->wrapper_call(cmd);
if (res_response.error == 0) {
str_replace_all(res_response.response, "\"","");
entryPasswordProtecc->set_text(res_response.response);
// TODO:
// Не работает
if (res_response.response == getlogin()) {
chbPasswordProtecc->set_active(0);
map_temp["GRUB_PASSWORD"] = "";
}
else if (res_response.response.length() != 0) {
// entryPasswordProtecc->set_text(res_response.response);
if (res_response.response.length() != 0) {
chbPasswordProtecc->set_active(1);
map_temp["GRUB_PASSWORD"] = "";
map_temp["GRUB_PASSWORD"] = res_response.response;
entryPasswordProtecc->set_text("");
entryPasswordProtecc->set_sensitive(true);
}
else{
@ -358,8 +353,8 @@ void MainWindow::get_password_protec(string cmd, std::map <string, string> &map_
chbPasswordProtecc->set_active(-1);
}
}
else if (res_response.error == 3 && res_response.response.find("null") != string::npos) {
chbPasswordProtecc->set_active(2);
else if (res_response.error == 3) {
chbPasswordProtecc->set_active(0);
map_temp["GRUB_PASSWORD"] = "";
entryPasswordProtecc->set_text("");
if (start_error != index_error) {
@ -727,10 +722,7 @@ void MainWindow::change_security_login() {
int index = chbSecurityLogin->get_active_row_number();
if (index == 0) {
entrySecurityLogin->set_sensitive(false);
// TODO:
// Добавить заполнение логина по умолчанию
string default_login = "superadmin";
entrySecurityLogin->set_text(default_login);
entrySecurityLogin->set_text("");
boxSave->set_sensitive(true);
}
else if (index == 1) {
@ -826,7 +818,9 @@ bool MainWindow::save_global_cfg() {
flag_no_save = false;
}
if (this->check_save(flag_save, "GRUB_USER")) {
this->set_security_login("ubconfig --target global set boot GRUB_USER=");
string cmd_login = "ubconfig --target global set boot GRUB_USER=";
string cmd_remove_login = "ubconfig --target system remove boot GRUB_USER";
this->set_security_login(cmd_login, cmd_remove_login);
flag_no_save = false;
}
if (this->check_save(flag_save, "GRUB_PASSWORD")) {
@ -886,7 +880,9 @@ bool MainWindow::save_local_cfg() {
flag_no_save = false;
}
if (this->check_save(flag_save, "GRUB_USER")) {
this->set_security_login("ubconfig --target system set boot GRUB_USER=");
string cmd_login = "ubconfig --target system set boot GRUB_USER=";
string cmd_remove_login = "ubconfig --target system remove boot GRUB_USER";
this->set_security_login(cmd_login, cmd_remove_login);
flag_no_save = false;
}
if (this->check_save(flag_save, "GRUB_PASSWORD")) {

@ -171,7 +171,7 @@ class MainWindow : public Gtk::ApplicationWindow {
bool focus_out_txt_IPT(GdkEventFocus*);
bool focus_out_txt_OTT(GdkEventFocus*);
void fill_in_view();
void set_security_login(string cmd);
void set_security_login(string cmd, string cmd_remove);
void get_security_login(string cmd, std::map <string, string> &map_temp);
bool check_flag_save(string flag_save);
void set_download_mode(string cmd);

@ -43,9 +43,6 @@ msgstr "Отсутствие анимации загрузки с выводом
msgid "Lack of loading animation with the output of the abbreviated log"
msgstr "Отсутствие анимации загрузки с выводом сокращенного журнала"
msgid "Load screen display mode:"
msgstr "Режим отображения экрана загрузки:"
msgid "Download menu user name:"
msgstr "Имя пользователя меню загрузки:"

Loading…
Cancel
Save