You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ubl-settings-usergroups/source/ubl-settings-usergroups.h

367 lines
13 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <locale.h>
#include <vte/vte.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
#include <libintl.h>
#include <limits.h>
#include <sys/wait.h>
#include <libublsettings.h>
#include <libublsettings-gtk3.h>
#include <libublsettingsui-gtk3.h>
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
#include "ubl-strings.h"
#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечениерограммы_и_утилиты/Все/ubl-settings-usergroups"
#define _(String) gettext(String)
#define glade_path "/com/ublinux/ui/ubl-settings-usergroups.glade"
#define glade_path_ubl_settings_usergroups_additional_settings "/com/ublinux/ui/ubl-settings-usergroups-additional-settings.glade"
#define glade_path_ubl_settings_usergroups_group_creation "/com/ublinux/ui/ubl-settings-usergroups-group-creation.glade"
#define glade_path_ubl_settings_usergroups_group "/com/ublinux/ui/ubl-settings-usergroups-group.glade"
#define glade_path_ubl_settings_usergroups_password "/com/ublinux/ui/ubl-settings-usergroups-password.glade"
#define glade_path_ubl_settings_usergroups_system "/com/ublinux/ui/ubl-settings-usergroups-system.glade"
#define glade_path_ubl_settings_usergroups_user "/com/ublinux/ui/ubl-settings-usergroups-user.glade"
#define glade_path_ubl_settings_usergroups_savesettings "/com/ublinux/ui/ubl-settings-usergroups-savesettings.glade"
#define glade_path_ubl_settings_usergroups_confirmation "/com/ublinux/ui/ubl-settings-usergroups-confirmation.glade"
#define banner_path "/com/ublinux/images/ubl-settings-usergroups-banner.png"
#define CssPath "/com/ublinux/css/ubl-settings-usergroups.css"
#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL)
#define LocalePath "/usr/share/locale"
#define LocaleName "ubl-settings-usergroups"
#define encrypt_passwords_command "/usr/lib/ublinux/functions globalconf_convert_pass_plain_to_hash"
#define get_default_hash_command "ubconfig --raw --source default get [users] HASHPASSWD"
#define clear_config_global_command "ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER"
#define clear_config_local_command "ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER"
#define samba_sync_command(user) yon_char_unite("sudo smbpasswd -Lan ",user,NULL)
#define samba_sync_password_command(user, password) yon_char_unite("(echo \"",password,"\"; echo \"",password,"\") | sudo smbpasswd -Las ",user,NULL)
#define get_passwords_command "ubconfig --target global get [users] USERADD[*] GROUPADD[*]"
#define check_is_password_hash(password) system(yon_char_unite("/lib/ublinux/functions is_hash_password '", password,"'",NULL))
#define groups_path "/etc/group"
#define users_path "/etc/passwd"
#define shadow_path "/etc/shadow"
#define uid_path "/etc/login.defs"
#define password_limits_path "/etc/security/pwquiality.conf"
#define get_home_command(target) yon_char_unite("getent passwd \"",target,"\" | cut -d: -f6",NULL)
#define remove_home_dirs_command(users_string) yon_char_append("/usr/lib/ublinux/functions remove_userhome ", users_string)
#define default_home_initiator_path "/etc/default/useradd"
#define hash_list_path "/usr/share/ubl-settings-usergroups/csv/hash_list.csv"
#define shell_list_path "/usr/share/ubl-settings-usergroups/csv/shell_list.csv"
#define USERADD(user) yon_char_unite("USERADD[",user,"]",NULL)
#define GROUPADD(group) yon_char_unite("GROUPADD[",group,"]",NULL)
#define USERSHADOW(user) yon_char_unite("USERSHADOW[",user,"]",NULL)
#define USERADD_SYNC(user) yon_char_unite("USERADD_SYNC[",user,"]",NULL)
#define USERSHADOW_SYNC(user) yon_char_unite("USERSHADOW_SYNC[",user,"]",NULL)
#define GROUPADD_SYNC(user) yon_char_unite("GROUPADD_SYNC[",user,"]",NULL)
#define add_icon_name "com.ublinux.ubl-settings-usergroups.increase-symbolic"
#define edit_icon_name "com.ublinux.ubl-settings-usergroups.edit-symbolic"
#define delete_icon_name "com.ublinux.ubl-settings-usergroups.trash-symbolic"
#define password_hash_get_command(passwd) yon_char_append("mkpasswd2 ",passwd)
#define config_get_command(source) yon_char_unite("ubconfig --source ",source," get users DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERADD_SYNC USERSHADOW[*] GROUPADD[*]",NULL),yon_char_unite("ubconfig --source ",source," get [system] SYSTEMBOOT_STATEMODE",NULL),yon_char_unite("ubconfig --source ",source," get [save] SAVE_ROOTCOPY_CHANGES",NULL)
#define config_get_default_command "ubconfig --source default get users DEFAULTPASSWD DEFAULTROOTPASSWD USERGROUPS DEFAULTUSER HASHPASSWD ADDADM"
#define config_get_global_only_parameters "ubconfig --source global get users DEFAULTPASSWD DEFAULTROOTPASSWD"
#define config_get_local_only_parameters ""
#define SAVE_ROOTCOPY_CHANGES_get_command "ubconfig --source global get [save] SAVE_ROOTCOPY_CHANGES"
#define DEFAULTUSER_get_command "ubconfig --source global get [users] DEFAULTUSER"
#define DEFAULTPASSWD_get_command "ubconfig --source global get [users] DEFAULTPASSWD"
#define DEFAULTROOTPASSWD_get_command "ubconfig --source global get [users] DEFAULTROOTPASSWD"
#define ADDADM_get_command "ubconfig --source global get [users] ADDADM"
#define HASHPASSWD_get_command "ubconfig --source global get [users] HASHPASSWD"
#define USERADD_SYNC_get_command "ubconfig --source global get [users] USERADD_SYNC"
#define USERGROUPS_get_command "ubconfig --source global get [users] USERGROUPS"
#define USERGROUPS_parameter "USERGROUPS"
#define USERGROUPS_parameter_command "ubconfig --source system get users USERGROUPS"
#define DEFAULTPASSWD_parameter "DEFAULTPASSWD"
#define DEFAULTPASSWD_parameter_command "ubconfig --source system get users DEFAULTPASSWD"
#define DEFAULTROOTPASSWD_parameter "DEFAULTROOTPASSWD"
#define DEFAULTROOTPASSWD_parameter_command "ubconfig --source system get users DEFAULTROOTPASSWD"
#define ADDADM_parameter "ADDADM"
#define ADDADM_parameter_command "ubconfig --source system get users ADDADM"
#define HASHPASSWD_parameter "HASHPASSWD"
#define HASHPASSWD_parameter_command "ubconfig --source system get users HASHPASSWD"
#define DEFAULTUSER_parameter "DEFAULTUSER"
#define DEFAULTUSER_parameter_command "ubconfig --source system get users DEFAULTUSER"
#define SAVE_ROOTCOPY_CHANGES_parameter "SAVE_ROOTCOPY_CHANGES"
#define SAVE_ROOTCOPY_CHANGES_parameter_command "ubconfig --source system get users SAVE_ROOTCOPY_CHANGES"
#define USERADD_parameter "USERADD"
#define USERADD_all_parameter_command "ubconfig --source system get users USERADD"
#define GROUPADD_parameter "GROUPADD"
#define GROUPADD_all_parameter_command "ubconfig --source system get users GROUPADD"
#define USERADD_SHADOW_parameter "USERADD_SHADOW"
#define USERADD_SHADOW_parameter_command "ubconfig --source system get users USERADD_SHADOW"
#define GROUPADD_SHADOW_parameter "GROUPADD_SHADOW"
#define GROUPADD_SHADOW_parameter_command "ubconfig --source system get users GROUPADD_SHADOW"
#define USERADD_SYNC_parameter "USERADD_SYNC"
#define USERADD_SYNC_parameter_command "ubconfig --source system get users USERADD_SYNC"
#define USERADD_SEARCH_macro "USERADD["
#define USERADD_parameter_command yon_char_unite("ubconfig --source system get users USERADD[",target,"]",NULL)
#define GROUPADD_SEARCH_macro "GROUPADD["
#define GROUPADD_parameter_command yon_char_unite("GROUPADD[",target,"]",NULL)
typedef char* string;
string version_application;
char *local;
typedef struct {
template_config_fields
config_str groups;
int groups_size;
config_str users;
int users_size;
GtkListStore *users_list;
GtkListStore *groups_list;
int MAXUID;
int MINUID;
int MAXGID;
int MINGID;
int password_min_length;
int hash_default_id;
config_str sync_users;
int sync_size;
config_str remove_homes;
int homes_size;
char *default_home;
int save_config;
int launch_size;
config_str launch_arguments;
} config;
typedef struct {
template_window_fields
GtkListStore *CacheAlgList;
GtkListStore *GroupsList;
GtkListStore *UsersList;
GtkWidget *button1;
GtkWidget *button2;
GtkWidget *button3;
GtkWidget *AddButton;
GtkWidget *EditButton;
GtkWidget *DeleteButton;
GtkWidget *UpdateButton;
GtkWidget *UsersTree;
GtkWidget *GroupsTree;
GtkWidget *MainNotebook;
GtkWidget *SavingSettingsButton;
rmb_menu_window *UsersMenu;
rmb_menu_window *GroupsMenu;
} main_window;
typedef struct {
GtkWidget *Window;
GtkWidget *AlwaysOpenCheck;
GtkWidget *CloseButton;
GtkWidget *AcceptButton;
} documentation_confirmation_window;
typedef struct{
GtkWidget *Window;
GtkWidget *StatusBox;
GtkWidget *DefaultUserNameEntry;
GtkWidget *DefaultUserAdministratorCheck;
GtkWidget *DefaultPasswordCombo;
GtkWidget *DefaultPasswordEntry;
GtkWidget *DefaultPasswordButton;
GtkWidget *RootPasswordCombo;
GtkWidget *RootPasswordEntry;
GtkWidget *RootPasswordButton;
GtkWidget *PasswordHashCombo;
GtkWidget *CancelButton;
GtkWidget *AcceptButton;
GtkWidget *EncryptAllPasswordsButton;
GtkWidget *UsersBootCheck;
GtkWidget *UsersShutdownCheck;
} ubl_settings_usergroups_additional_settings_window;
typedef struct{
GtkWidget *CreateGroupWindow;
GtkWidget *StatusBox;
GtkWidget *userUIDAutoCheck;
GtkWidget *userUIDEntry;
GtkWidget *userLoginEntry;
GtkWidget *userGroupsEntry;
GtkWidget *UserAdditionalGroupsButton;
GtkWidget *UserCancelButton;
GtkWidget *UserOkButton;
GtkWidget *AdditionalGroupsButton;
GtkWidget *UnuniqueGIDCheck;
GtkWidget *SystemGroupCheck;
GtkWidget *PasswordCombo;
GtkWidget *PasswordEntry;
GtkWidget *ChangePasswordButton;
GtkWidget *userTitleNameLabel;
GtkWidget *AdminGroupsEntry;
GtkWidget *AdminGroupsButton;
GtkWidget *GroupaddShutdownCheck;
GtkWidget *groupExtraOptionsEntry;
} ubl_settings_usergroups_group_creation_window;
typedef struct{
GtkWidget *GroupsWindow;
GtkWidget *GroupsTree;
GtkListStore *list;
GtkWidget *GroupsCancelButton;
GtkWidget *GroupsOkButton;
GtkWidget *HeaderLabel;
GtkCellRenderer *StatusCell;
GtkTreeViewColumn *GroupColumn;
} ubl_settings_usergroups_group_window;
typedef struct{
GtkWidget *CreateGroupWindow;
GtkWidget *StatusBox;
GtkWidget *UserCancelButton;
GtkWidget *UserOkButton;
GtkWidget *PasswordEntry;
GtkWidget *RepeatPasswordEntry;
GtkWidget *PasswordHashEntry;
GtkWidget *HashBox;
GtkWidget *PasswordBox;
GtkWidget *NoEncriptionCheck;
} ubl_settings_usergroups_password_window;
typedef struct{
GtkListStore *liststore1;
GtkListStore *liststore2;
GtkWidget *MonitorWindow;
GtkWidget *ToggleAllButton;
GtkWidget *UpdateButton;
GtkWidget *SystemTree;
int show_all;
} ubl_settings_usergroups_system_window;
typedef struct{
GtkWidget *CreateUserWindow;
GtkWidget *StatusBox;
GtkWidget *userUIDAutoCheck;
GtkWidget *userUIDEntry;
GtkWidget *userLoginEntry;
GtkWidget *userPasswordCombo;
GtkWidget *userPasswordEntry;
GtkWidget *userPasswordButton;
GtkWidget *userUserNameEntry;
GtkWidget *userGroupsCheck;
GtkWidget *userGroupsEntry;
GtkWidget *UserGroupsButton;
GtkWidget *userAdditionalGroupsEntry;
GtkWidget *userAdditionalGroupsButton;
GtkWidget *userPasswordChangedEntry;
GtkWidget *userPasswordExpirationEntry;
GtkWidget *userPasswordExpirationButton;
GtkWidget *userPasswordChangeDelayMinimumSpin;
GtkWidget *userPasswordChangeDelayMaximumSpin;
GtkWidget *userWarningSpin;
GtkWidget *userActivitySpin;
GtkWidget *userForceChangeCheck;
GtkWidget *userShellCombo;
GtkWidget *userShellEntry;
GtkWidget *userHomeCombo;
GtkWidget *userHomeEntry;
GtkWidget *userHomeButton;
GtkWidget *userCreateSystemCheck;
GtkWidget *userCreateUnuniqueCheck;
GtkWidget *userDontCheckCheck;
GtkWidget *userSyncSAMBACheck;
GtkWidget *userDeactivatedCheck;
GtkWidget *userExtraOptionsEntry;
GtkWidget *UserCancelButton;
GtkWidget *UserOkButton;
GtkWidget *CalendarPopup;
GtkWidget *ExpirationCalendar;
GtkWidget *UseraddBootCheck;
GtkWidget *UseraddShutdownCheck;
GtkWidget *UsershadowBootCheck;
GtkWidget *UsershadowShutdownCheck;
GtkWidget *userTitleNameLabel;
GtkWidget *userSyncSAMBAPasswordCheck;
char *expiration_unix;
char *old_password;
char *old_username;
} ubl_settings_usergroups_user_window;
typedef struct {
GtkWidget *Window;
GtkWidget *StatusBox;
GtkWidget *CancelButton;
GtkWidget *AcceptButton;
GtkWidget *SambaCheck;
} yon_savasettings_window;
typedef struct {
GtkWidget *Window;
GtkWidget *StatusBox;
GtkWidget *CancelButton;
GtkWidget *AcceptButton;
GtkWidget *DeletionTree;
GtkWidget *TitleLabel;
GtkWidget *HatLabel;
GtkListStore *list;
GtkCellRenderer *DeleteCell;
GtkCellRenderer *DeleteHomeCell;
GtkTreeViewColumn *UserCell;
} yon_confirmation_window;
ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new();
void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *self, main_window *widgets);
ubl_settings_usergroups_group_creation_window *yon_ubl_settings_usergroups_group_creation_new();
ubl_settings_usergroups_group_window *yon_ubl_settings_usergroups_group_new();
void on_standard_groups_open(GtkWidget *self, main_window *widgets);
ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_new();
ubl_settings_usergroups_system_window *yon_ubl_settings_usergroups_system_new();
void on_settings_usergroups_system_open(GtkWidget *self, main_window *widgets);
ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new();
void on_password_accept(GtkWidget *self, dictionary *dict);
void on_config_update(GtkWidget *self, main_window *widgets);