|
|
|
|
@ -333,6 +333,7 @@ void MainWindow::settings() {
|
|
|
|
|
lblTime4EpriorityHigh->set_text("0 (Высокий)");
|
|
|
|
|
scalePriority->set_inverted(true);
|
|
|
|
|
this->pars_dir_bin();
|
|
|
|
|
this->is_user_wheel();
|
|
|
|
|
this->pars_users();
|
|
|
|
|
this->activ_or_block_execute_epriority();
|
|
|
|
|
this->changed_user();
|
|
|
|
|
@ -455,7 +456,7 @@ string MainWindow::start_cmd(string user_cmd) {
|
|
|
|
|
string str_nice_cmd = "";
|
|
|
|
|
if (chbAnotherUser->get_active()) {
|
|
|
|
|
if (rbPkexec->get_active()) {
|
|
|
|
|
str_variants_root = " pkexec --user " + cmbUser->get_active_text();
|
|
|
|
|
str_variants_root = "pkexec --user " + cmbUser->get_active_text();
|
|
|
|
|
if (cbxExecuteEpriority->get_active()) {
|
|
|
|
|
str_variants_root += " nice -n " + to_string(spinPriority->get_value_as_int());
|
|
|
|
|
}
|
|
|
|
|
@ -470,18 +471,19 @@ string MainWindow::start_cmd(string user_cmd) {
|
|
|
|
|
else{
|
|
|
|
|
str_variants_root = "su ";
|
|
|
|
|
}
|
|
|
|
|
str_variants_root += + " -c \" DISPLAY=$DISPLAY ";
|
|
|
|
|
str_variants_root += " -c \" DISPLAY=$DISPLAY ";
|
|
|
|
|
if (cbxExecuteEpriority->get_active()) {
|
|
|
|
|
str_variants_root += "nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (rbSudo->get_active()) {
|
|
|
|
|
chbTerminal->set_active(true);
|
|
|
|
|
if (getlogin()==cmbUser->get_active_text()) {
|
|
|
|
|
str_variants_root="sudo ";
|
|
|
|
|
//if (getlogin()==cmbUser->get_active_text()) {
|
|
|
|
|
if (user_exec_app==cmbUser->get_active_text()) {
|
|
|
|
|
str_variants_root = "sudo ";
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
str_variants_root="sudo -u " + cmbUser->get_active_text() + " ";
|
|
|
|
|
str_variants_root = "sudo -u " + cmbUser->get_active_text() + " ";
|
|
|
|
|
}
|
|
|
|
|
if (cbxExecuteEpriority->get_active()) {
|
|
|
|
|
str_variants_root += " nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
|
|
|
|
|
@ -562,6 +564,24 @@ void MainWindow::denamic_cmd() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string MainWindow::call(string cmd) {
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int status;
|
|
|
|
|
char path[PATH_MAX] = {0};
|
|
|
|
|
fp = popen(cmd.c_str(), "r");
|
|
|
|
|
if (fp == NULL) {
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
while (fgets(path, PATH_MAX, fp) != NULL) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
status = pclose(fp);
|
|
|
|
|
if (status == -1) {
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event) {
|
|
|
|
|
if (cmd_old != txtCmd->get_text()) {
|
|
|
|
|
user_cmd = txtCmd->get_text();
|
|
|
|
|
@ -645,6 +665,17 @@ void MainWindow::pars_dir_bin() {
|
|
|
|
|
rbSudo->set_sensitive(flag_sudo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::is_user_wheel(){
|
|
|
|
|
string response = this->call("id -Gn");
|
|
|
|
|
if (response.find("wheel") == string::npos){
|
|
|
|
|
rbSudo->set_sensitive(false);
|
|
|
|
|
}
|
|
|
|
|
size_t user_index = response.find(" ");
|
|
|
|
|
if (user_index!=string::npos){
|
|
|
|
|
user_exec_app = response.substr(0, user_index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::pars_users() {
|
|
|
|
|
while (true) {
|
|
|
|
|
errno = 0;
|
|
|
|
|
|