Added checking for uid and gid existance

pull/183/head
parent ec507c6949
commit 50cc307d8e

@ -1370,6 +1370,27 @@ void on_group_save(GtkWidget *self, dictionary *dict){
} }
} }
int config_size=0;
int final_size=0;
config_str config_users = yon_config_get_all_by_key(USERADD_SEARCH_macro,&config_size);
yon_char_parsed_prepend_strings(config_users,config_size,":");
config_str final = yon_char_parsed_merge(main_config.groups,main_config.groups_size,config_users,config_size,&final_size);
int found=0;
char *uid_string = (char*)gtk_entry_get_text(GTK_ENTRY(window->userUIDEntry));
for (int i=0;i<final_size;i++){
int parsed_size;
config_str parsed = yon_char_parse(final[i],&parsed_size,":");
printf("%s / %s\n",parsed[2],uid_string);
if (parsed_size>1&&!strcmp(parsed[2],uid_string)&&strcmp(parsed[2],window->last_gid)) found = 1;
if (parsed_size) yon_char_parsed_free(parsed,parsed_size);
}
if (found){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),GID_ALREADY_EXIST_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->userUIDEntry);
return;
}
group_name = (char*)gtk_entry_get_text(GTK_ENTRY(window->userLoginEntry)); group_name = (char*)gtk_entry_get_text(GTK_ENTRY(window->userLoginEntry));
if (group_name[0]>'0'&&group_name[0]<'9'){ if (group_name[0]>'0'&&group_name[0]<'9'){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),GROUP_BEGINS_WITH_DIGIT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),GROUP_BEGINS_WITH_DIGIT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
@ -1962,10 +1983,27 @@ void on_user_save(GtkWidget *self, dictionary *dict){
if (uid_auto_active){ if (uid_auto_active){
uid_string=""; uid_string="";
} else { } else {
uid_string = (char*)gtk_entry_get_text(GTK_ENTRY(window->userUIDEntry)); int config_size=0;
if (yon_char_is_empty(uid_string)){ int final_size=0;
config_str config_users = yon_config_get_all_by_key(USERADD_SEARCH_macro,&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);
int found=0;
uid_string = (char*)gtk_entry_get_text(GTK_ENTRY(window->userUIDEntry));
for (int i=0;i<final_size;i++){
int parsed_size;
config_str parsed = yon_char_parse(final[i],&parsed_size,":");
if (parsed_size>1&&!strcmp(parsed[2],uid_string)&&strcmp(parsed[2],window->last_uid)) found = 1;
if (parsed_size) yon_char_parsed_free(parsed,parsed_size);
}
if (found){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),UID_ALREADY_EXIST_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->userUIDEntry);
return;
}
if (yon_char_is_empty(uid_string)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->userUIDEntry); yon_ubl_status_highlight_incorrect(window->userUIDEntry);
return; return;

@ -184,6 +184,9 @@
#define PASSWORD_NO_SET_LABEL _("Not specified") #define PASSWORD_NO_SET_LABEL _("Not specified")
#define UID_ALREADY_EXIST_LABEL _("UID already busy")
#define GID_ALREADY_EXIST_LABEL _("GID already busy")
//ubl-settings-usergroups-password.glade //ubl-settings-usergroups-password.glade
#define PASSWORD_REPEAT_LABEL _("Repeat password:") #define PASSWORD_REPEAT_LABEL _("Repeat password:")
#define PASSWORD_HASH_LABEL _("Password hash:") #define PASSWORD_HASH_LABEL _("Password hash:")

@ -40,7 +40,7 @@
<object class="GtkTreeView" id="GroupsTree"> <object class="GtkTreeView" id="GroupsTree">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="search-column">1</property> <property name="search-column">2</property>
<property name="enable-grid-lines">vertical</property> <property name="enable-grid-lines">vertical</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection"> <object class="GtkTreeSelection">

@ -703,3 +703,9 @@ msgstr ""
msgid "Are you sure want to delete user" msgid "Are you sure want to delete user"
msgstr "" msgstr ""
msgid "UID already busy"
msgstr ""
msgid "GID already busy"
msgstr ""

@ -742,3 +742,10 @@ msgstr "Домашний каталог"
#: source/ubl-strings.h:207 #: source/ubl-strings.h:207
msgid "Delete home directory" msgid "Delete home directory"
msgstr "Удалить домашний каталог" msgstr "Удалить домашний каталог"
msgid "UID already busy"
msgstr "UID уже существует"
msgid "GID already busy"
msgstr "GID уже существует"
Loading…
Cancel
Save