Added reading of system mininum password length, added chekhing for minimum password length

pull/14/head
parent 7e12513f83
commit 91009dd171

@ -549,6 +549,10 @@ void on_password_accept(GtkWidget *self, dictionary *dict){
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
if (strlen(password)<main_config.password_min_length){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_SHORT_LABEL(yon_char_from_int(main_config.password_min_length)),5,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry));
if (!strcmp(password,password_check)){
char *passwd_hash = g_malloc0(101);
@ -1177,12 +1181,16 @@ void on_main_delete(GtkWidget *self, main_window *widgets){
if(gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(cur_tree)),&model,&iter)){
char *name;
gtk_tree_model_get(model,&iter,1,&name,-1);
yon_config_remove_by_key(USERADD(name));
yon_config_remove_by_key(GROUPADD(name));
gtk_list_store_remove(GTK_LIST_STORE(model),&iter);
}
}
}
void on_config_update(){
}
/**config_init()
* [EN]
@ -1205,6 +1213,7 @@ void config_init(){
main_config.users = yon_file_open(users_path,&main_config.users_size);
main_config.users_list=NULL;
main_config.groups_list=NULL;
main_config.password_min_length=6;
int login_size;
config_str login_defs = yon_file_open(uid_path,&login_size);
for (int i=0;i<login_size;i++){
@ -1228,6 +1237,22 @@ void config_init(){
}
}
yon_char_parsed_free(login_defs,login_size);
login_defs = yon_file_open(password_limits_path,&login_size);
for (int i=0;i<login_size;i++){
if (login_defs[i][0]!='#'){
char *copy = yon_char_new(login_defs[i]);
char *divided = yon_char_divide(copy,7);
if (divided){
if (!strcmp(divided,"minlen")){
main_config.password_min_length = atol(strstr(login_defs[i],"\t"));
}
// else if (!strcmp(divided,"UID_MIN")){
// main_config.MINUID = atol(strstr(login_defs[i],"\t"));
// }
}
}
}
yon_char_parsed_free(login_defs,login_size);
}
/**yon_main_window_complete(main_window *widgets)

@ -41,6 +41,7 @@
#define groups_path "/etc/group"
#define users_path "/etc/passwd"
#define uid_path "/etc/login.defs"
#define password_limits_path "/etc/security/pwquiality.conf"
#define USERADD(user) yon_char_unite("USERADD[",user,"]",NULL)
#define GROUPADD(group) yon_char_unite("GROUPADD[",group,"]",NULL)
@ -82,6 +83,8 @@ typedef struct {
int MAXGID;
int MINGID;
int password_min_length;
} config;
typedef struct {

Loading…
Cancel
Save