-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager.h
170 lines (129 loc) · 4.33 KB
/
manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef MANAGER_H
#define MANAGER_H
#include <QMainWindow>
#include <QDebug>
#include <QProcess>
#include <QFileDialog>
#include <QMessageBox>
#include <QInputDialog>
#include <QLineEdit>
namespace Ui {
class Manager;
}
class Manager : public QMainWindow
{
Q_OBJECT
public:
explicit Manager(QWidget *parent = nullptr);
~Manager();
// Initialize a few things
void init();
QString getUsername() const;
void setUsername(const QString &value);
QString getPassword() const;
void setPassword(const QString &value);
// COmpare username provided by Qt and the entered one
bool compare_usernames();
// Find out if password is the correct one!
bool compare_passwords();
// List / grep real human system users
void cat_users();
// List / grep all real system groups
void cat_groups();
// Exit the application function
void exit_app();
/*
* Group Management related functions
*/
QString getGroupname() const;
void setGroupname(const QString &value);
QString getNew_groupname() const;
void setNew_groupname(const QString &value);
QString getGid() const;
void setGid(const QString &value);
// Create a new group
bool groupadd();
// Rename an existing group
bool groupmod();
// Remove an existing group
bool groupdel();
// Check if a group exists
bool group_exists();
/*
* User Management related functions
*/
void create_enc_password();
bool is_username_valid();
bool adduser();
bool deluser();
bool user_exists();
// set ownership and permissions for the new user's home directory
// in order to be able to lg in there when login to the system
bool set_chown();
bool set_chmod();
bool del_user_home();
/*
* Networking Section related functions
*/
QString ifconfig();
QString netstat();
QString iptables();
QString Table;
QString getNew_username() const;
void setNew_username(const QString &value);
QString getNew_user_realname() const;
void setNew_user_realname(const QString &value);
QString getNew_user_group() const;
void setNew_user_group(const QString &value);
QString getNew_user_id() const;
void setNew_user_id(const QString &value);
QString getNew_user_shell() const;
void setNew_user_shell(const QString &value);
QString getNew_user_encr_password() const;
void setNew_user_encr_password(const QString &value);
QString getTable() const;
private slots:
void on_show_password_checkBox_clicked(bool checked);
void on_submit_button_clicked();
void on_human_users_checkBox_clicked(bool checked);
void on_human_groups_checkBox_clicked(bool checked);
void on_clear_credentials_checkBox_clicked(bool checked);
void on_clear_user_fields_checkBox_clicked(bool checked);
void on_clear_group_fields_checkBox_clicked(bool checked);
void on_exit_manager_checkBox_clicked(bool checked);
void on_actionExit_Manager_triggered();
void on_actionAbout_Author_triggered();
void on_actionAbout_Manager_triggered();
void on_confirm_group_stuff_checkBox_clicked(bool checked);
void on_create_group_button_clicked();
void on_remove_group_button_clicked();
void on_rename_group_button_clicked();
void on_show_new_user_password_checkBox_clicked(bool checked);
void on_shells_checkBox_clicked(bool checked);
void on_confirm_user_stuff_checkBox_clicked(bool checked);
void on_create_new_user_button_clicked();
void on_remove_user_button_clicked();
void on_interfaces_checkBox_clicked(bool checked);
void on_routing_table_checkBox_clicked(bool checked);
void on_firewall_checkBox_clicked(bool checked);
private:
Ui::Manager *ui;
// username & password
QString username;
QString password;
// A bool that is set to true only if username & password
// provided by the user are the correct ones of course
bool submit_validation = false;
// Group Management related string variables
QString groupname;
QString new_groupname;
QString gid; // The GID (aka Group ID)
// User Management related string variables
QString new_username;
QString new_user_realname;
QString new_user_group;
QString new_user_id;
QString new_user_shell;
QString new_user_encr_password;
};
#endif // MANAGER_H