|
|
|
|
@ -6,10 +6,48 @@ config main_config;
|
|
|
|
|
|
|
|
|
|
int yon_load_proceed(YON_CONFIG_TYPE type){
|
|
|
|
|
yon_config_load_register(YON_CONFIG_DEFAULT,"users","DEFAULTPASSWD DEFAULTROOTPASSWD USERGROUPS DEFAULTUSER HASHPASSWD ADDADM",NULL);
|
|
|
|
|
if (yon_config_load_register_no_cleaning(type,"users","DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]","[system]","SYSTEMBOOT_STATEMODE","[save]","SAVE_ROOTCOPY_CHANGES",NULL)){
|
|
|
|
|
yon_config_load_register_no_cleaning(type,"users","DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]","[system]","SYSTEMBOOT_STATEMODE","[save]","SAVE_ROOTCOPY_CHANGES",NULL);
|
|
|
|
|
if (type!=YON_CONFIG_GLOBAL){
|
|
|
|
|
yon_config_load_register_no_cleaning(YON_CONFIG_GLOBAL,"users","DEFAULTPASSWD DEFAULTROOTPASSWD",NULL);
|
|
|
|
|
}
|
|
|
|
|
if (type==YON_CONFIG_LOCAL){
|
|
|
|
|
int size;
|
|
|
|
|
config_str passwords = yon_config_load(get_passwords_command,&size);
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
char *key, *value;
|
|
|
|
|
if (yon_config_parse_parameter(passwords[i],&key, &value)){
|
|
|
|
|
int parsed_size;
|
|
|
|
|
char *local_value = yon_config_get_by_key(key);
|
|
|
|
|
config_str parsed = yon_char_parse(value,&parsed_size,":");
|
|
|
|
|
if (strstr(key,"USERADD[")){
|
|
|
|
|
if (parsed_size>5){
|
|
|
|
|
char *temp = yon_char_append(local_value,parsed[5]);
|
|
|
|
|
free(local_value);
|
|
|
|
|
local_value=temp;
|
|
|
|
|
yon_config_set(key,yon_char_new(local_value));
|
|
|
|
|
yon_config_set_status(key,0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (strstr(key,"GROUPADD[")){
|
|
|
|
|
if (parsed_size>4){
|
|
|
|
|
char *temp = yon_char_append(local_value,parsed[4]);
|
|
|
|
|
free(local_value);
|
|
|
|
|
local_value=temp;
|
|
|
|
|
yon_config_set(key,yon_char_new(local_value));
|
|
|
|
|
yon_config_set_status(key,0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,parsed_size);
|
|
|
|
|
free(key);
|
|
|
|
|
free(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -34,13 +72,13 @@ void yon_interface_update(main_window *widgets){
|
|
|
|
|
login = yon_char_divide_search(parameters[0],"=",-1);
|
|
|
|
|
login[strlen(login)-1]='\0';
|
|
|
|
|
}
|
|
|
|
|
if (!strcmp(parameters[1],"x")) parameters[1]=AUTOMATICALLY_LABEL;
|
|
|
|
|
if (!strcmp(parameters[2],"x")) parameters[2]=login;
|
|
|
|
|
if (parameters_size>1&&!strcmp(parameters[1],"x")) parameters[1]=AUTOMATICALLY_LABEL;
|
|
|
|
|
if (parameters_size>2&&!strcmp(parameters[2],"x")) parameters[2]=login;
|
|
|
|
|
gtk_list_store_set(widgets->UsersList,&iter,
|
|
|
|
|
2,login,
|
|
|
|
|
3,parameters_size>0?parameters[0]:"",
|
|
|
|
|
1,parameters_size>1?parameters[1]:"",
|
|
|
|
|
4,parameters_size>2?parameters[2]:"",
|
|
|
|
|
1,parameters_size>1&&!yon_char_is_empty(parameters[1])?parameters[1]:AUTOMATICALLY_LABEL,
|
|
|
|
|
4,parameters_size>2&&!yon_char_is_empty(parameters[2])?parameters[2]:login,
|
|
|
|
|
5,parameters_size>3?!strcmp(parameters[3],"x")||!strcmp(parameters[3],"")?def_groups:parameters[3]:def_groups,
|
|
|
|
|
6,parameters_size>4?parameters[4]:"",
|
|
|
|
|
7,parameters_size>5?strcmp(parameters[5],"x")&&strcmp(parameters[5],"")? parameters[5][0]=='%'&¶meters[5][1]=='%'? UNENCRYPTED_LABEL: ENCRYPTED_LABEL : DEFAULT_USER_LABEL : DEFAULT_USER_LABEL,
|
|
|
|
|
@ -136,57 +174,91 @@ void yon_hide_passwords(template_saving_window *window){
|
|
|
|
|
char *new_value;
|
|
|
|
|
gtk_tree_model_get(model,&iter,1,&name,2,&old_value,3,&new_value,-1);
|
|
|
|
|
if (strstr(name,"USERADD[")){
|
|
|
|
|
int size;
|
|
|
|
|
config_str parsed = yon_char_parse(new_value,&size,":");
|
|
|
|
|
if (size>5 &&parsed[5][0] !='$'&&parsed[5][0]!='%'){
|
|
|
|
|
parsed[5]="******";
|
|
|
|
|
char *new_compare = yon_char_unite(!yon_char_is_empty(old_value)?"<s>":"",!yon_char_is_empty(old_value)?old_value:"",!yon_char_is_empty(old_value)?"</s>":"","\n",yon_char_parsed_to_string(parsed,size,":"),NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
free(new_compare);
|
|
|
|
|
} else {
|
|
|
|
|
char *new_compare = yon_char_unite(!yon_char_is_empty(old_value)?"<s>":"",!yon_char_is_empty(old_value)?old_value:"",!yon_char_is_empty(old_value)?"</s>":"","\n",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
free(new_compare);
|
|
|
|
|
|
|
|
|
|
char *old=NULL;
|
|
|
|
|
char *newv=NULL;
|
|
|
|
|
int size = 0;
|
|
|
|
|
if (!yon_char_is_empty(new_value)){
|
|
|
|
|
config_str parsed = NULL;
|
|
|
|
|
parsed = yon_char_parse(new_value,&size,":");
|
|
|
|
|
if (size>5&&!yon_char_is_empty(parsed[5])&&strcmp(parsed[5],"x")&&parsed[5][0]!='%'&&parsed[5][1]!='%'){
|
|
|
|
|
free(new_value);
|
|
|
|
|
free(parsed[5]);
|
|
|
|
|
parsed[5]=yon_char_new("*******");
|
|
|
|
|
new_value = yon_char_parsed_to_string(parsed,size,":");
|
|
|
|
|
} else if (size>5&&!yon_char_is_empty(parsed[5])&&strcmp(parsed[5],"x")) {
|
|
|
|
|
free(new_value);
|
|
|
|
|
free(yon_char_divide(parsed[5],1));
|
|
|
|
|
new_value = yon_char_parsed_to_string(parsed,size,":");
|
|
|
|
|
}
|
|
|
|
|
if (parsed){
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!yon_char_is_empty(old_value)){
|
|
|
|
|
old=yon_char_unite("<s>",old_value,"</s>",NULL);
|
|
|
|
|
}
|
|
|
|
|
if(!yon_char_is_empty(new_value)){
|
|
|
|
|
newv=new_value;
|
|
|
|
|
}
|
|
|
|
|
char *new_string = yon_char_unite(!yon_char_is_empty(old)?old:"","\n",!yon_char_is_empty(newv)?newv:"",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_string,-1);
|
|
|
|
|
|
|
|
|
|
} else if (strstr(name,"GROUPADD[")){
|
|
|
|
|
int size;
|
|
|
|
|
char *old=NULL;
|
|
|
|
|
char *newv=NULL;
|
|
|
|
|
int size = 0;
|
|
|
|
|
if (new_value){
|
|
|
|
|
config_str parsed = yon_char_parse(new_value,&size,":");
|
|
|
|
|
if (size>4&&parsed[4][0] !='$'&&parsed[4][0]!='%'){
|
|
|
|
|
parsed[4]="******";
|
|
|
|
|
char *new_compare = yon_char_unite(!yon_char_is_empty(old_value)?"<s>":"",!yon_char_is_empty(old_value)?old_value:"",!yon_char_is_empty(old_value)?"</s>":"","\n",yon_char_parsed_to_string(parsed,size,":"),NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
} else {
|
|
|
|
|
char *new_compare = yon_char_unite(!yon_char_is_empty(old_value)?"<s>":"",!yon_char_is_empty(old_value)?old_value:"",!yon_char_is_empty(old_value)?"</s>":"","\n",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
free(new_compare);
|
|
|
|
|
|
|
|
|
|
free(new_value);
|
|
|
|
|
if (size>4&&!yon_char_is_empty(parsed[4])&&strcmp(parsed[4],"x")&&parsed[4][0]!='%'&&parsed[4][1]!='%'){
|
|
|
|
|
free(parsed[4]);
|
|
|
|
|
parsed[4]=yon_char_new("*******");
|
|
|
|
|
}
|
|
|
|
|
new_value = yon_char_parsed_to_string(parsed,size,":");
|
|
|
|
|
}
|
|
|
|
|
if(!yon_char_is_empty(old_value)){
|
|
|
|
|
old=yon_char_unite("<s>",old_value,"</s>",NULL);
|
|
|
|
|
}
|
|
|
|
|
if(!yon_char_is_empty(new_value)){
|
|
|
|
|
newv=new_value;
|
|
|
|
|
}
|
|
|
|
|
char *new_string = yon_char_unite(!yon_char_is_empty(old)?old:"","\n",!yon_char_is_empty(newv)?newv:"",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_string,-1);
|
|
|
|
|
|
|
|
|
|
} else if (strstr(name,"DEFAULTPASSWD")){
|
|
|
|
|
if (!yon_char_is_empty(new_value) && new_value[0] !='$'&&new_value[0]!='%'){
|
|
|
|
|
char *new_compare = yon_char_unite("<s>",old_value,"</s>\n",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
free(new_compare);
|
|
|
|
|
} else {
|
|
|
|
|
char *new_compare = yon_char_unite("<s>",old_value,"</s>\n",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
free(new_compare);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else if (strstr(name,"DEFAULTPASSWD")){
|
|
|
|
|
char *old=NULL;
|
|
|
|
|
char *newv=NULL;
|
|
|
|
|
if (!yon_char_is_empty(new_value)&&strlen(new_value)>2&&new_value[0]=='%'&&new_value[1]=='%'){
|
|
|
|
|
free(yon_char_divide(new_value,1));
|
|
|
|
|
newv=new_value;
|
|
|
|
|
} else if (!yon_char_is_empty(new_value)&&new_value[0]=='$') {
|
|
|
|
|
newv=new_value;
|
|
|
|
|
}else if (!yon_char_is_empty(new_value)){
|
|
|
|
|
newv="*******";
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(old_value)){
|
|
|
|
|
old = yon_char_unite("<s>",old_value,"</s>",NULL);
|
|
|
|
|
}
|
|
|
|
|
char *new_string = yon_char_unite(!yon_char_is_empty(old)?old:"","\n",!yon_char_is_empty(newv)?newv:"",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_string,-1);
|
|
|
|
|
|
|
|
|
|
} else if (strstr(name,"DEFAULTROOTPASSWD")){
|
|
|
|
|
if (!yon_char_is_empty(new_value) &&new_value[0] !='$'&&new_value[0]!='%'){
|
|
|
|
|
char *new_compare = yon_char_unite("<s>",old_value,"</s>\n******",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
free(new_compare);
|
|
|
|
|
} else {
|
|
|
|
|
char *new_compare = yon_char_unite("<s>",old_value,"</s>\n******",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_compare,-1);
|
|
|
|
|
free(new_compare);
|
|
|
|
|
|
|
|
|
|
char *old=NULL;
|
|
|
|
|
char *newv=NULL;
|
|
|
|
|
if (!yon_char_is_empty(new_value)&&strlen(new_value)>2&&new_value[0]=='%'&&new_value[1]=='%'){
|
|
|
|
|
free(yon_char_divide(new_value,1));
|
|
|
|
|
newv=new_value;
|
|
|
|
|
} else if (!yon_char_is_empty(new_value)&&new_value[0]=='$') {
|
|
|
|
|
newv=new_value;
|
|
|
|
|
}else if (!yon_char_is_empty(new_value)){
|
|
|
|
|
newv="*******";
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(old_value)){
|
|
|
|
|
old = yon_char_unite("<s>",old_value,"</s>",NULL);
|
|
|
|
|
}
|
|
|
|
|
char *new_string = yon_char_unite(!yon_char_is_empty(old)?old:"","\n",!yon_char_is_empty(newv)?newv:"",NULL);
|
|
|
|
|
gtk_list_store_set(window->list,&iter,7,new_string,-1);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1341,7 +1413,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
password="x";
|
|
|
|
|
password="";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
username = (char*)gtk_entry_get_text(GTK_ENTRY(window->userUserNameEntry));
|
|
|
|
|
@ -1491,7 +1563,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){
|
|
|
|
|
yon_char_return_if_exist(create_system_user,""),
|
|
|
|
|
yon_char_return_if_exist(create_ununique,""),
|
|
|
|
|
yon_char_return_if_exist(do_not_check,""),
|
|
|
|
|
":",yon_char_return_if_exist(password,"x"),
|
|
|
|
|
":",yon_char_return_if_exist(password,""),
|
|
|
|
|
":",yon_char_return_if_exist(extra_options,""),
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
@ -1986,7 +2058,7 @@ void config_init(){
|
|
|
|
|
main_config.lock_save_global=0;
|
|
|
|
|
main_config.lock_save_local=0;
|
|
|
|
|
main_config.groups_size=0;
|
|
|
|
|
main_config.load_mode=0;
|
|
|
|
|
main_config.load_mode=1;
|
|
|
|
|
main_config.hash_default_id=-1;
|
|
|
|
|
main_config.groups = yon_file_open(groups_path,&main_config.groups_size);
|
|
|
|
|
main_config.users = yon_file_open(users_path,&main_config.users_size);
|
|
|
|
|
@ -2126,8 +2198,7 @@ main_window *yon_main_window_complete(main_window *widgets){
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_config_global_load),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_local_load),widgets);
|
|
|
|
|
main_config.load_mode=0;
|
|
|
|
|
yon_load_proceed(YON_CONFIG_GLOBAL);
|
|
|
|
|
yon_load_proceed(YON_CONFIG_LOCAL);
|
|
|
|
|
yon_interface_update((main_window*)widgets);
|
|
|
|
|
gtk_widget_realize(GTK_WIDGET(widgets->UsersTree));
|
|
|
|
|
yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->UsersTree));
|
|
|
|
|
@ -2157,9 +2228,6 @@ int main(int argc, char *argv[]){
|
|
|
|
|
yon_ubl_setup_arguments(argc,argv,&unfound,&size,NULL);
|
|
|
|
|
gtk_init(&argc,&argv);
|
|
|
|
|
template_main_window *widgets = yon_ubl_window_setup();
|
|
|
|
|
textdomain (template_ui_LocaleName);
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
textdomain (LocaleName);
|
|
|
|
|
yon_main_window_complete((main_window*)widgets);
|
|
|
|
|
yon_window_config_load(config_path);
|
|
|
|
|
gtk_main();
|
|
|
|
|
|