|
|
|
|
@ -97,6 +97,19 @@ void on_config_global_load(GtkWidget *self, main_window *widgets){
|
|
|
|
|
yon_interface_update(widgets);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_samba_sync_proceed(){
|
|
|
|
|
if (main_config.sync_users){
|
|
|
|
|
for (int i=0;i<main_config.sync_size;i++){
|
|
|
|
|
int size;
|
|
|
|
|
config_str parsed = yon_char_parse(main_config.sync_users[i],&size,":");
|
|
|
|
|
|
|
|
|
|
system (yon_char_is_empty(parsed[1])? samba_sync_command(parsed[0]) : samba_sync_password_command(parsed[0],parsed[1]));
|
|
|
|
|
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_config_save(){
|
|
|
|
|
yon_save_proceed(NULL,YON_CONFIG_BOTH,"users", "DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]",NULL);
|
|
|
|
|
}
|
|
|
|
|
@ -120,6 +133,34 @@ void on_saving_settings_save(GtkWidget *self, yon_savasettings_window *window){
|
|
|
|
|
on_subwindow_close(self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_samba_sync_add(char *user, char*password){
|
|
|
|
|
int sync_place = yon_char_parsed_check_exist(main_config.sync_users,main_config.sync_size,yon_char_append(user,":"));
|
|
|
|
|
if (sync_place==-1){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(main_config.sync_users,&main_config.sync_size,yon_char_unite(user,":",password,NULL));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_samba_sync_remove(char *user){
|
|
|
|
|
int sync_place = yon_char_parsed_check_exist(main_config.sync_users,main_config.sync_size,yon_char_append(user,":"));
|
|
|
|
|
if (sync_place>-1){
|
|
|
|
|
config_str temp = yon_char_parsed_rip(main_config.sync_users,&main_config.sync_size,sync_place);
|
|
|
|
|
free(main_config.sync_users);
|
|
|
|
|
main_config.sync_users = temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_samba_sync_get(char *user){
|
|
|
|
|
int sync_place = yon_char_parsed_check_exist(main_config.sync_users,main_config.sync_size,yon_char_append(user,":"));
|
|
|
|
|
if (sync_place>-1){
|
|
|
|
|
if (!main_config.sync_users)
|
|
|
|
|
return 0;
|
|
|
|
|
int active = main_config.sync_users[sync_place][strlen(main_config.sync_users[sync_place])-1]==':'? 1:2;
|
|
|
|
|
return active;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_delete_confirmation_delete_home_check(GtkCellRenderer *self, char *path, yon_confirmation_window *window){
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gboolean status;
|
|
|
|
|
@ -229,11 +270,12 @@ yon_savasettings_window *yon_saving_settings_new(){
|
|
|
|
|
window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
|
|
|
|
|
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
|
|
|
|
|
gtk_widget_show(window->Window);
|
|
|
|
|
yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"savingSettingsWindow");
|
|
|
|
|
char *string = yon_config_get_by_key("SAVE_ROOTCOPY_CHANGES");
|
|
|
|
|
if (!yon_char_is_empty(string)&&strstr(string,"/var/lib/samba")){
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SambaCheck),1);
|
|
|
|
|
}
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),SYSTEM_SAVEMODE_LABEL,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savemode",SYSTEM_SAVEMODE_LABEL,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -354,11 +396,6 @@ void on_password_change(GtkWidget *self, dictionary *entry_dict){
|
|
|
|
|
GtkComboBox *combo = yon_dictionary_get_data(entry_dict->first,GtkComboBox*);
|
|
|
|
|
GtkEntry *output_target = yon_dictionary_get_data(entry_dict->first->next,GtkEntry*);
|
|
|
|
|
ubl_settings_usergroups_password_window *window = yon_ubl_settings_usergroups_password_new();
|
|
|
|
|
int active = gtk_combo_box_get_active(combo);
|
|
|
|
|
if (active == 2)
|
|
|
|
|
gtk_widget_hide(window->HashBox);
|
|
|
|
|
else if (active==3)
|
|
|
|
|
gtk_widget_hide(window->PasswordBox);
|
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(dict,"target",output_target);
|
|
|
|
|
@ -796,7 +833,9 @@ void on_password_changed(GtkEntry *self, ubl_settings_usergroups_password_window
|
|
|
|
|
char *self_text = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
|
|
|
|
|
char *pair_text = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry));
|
|
|
|
|
if ((!yon_char_is_empty(self_text)&&!yon_char_is_empty(pair_text))&&strcmp(self_text,pair_text)){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_mismatch",PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
} else if (strlen(self_text)<main_config.password_min_length){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_short",PASSWORD_SHORT_LABEL(yon_char_from_int(main_config.password_min_length)),BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
} else {
|
|
|
|
|
yon_ubl_status_box_despawn_infinite(GTK_CONTAINER(window->StatusBox));
|
|
|
|
|
}
|
|
|
|
|
@ -805,18 +844,16 @@ void on_password_changed(GtkEntry *self, ubl_settings_usergroups_password_window
|
|
|
|
|
void on_password_accept(GtkWidget *self, dictionary *dict){
|
|
|
|
|
ubl_settings_usergroups_password_window *window = yon_dictionary_get_data(dict->first,ubl_settings_usergroups_password_window*);
|
|
|
|
|
GtkEntry *entry = yon_dictionary_get_data(dict->first->next,GtkEntry*);
|
|
|
|
|
if (gtk_widget_get_visible(window->HashBox)){
|
|
|
|
|
char *pasted_hash = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry));
|
|
|
|
|
if (yon_char_is_empty(pasted_hash)){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
if (!yon_char_is_empty(pasted_hash)){
|
|
|
|
|
gtk_entry_set_text(entry,pasted_hash);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
char *password = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)));
|
|
|
|
|
if (yon_char_is_empty(password)){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_empty",EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
return;
|
|
|
|
|
} else if (password[0]=='%'&&password[1]=='%'){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_wrong",EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (strlen(password)<main_config.password_min_length){
|
|
|
|
|
@ -825,13 +862,14 @@ void on_password_accept(GtkWidget *self, dictionary *dict){
|
|
|
|
|
}
|
|
|
|
|
char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry));
|
|
|
|
|
if (!strcmp(password,password_check)){
|
|
|
|
|
char *passwd_hash = g_malloc0(101);
|
|
|
|
|
FILE *fl = popen(password_hash_get_command(password),"r");
|
|
|
|
|
fgets(passwd_hash,100,fl);
|
|
|
|
|
if (passwd_hash[strlen(passwd_hash)-1]=='\n') passwd_hash[strlen(passwd_hash)-1]='\0';
|
|
|
|
|
gtk_entry_set_text(entry,passwd_hash);
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){
|
|
|
|
|
char *pasw=yon_char_append("%%",password);
|
|
|
|
|
free(password);
|
|
|
|
|
password=pasw;
|
|
|
|
|
}
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(entry),password);
|
|
|
|
|
} else {
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_mismatch",PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -848,6 +886,7 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne
|
|
|
|
|
window->PasswordHashEntry=yon_gtk_builder_get_widget(builder,"PasswordHashEntry");
|
|
|
|
|
window->HashBox=yon_gtk_builder_get_widget(builder,"HashBox");
|
|
|
|
|
window->PasswordBox=yon_gtk_builder_get_widget(builder,"PasswordBox");
|
|
|
|
|
window->NoEncriptionCheck=yon_gtk_builder_get_widget(builder,"NoEncriptionCheck");
|
|
|
|
|
|
|
|
|
|
window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton");
|
|
|
|
|
window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton");
|
|
|
|
|
@ -1010,7 +1049,7 @@ void on_UID_update(GtkWidget *self, ubl_settings_usergroups_user_window *window)
|
|
|
|
|
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDAutoCheck))){
|
|
|
|
|
int config_size=0;
|
|
|
|
|
int final_size=0;
|
|
|
|
|
config_str config_users = yon_config_get_all_by_key("USERADD",&config_size);
|
|
|
|
|
config_str config_users = yon_config_get_all_by_key("USERADD[",&config_size);
|
|
|
|
|
yon_char_parsed_prepend_strings(config_users,config_size,":");
|
|
|
|
|
config_str final = yon_char_parsed_merge(main_config.users,main_config.users_size,config_users,config_size,&final_size);
|
|
|
|
|
long prev_busy=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userCreateSystemCheck))?0:main_config.MINGID;
|
|
|
|
|
@ -1066,7 +1105,8 @@ void on_user_save(GtkWidget *self, dictionary *dict){
|
|
|
|
|
char *create_system_user = NULL;
|
|
|
|
|
char *create_ununique = NULL;
|
|
|
|
|
char *do_not_check = NULL;
|
|
|
|
|
char *samba_sync = NULL;
|
|
|
|
|
int samba_sync = 0;
|
|
|
|
|
int samba_password_sync = 0;
|
|
|
|
|
char *deactivate = NULL;
|
|
|
|
|
char *extra_options = NULL;
|
|
|
|
|
char *useradd_boot = "";
|
|
|
|
|
@ -1074,6 +1114,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){
|
|
|
|
|
char *usershadow_boot = "";
|
|
|
|
|
char *usershadow_shutdown = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int uid_auto_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDAutoCheck));
|
|
|
|
|
if (uid_auto_active){
|
|
|
|
|
uid_string="";
|
|
|
|
|
@ -1181,8 +1222,19 @@ void on_user_save(GtkWidget *self, dictionary *dict){
|
|
|
|
|
if (do_not_check_actve)
|
|
|
|
|
do_not_check = " --badnames";
|
|
|
|
|
|
|
|
|
|
int samba_sync_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck));
|
|
|
|
|
if (samba_sync_active);
|
|
|
|
|
samba_sync = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck));
|
|
|
|
|
samba_password_sync = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBAPasswordCheck));
|
|
|
|
|
if (samba_sync){
|
|
|
|
|
if (yon_samba_sync_get(login)==2)
|
|
|
|
|
yon_samba_sync_remove(login);
|
|
|
|
|
yon_samba_sync_add(login,NULL);
|
|
|
|
|
} else if (samba_password_sync){
|
|
|
|
|
if (yon_samba_sync_get(login)==1)
|
|
|
|
|
yon_samba_sync_remove(login);
|
|
|
|
|
yon_samba_sync_add(login,password);
|
|
|
|
|
} else {
|
|
|
|
|
yon_samba_sync_remove(login);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int deactivate_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userDeactivatedCheck));
|
|
|
|
|
if (deactivate_active);
|
|
|
|
|
@ -1215,6 +1267,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){
|
|
|
|
|
usershadow_shutdown = "shutdown";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *useradd_sync_string = NULL;
|
|
|
|
|
useradd_sync_string = yon_char_unite(useradd_boot,!yon_char_is_empty(useradd_boot)?",":"",useradd_shutdown,NULL);
|
|
|
|
|
char *usershadow_sync_string = NULL;
|
|
|
|
|
@ -1306,6 +1359,7 @@ ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){
|
|
|
|
|
window->userCreateUnuniqueCheck=yon_gtk_builder_get_widget(builder,"userCreateUnuniqueCheck");
|
|
|
|
|
window->userDontCheckCheck=yon_gtk_builder_get_widget(builder,"userDontCheckCheck");
|
|
|
|
|
window->userSyncSAMBACheck=yon_gtk_builder_get_widget(builder,"userSyncSAMBACheck");
|
|
|
|
|
window->userSyncSAMBAPasswordCheck=yon_gtk_builder_get_widget(builder,"userSyncSAMBAPasswordCheck");
|
|
|
|
|
window->userDeactivatedCheck=yon_gtk_builder_get_widget(builder,"userDeactivatedCheck");
|
|
|
|
|
window->userExtraOptionsEntry=yon_gtk_builder_get_widget(builder,"userExtraOptionsEntry");
|
|
|
|
|
window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton");
|
|
|
|
|
@ -1480,6 +1534,12 @@ void on_main_edit(GtkWidget *self, main_window *widgets){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
int samba_sync = yon_samba_sync_get(name);
|
|
|
|
|
if (samba_sync==1){
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck),1);
|
|
|
|
|
} else if (samba_sync==2){
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBAPasswordCheck),1);
|
|
|
|
|
}
|
|
|
|
|
free(parameters);
|
|
|
|
|
parameters=yon_char_parse(yon_config_get_by_key(USERSHADOW(name)),&parsed_size,":");
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(window->userPasswordChangedEntry),parsed_size>0?parameters[0]:"");
|
|
|
|
|
@ -1637,6 +1697,8 @@ void config_init(){
|
|
|
|
|
main_config.users_list=NULL;
|
|
|
|
|
main_config.groups_list=NULL;
|
|
|
|
|
main_config.password_min_length=6;
|
|
|
|
|
main_config.sync_users = NULL;
|
|
|
|
|
main_config.sync_size=0;
|
|
|
|
|
int login_size;
|
|
|
|
|
config_str login_defs = yon_file_open(uid_path,&login_size);
|
|
|
|
|
for (int i=0;i<login_size;i++){
|
|
|
|
|
@ -1842,7 +1904,7 @@ int main(int argc, char *argv[]){
|
|
|
|
|
if(optarg)
|
|
|
|
|
main_config.load_socket_id=atoi(optarg);
|
|
|
|
|
break;
|
|
|
|
|
case 'c': system(yon_char_unite("rm -rfd ", yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",NULL));
|
|
|
|
|
case 'c': system(remove_config_dir_command);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
main_config.lock_help=1;
|
|
|
|
|
|