Исправлено получение uid_min и uid_max, исправлен дизайн

pull/17/head
Igor Belitskiy 3 years ago
parent 88fb010983
commit 630ee034e7

@ -722,7 +722,6 @@ void MainWindow::entry_app() {
void MainWindow::activ_or_block_other_user() {
bool flag = chbAnotherUser->get_active();
cmbUser->set_active(0);
cmbUser->set_sensitive(flag);
lblInfoUserName->set_sensitive(flag);
if (flag_pkexec == true) {
@ -800,6 +799,47 @@ void MainWindow::is_user_wheel(){
}
}
unsigned short MainWindow::read_uid_min_max(string filename, string search){
std::string line;
int uid = 0;
string remove_tab = "\t";
string remove_space = " ";
std::ifstream in(filename); // окрываем файл для чтения
if (in.is_open()){
while (getline(in, line)){
try{
if (line.find(search) != string::npos && (line.find("SYS_"+search) == string::npos)) {
this->str_remove(line, search);
this->str_remove(line, remove_space);
this->str_remove(line, remove_tab);
uid = atoi(line.c_str());
}
}
catch (int x) {
if (search == "UID_MIN"){
uid = 1000;
}
else{
uid = 65534;
}
}
}
}
else{
if (search == "UID_MIN") {
uid = 1000;
}
else{
uid = 65534;
}
}
in.close();
return uid;
}
void MainWindow::pars_users() {
//string str_uid_max = this->call("grep \"^UID_MAX\" /etc/login.defs | xargs | cut -d ' ' -f 2)");
//int uid_max = 0;
@ -807,8 +847,9 @@ void MainWindow::pars_users() {
// int uid_max = stoi(str_uid_max);
//}
//else{
int uid_max = 65534;
//}
unsigned short uid_min = this->read_uid_min_max("/etc/login.defs", "UID_MIN");
unsigned short uid_max = this->read_uid_min_max("/etc/login.defs", "UID_MAX");
while (true) {
errno = 0;
passwd* entry = getpwent();

@ -15,6 +15,7 @@
#include <ostream>
#include <thread>
#include <algorithm>
#include <fstream>
#include "ubl-util-standard.c"
using namespace std;
@ -93,6 +94,7 @@ public:
bool focus_in_txt_cmd(GdkEventFocus* event);
void unselect_icon(Gtk::IconView *icon_entry);
void pars_dir_terminal();
unsigned short read_uid_min_max(string filename, string search);
void str_remove(std::string& source, std::string & to_remove);
string call(string cmd);
vector<std::string> split(const std::string &s, char delim);

@ -1133,7 +1133,7 @@ specified priority</property>
</child>
<child>
<object class="GtkEntry" id="txtCmd">
<property name="width-request">381</property>
<property name="width-request">440</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-left">5</property>
@ -1279,7 +1279,7 @@ specified priority</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-left">9</property>
<property name="margin-left">2</property>
<property name="margin-right">5</property>
<property name="margin-end">5</property>
<property name="margin-bottom">6</property>
@ -1398,6 +1398,7 @@ specified priority</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="margin-left">6</property>
<property name="draw-indicator">True</property>
<property name="group">rbSu</property>
</object>
@ -1413,6 +1414,10 @@ specified priority</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="margin-left">6</property>
<property name="margin-right">6</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="draw-indicator">True</property>
<property name="group">rbPkexec</property>
</object>
@ -1428,6 +1433,10 @@ specified priority</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="margin-left">6</property>
<property name="margin-right">6</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="draw-indicator">True</property>
<property name="group">rbSu</property>
</object>
@ -1489,7 +1498,7 @@ specified priority</property>
</child>
<child>
<object class="GtkComboBoxText" id="cmbUser">
<property name="width-request">381</property>
<property name="width-request">374</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>

Loading…
Cancel
Save