Added password check function selection

pull/73/head
parent 50cd5550da
commit 08ff92f957

@ -12,7 +12,7 @@ DEPENDS = /bin/cmake
PREFIX ?= /usr/local PREFIX ?= /usr/local
PKGNAME = $(MAKEFILE_DIR) PKGNAME = $(MAKEFILE_DIR)
FILE_VER = source/CMakeLists.txt FILE_VER = source/CMakeLists.txt
PKGIDENT=$(subst /,-,${PREFIX}) PKGIDENT=$(subst /,-,/usr)
default_target: all default_target: all
@ -49,14 +49,14 @@ depend:
debug: debug:
@echo "Debug ..." @echo "Debug ..."
if [ ! -d ${CMAKE_UI_BUILD_DIR} ]; then \ if [ ! -d ${CMAKE_UI_BUILD_DIR} ]; then \
$(CMAKE_UI_COMMAND) -S${CMAKE_UI_SOURCE_DIR} -B${CMAKE_UI_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ $(CMAKE_UI_COMMAND) -S${CMAKE_UI_SOURCE_DIR} -B${CMAKE_UI_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="/usr"; \
fi; \ fi; \
echo "Debug: OK" echo "Debug: OK"
prepare: prepare:
@echo "Prepare ..."; \ @echo "Prepare ..."; \
if [ ! -d ${CMAKE_UI_BUILD_DIR} ]; then \ if [ ! -d ${CMAKE_UI_BUILD_DIR} ]; then \
$(CMAKE_UI_COMMAND) -DCMAKE_INSTALL_PREFIX=/usr -S${CMAKE_UI_SOURCE_DIR} -B${CMAKE_UI_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ $(CMAKE_UI_COMMAND) -DCMAKE_INSTALL_PREFIX=/usr -S${CMAKE_UI_SOURCE_DIR} -B${CMAKE_UI_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr"; \
fi; \ fi; \
echo "Prepare: OK" echo "Prepare: OK"
@ -79,7 +79,7 @@ build: depend prepare
uninstall: uninstall:
@echo "Uninstall ..." @echo "Uninstall ..."
@for LANG in $$(find ./ -iname "*.po" -print | sed -En "s/.+_([[:alpha:]]+)\.po/\1/p" | sort -u); do \ @for LANG in $$(find ./ -iname "*.po" -print | sed -En "s/.+_([[:alpha:]]+)\.po/\1/p" | sort -u); do \
# PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \ # PATH_FILE_MO="${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \
PATH_FILE_MO="${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \ PATH_FILE_MO="${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \
$(RM) "$${PATH_FILE_MO}"; \ $(RM) "$${PATH_FILE_MO}"; \
done done
@ -90,25 +90,25 @@ uninstall:
$(RM) "$${PATH_FILE_MO}"; \ $(RM) "$${PATH_FILE_MO}"; \
done done
@for SIZE in 16x16 32x32 48x48 scalable; do \ @for SIZE in 16x16 32x32 48x48 scalable; do \
$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ $(RM) "${DESTDIR}/usr/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \
$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.png"; \ $(RM) "${DESTDIR}/usr/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.png"; \
done done
@for FILE_SVG in $(wildcard *.svg); do \ @for FILE_SVG in $(wildcard *.svg); do \
for SIZE in 16x16 32x32 48x48 scalable; do \ for SIZE in 16x16 32x32 48x48 scalable; do \
$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \ $(RM) "${DESTDIR}/usr/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \
done; \ done; \
done done
@for FILE_ICON in $(wildcard icons/*/*.svg); do \ @for FILE_ICON in $(wildcard icons/*/*.svg); do \
SUB_NAME=$${FILE_ICON#*/};SUB_NAME=$${FILE_ICON%/*}; \ SUB_NAME=$${FILE_ICON#*/};SUB_NAME=$${FILE_ICON%/*}; \
$(RM) "${DESTDIR}/usr/share/icons/hicolor/scalable/$${SUB_NAME}/$${FILE_ICON##*/}"; \ $(RM) "${DESTDIR}/usr/share/icons/hicolor/scalable/$${SUB_NAME}/$${FILE_ICON##*/}"; \
done done
@$(RM) "${DESTDIR}${PREFIX}/lib/${PKGNAME}".so* @$(RM) "${DESTDIR}/usr/lib/${PKGNAME}".so*
@$(RM) "${DESTDIR}${PREFIX}/include/${PKGNAME}".h* @$(RM) "${DESTDIR}/usr/include/${PKGNAME}".h*
@if [ -z ${DESTDIR} ]; then \ @if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ [ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \
update-desktop-database --quiet &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \
[ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ [ -d "${DESTDIR}/usr/share/applications" ] && touch "${DESTDIR}/usr/share/applications" &>/dev/null || true; \
ldconfig -n ${DESTDIR}${PREFIX}/lib; \ ldconfig -n ${DESTDIR}/usr/lib; \
fi fi
@echo "Uninstall: OK" @echo "Uninstall: OK"
@ -124,8 +124,8 @@ install: check
msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \ msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \
done done
@for SIZE in 16 32 48; do \ @for SIZE in 16 32 48; do \
install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ install -dm755 "${DESTDIR}/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \
rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \
done done
@install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg"
@for FILE_ICON in $(wildcard icons/*/*.svg); do \ @for FILE_ICON in $(wildcard icons/*/*.svg); do \
@ -136,7 +136,7 @@ install: check
[ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \ [ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \
update-desktop-database --quiet &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \
[ -d "${DESTDIR}/usr/share/applications" ] && touch "${DESTDIR}/usr/share/applications" &>/dev/null || true; \ [ -d "${DESTDIR}/usr/share/applications" ] && touch "${DESTDIR}/usr/share/applications" &>/dev/null || true; \
ldconfig -n ${DESTDIR}${PREFIX}/lib; \ ldconfig -n ${DESTDIR}/usr/lib; \
fi fi
@echo "Install: OK" @echo "Install: OK"

@ -145,6 +145,43 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="PasswordStrengthProgress">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
@ -185,7 +222,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -200,7 +237,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -211,7 +248,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">3</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -264,7 +301,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">4</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -328,6 +365,7 @@
<widget name="label3"/> <widget name="label3"/>
<widget name="label2"/> <widget name="label2"/>
<widget name="label4"/> <widget name="label4"/>
<widget name="box1"/>
</widgets> </widgets>
</object> </object>
</interface> </interface>

@ -394,4 +394,7 @@ msgid "The configuration file contains incorrect parameters."
msgstr "" msgstr ""
msgid "Empty important field!" msgid "Empty important field!"
msgstr ""
msgid "The password does not meet the password policy requirements!"
msgstr "" msgstr ""

@ -400,4 +400,7 @@ msgid "The configuration file contains incorrect parameters."
msgstr "Файл конфигурации содержит некорректные параметры" msgstr "Файл конфигурации содержит некорректные параметры"
msgid "Empty important field!" msgid "Empty important field!"
msgstr "Пустое важное поле!" msgstr "Пустое важное поле!"
msgid "The password does not meet the password policy requirements!"
msgstr "Пароль не соответствует требованиям политики паролей"

@ -1,6 +1,5 @@
#include "libublsettingsui-gtk3.h" #include "libublsettingsui-gtk3.h"
#define sha256_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha256sum | cut -f 1 -d ' '",NULL) #define sha256_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha256sum | cut -f 1 -d ' '",NULL)
#define sha512_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha512sum | cut -f 1 -d ' '",NULL) #define sha512_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha512sum | cut -f 1 -d ' '",NULL)
@ -112,10 +111,15 @@ void yon_hash_entry_sensitiveness_update(GtkWidget *, yon_password_window *dialo
void yon_password_hash_list_set(yon_password_window *window, config_str hashes, config_str get_hash_commands, int size){ void yon_password_hash_list_set(yon_password_window *window, config_str hashes, config_str get_hash_commands, int size){
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->EncryptionCombo)); gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->EncryptionCombo));
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),_ENCRYPTION_DEFAULT_LABEL,""); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),"",_ENCRYPTION_DEFAULT_LABEL);
if (!size){
gtk_widget_hide(gtk_widget_get_parent(window->EncryptionCombo));
gtk_widget_hide(window->NoEncriptionCheck);
gtk_widget_hide(window->HashBox);
}
for (int i=0;i<size;i++){ for (int i=0;i<size;i++){
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),hashes[i],get_hash_commands[i]); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),get_hash_commands[i],hashes[i]);
} }
} }
@ -149,6 +153,10 @@ void on_password_hash_sensitiveness(GtkWidget *,yon_password_window *window){
} }
} }
void yon_password_function_set(yon_password_window *window, double *password_func){
window->strength_func = password_func;
}
void on_password_accept(GtkWidget *,dictionary *dict){ void on_password_accept(GtkWidget *,dictionary *dict){
yon_password_window *window = yon_dictionary_get_data(dict->first,yon_password_window*); yon_password_window *window = yon_dictionary_get_data(dict->first,yon_password_window*);
GtkWidget *target = yon_dictionary_get_data(dict->first->next,GtkWidget*); GtkWidget *target = yon_dictionary_get_data(dict->first->next,GtkWidget*);
@ -157,6 +165,14 @@ void on_password_accept(GtkWidget *,dictionary *dict){
char *final = NULL; char *final = NULL;
if (encription_active == 0||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ if (encription_active == 0||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){
final = yon_password_unencrypted_password_get(window); final = yon_password_unencrypted_password_get(window);
if (window->strength_func){
double password_strength = ((double(*)(yon_password_window *,const char*))window->strength_func)(window,final);
if (password_strength<0.3){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),WEAK_PASSWORD_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
}
if (!final) return; if (!final) return;
} else { } else {
final = yon_password_hash_get(window); final = yon_password_hash_get(window);
@ -166,6 +182,11 @@ void on_password_accept(GtkWidget *,dictionary *dict){
gtk_widget_destroy(window->Window); gtk_widget_destroy(window->Window);
} }
void on_password_changed(GtkWidget *, yon_password_window *window){
const char *password_str = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
double strength = ((double(*)(yon_password_window *,const char*))window->strength_func)(window,password_str);
}
yon_password_window *yon_password_window_new(){ yon_password_window *yon_password_window_new(){
GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_password); GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_password);
yon_password_window *window = malloc(sizeof(yon_password_window)); yon_password_window *window = malloc(sizeof(yon_password_window));
@ -177,6 +198,7 @@ yon_password_window *yon_password_window_new(){
window->EncryptionCombo = yon_gtk_builder_get_widget(builder,"EncryptionCombo"); window->EncryptionCombo = yon_gtk_builder_get_widget(builder,"EncryptionCombo");
window->NoEncriptionCheck = yon_gtk_builder_get_widget(builder,"NoEncriptionCheck"); window->NoEncriptionCheck = yon_gtk_builder_get_widget(builder,"NoEncriptionCheck");
window->PasswordHashEntry = yon_gtk_builder_get_widget(builder,"PasswordHashEntry"); window->PasswordHashEntry = yon_gtk_builder_get_widget(builder,"PasswordHashEntry");
window->PasswordStrengthProgress= yon_gtk_builder_get_widget(builder,"PasswordStrengthProgress");
window->UserCancelButton = yon_gtk_builder_get_widget(builder,"UserCancelButton"); window->UserCancelButton = yon_gtk_builder_get_widget(builder,"UserCancelButton");
window->AcceptButton = yon_gtk_builder_get_widget(builder,"UserOkButton"); window->AcceptButton = yon_gtk_builder_get_widget(builder,"UserOkButton");
window->PasswordBox = yon_gtk_builder_get_widget(builder,"PasswordBox"); window->PasswordBox = yon_gtk_builder_get_widget(builder,"PasswordBox");
@ -188,6 +210,7 @@ yon_password_window *yon_password_window_new(){
g_signal_connect(G_OBJECT(window->NoEncriptionCheck),"toggled",G_CALLBACK(on_password_hash_sensitiveness),window); g_signal_connect(G_OBJECT(window->NoEncriptionCheck),"toggled",G_CALLBACK(on_password_hash_sensitiveness),window);
g_signal_connect(G_OBJECT(window->PasswordHashEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); g_signal_connect(G_OBJECT(window->PasswordHashEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window);
g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window);
g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_changed),window);
g_signal_connect(G_OBJECT(window->RepeatPasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); g_signal_connect(G_OBJECT(window->RepeatPasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window);
gtk_widget_show(window->Window); gtk_widget_show(window->Window);
return window; return window;

@ -556,7 +556,11 @@ typedef struct {
GtkWidget *PasswordBox; GtkWidget *PasswordBox;
GtkWidget *HashBox; GtkWidget *HashBox;
GtkWidget *PasswordStrengthProgress;
void *strength_func;
const char *old_password; const char *old_password;
} yon_password_window; } yon_password_window;
@ -570,6 +574,7 @@ GtkWidget *yon_config_save_window_new();
void yon_password_hash_list_set(yon_password_window *window, config_str hashes, config_str get_hash_commands, int size); void yon_password_hash_list_set(yon_password_window *window, config_str hashes, config_str get_hash_commands, int size);
yon_password_window *yon_password_open(GtkEntry *target); yon_password_window *yon_password_open(GtkEntry *target);
void yon_password_function_set(yon_password_window *window, double *password_func);
typedef struct { typedef struct {
GtkWidget *Window; GtkWidget *Window;
@ -720,4 +725,5 @@ yon_window *yon_window_new();
#define DMY_MINUS_FORMAT_LABEL _("DD-MM-YYYY") #define DMY_MINUS_FORMAT_LABEL _("DD-MM-YYYY")
#define DMY_SLASH_FORMAT_LABEL _("DD/MM/YYYY") #define DMY_SLASH_FORMAT_LABEL _("DD/MM/YYYY")
#define MDY_FORMAT_LABEL _("MM-DD-YYYY") #define MDY_FORMAT_LABEL _("MM-DD-YYYY")
#define WEAK_PASSWORD_LABEL _("The password does not meet the password policy requirements")
#endif #endif
Loading…
Cancel
Save