Merge pull request 'If unedited, backend will run file/application, if edited, ublexec will' (#56) from YanTheKaller/ublexec:master into master

Reviewed-on: #56
master v2.31
Dmitry Razumov 2 years ago
commit 1f54076d86

@ -1169,7 +1169,6 @@ int yon_config_remove_element(char *key, char *deleted){
new_data = yon_char_append(new_data,found+strlen(deleted));
}
dict->data=(void*)(new_data);
// free(data);
dict->flag1=1;
return 1;
} else return 0;
@ -1296,7 +1295,6 @@ config_str yon_config_load(char *command, int *str_len){
if (strcmp(str, "") != 0)
{
output_strings = realloc(output_strings, sizeof(char *) * (i + 1));
// printf("%s\n", str);
output_strings[i] = NULL;
output_strings[i] = yon_char_new(str);
memset(str, 0, 4096);

@ -180,14 +180,14 @@ void on_setup_command(GtkWidget *self, main_window *widgets){
int su_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck));
int sudo_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck));
int priority_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck));
char *priority = priority_check ? yon_char_append(" -p ",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin)))) : "";
char *priority = priority_check ? yon_char_append(" --priority=",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin)))) : "";
int size;
char *command = yon_char_unite(get_run_command_command,
terminal_check ? yon_char_append(" -t ", terminal->name_simple) : "",
user_check ? yon_char_append(" -u ", user) : "",
user_check&&pkexec_check ? " -e pkexec" : "",
user_check&&su_check ? " -e su" : "",
user_check&&sudo_check ? " -e sudo" : "",
char *command = yon_char_unite(get_run_command_command, " -o",
terminal_check ? yon_char_append(" --terminal=", terminal->name_simple) : "",
user_check ? yon_char_append(" --user=", user) : "",
user_check&&pkexec_check ? " --exec=pkexec" : "",
user_check&&su_check ? " --exec=su" : "",
user_check&&sudo_check ? " --exec=sudo" : "",
priority_check ? priority : "",
yon_char_append(" ",target),
NULL);
@ -199,8 +199,38 @@ void on_setup_command(GtkWidget *self, main_window *widgets){
}
void on_command_run(GtkWidget *self, main_window *widgets){
const char *command = gtk_entry_get_text(GTK_ENTRY(widgets->commandEntry));
yon_launch_thread((char*)command);
if (strcmp(gtk_entry_get_text(GTK_ENTRY(widgets->commandEntry)),"")){
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->commandCheck))){
const char *command = gtk_entry_get_text(GTK_ENTRY(widgets->commandEntry));
yon_launch_thread((char*)command);
} else {
char *target = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->TargetNameEntry));
if (target&&strcmp(target,"")){
char *final_command;
int terminal_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck));
int chosen_terminal = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithTerminalCombo));
terminal_info *terminal = yon_dictionary_get_data(yon_dictionary_get_nth(main_config.terminals,chosen_terminal),terminal_info*);
int user_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserCheck));
char *user = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->runWithUserCombo));
int pkexec_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserPkexecCheck));
int su_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck));
int sudo_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck));
int priority_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck));
char *priority = priority_check ? yon_char_append(" --priority=",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin)))) : "";
int size;
char *command = yon_char_unite(get_run_command_command,
terminal_check ? yon_char_append(" --terminal=", terminal->name_simple) : "",
user_check ? yon_char_append(" --user=", user) : "",
user_check&&pkexec_check ? " --exec=pkexec" : "",
user_check&&su_check ? " --exec=su" : "",
user_check&&sudo_check ? " --exec=sudo" : "",
priority_check ? priority : "",
yon_char_append(" ",target),
NULL);
yon_launch(command);
}
}
}
}
// standard functions

@ -27,7 +27,7 @@
#define get_user_id_max_command "grep \"^UID_MAX\" /etc/login.defs | sed -e 's/\t/ /g' -e 's/ */ /g'|grep -oE \"[0-9]{1,}\""
#define get_users_command "getent passwd |cut -d: -f1,3"
#define get_terminals_info_command "ublexec-cli -l|sed -e 's/\t/ /g' -e 's/^ *//g' -e 's/ */:/g'|cut -d':' -f1,2,3"
#define get_run_command_command "ublexec-cli -q -o"
#define get_run_command_command "ublexec-cli -q"
#define LocalePath "/usr/share/locale"
#define LocaleName "ublexec"

Loading…
Cancel
Save