|
|
#include <gtk/gtk.h>
|
|
|
#include <gtk/gtkx.h>
|
|
|
#include <locale.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 -Las ",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 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)
|
|
|
|
|
|
typedef char* string;
|
|
|
string version_application;
|
|
|
|
|
|
char *local;
|
|
|
|
|
|
typedef struct {
|
|
|
// Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT {
|
|
|
int socket_id;
|
|
|
int load_socket_id;
|
|
|
int save_socket_id;
|
|
|
|
|
|
int lock_help;
|
|
|
int lock_save_local;
|
|
|
int lock_save_global;
|
|
|
int lock_load_global;
|
|
|
int lock_load_system;
|
|
|
|
|
|
int load_mode;
|
|
|
|
|
|
int always_open_documentation;
|
|
|
// } Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT
|
|
|
// Type custom parameters below: :
|
|
|
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;
|
|
|
} config;
|
|
|
|
|
|
typedef struct {
|
|
|
// Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT {
|
|
|
GtkWidget *Window;
|
|
|
GtkWidget *HeadLabel;
|
|
|
GtkWidget *PlugBox;
|
|
|
|
|
|
GtkWidget *HeadOverlay;
|
|
|
GtkWidget *HeadImage;
|
|
|
GtkWidget *HeadBox;
|
|
|
GtkWidget *HeadTitleLabel;
|
|
|
GtkWidget *HeadInfoLabel;
|
|
|
|
|
|
GtkWidget *StatusBox;
|
|
|
GtkWidget *StatusIcon;
|
|
|
GtkWidget *StatusLabel;
|
|
|
|
|
|
GtkWidget *SaveMenuItem;
|
|
|
GtkWidget *SaveGlobalMenuItem;
|
|
|
GtkWidget *SaveLocalMenuItem;
|
|
|
GtkWidget *RightBox;
|
|
|
|
|
|
GtkWidget *LoadGlobalMenuItem;
|
|
|
GtkWidget *LoadLocalMenuItem;
|
|
|
GtkWidget *LeftBox;
|
|
|
|
|
|
GtkWidget *DocumentationMenuItem;
|
|
|
GtkWidget *AboutMenuItem;
|
|
|
|
|
|
GtkWidget *InterfaceBox;
|
|
|
// } Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT
|
|
|
// Type custom parameters below:
|
|
|
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;
|
|
|
|
|
|
} 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;
|
|
|
} 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;
|
|
|
GtkListStore *list;
|
|
|
GtkCellRenderer *DeleteCell;
|
|
|
GtkCellRenderer *DeleteHomeCell;
|
|
|
} 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); |