From 89b940643ea38d4c16a93d9b39afbd8933c59630 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 30 Sep 2025 14:54:49 +0600 Subject: [PATCH] Fixed unchosen expiration date was set as today --- source/ubl-settings-usergroups-user.c | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/source/ubl-settings-usergroups-user.c b/source/ubl-settings-usergroups-user.c index e0a2b56..dbefe06 100644 --- a/source/ubl-settings-usergroups-user.c +++ b/source/ubl-settings-usergroups-user.c @@ -514,17 +514,19 @@ void on_user_save(GtkWidget *self, dictionary *dict){ password_change_interval_maximum = yon_char_from_long(password_change_interval_maximum_active); } else password_change_interval_maximum = 0; - guint year, month, day; - gtk_calendar_get_date(GTK_CALENDAR(window->ExpirationCalendar),&year,&month,&day); - char *dy = yon_char_from_int(day); - char *mn = yon_char_from_int(month+1); - char *yr = yon_char_from_int(year); - if (month+1<10) mn = yon_char_append("0",mn); - if (day<10) dy = yon_char_append("0",dy); - password_expiration_date = yon_char_unite(yr,"-",mn,"-",dy,NULL); - // password_expiration_date = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordExpirationEntry)); - if (yon_char_is_empty(password_expiration_date)){ - password_expiration_date="-1"; + if (!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(window->userPasswordExpirationEntry)))){ + guint year, month, day; + gtk_calendar_get_date(GTK_CALENDAR(window->ExpirationCalendar),&year,&month,&day); + char *dy = yon_char_from_int(day); + char *mn = yon_char_from_int(month+1); + char *yr = yon_char_from_int(year); + if (month+1<10) mn = yon_char_append("0",mn); + if (day<10) dy = yon_char_append("0",dy); + password_expiration_date = yon_char_unite(yr,"-",mn,"-",dy,NULL); + // password_expiration_date = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordExpirationEntry)); + if (yon_char_is_empty(password_expiration_date)){ + password_expiration_date="-1"; + } } long warning_days_active = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->userWarningSpin)); @@ -674,11 +676,13 @@ int yon_system_user_sync(char *target_user){ free(optionals); if (!yon_char_is_empty(config_user)){ - char *user_command = yon_config_parameter_prepare_command(dull_parameter_get_command,NULL,"users",USERADD(target_user)); char *parameter_name = USERADD(target_user); + char *user_command = yon_config_parameter_prepare_command(dull_parameter_get_command,NULL,"users",parameter_name); yon_config_register(parameter_name,user_command,config_user); yon_config_remove_ignore(parameter_name); free(config_user); + free(user_command); + free(parameter_name); } else return 0; if (!yon_char_is_empty(config_shadow)){