Greenbone Security Assistant  7.0.0
gsad_base.h
Go to the documentation of this file.
1 /* Greenbone Security Assistant
2  * $Id$
3  * Description: Headers/structs used generally in GSA
4  *
5  * Authors:
6  * Matthew Mundell <matthew.mundell@greenbone.net>
7  * Jan-Oliver Wagner <jan-oliver.wagner@greenbone.net>
8  *
9  * Copyright:
10  * Copyright (C) 2009 Greenbone Networks GmbH
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26 
32 #ifndef _GSAD_BASE_H
33 #define _GSAD_BASE_H
34 
35 #include <glib.h>
36 #include <sys/time.h>
37 
41 #define RESULTS_PER_PAGE 100
42 
44 #define GSAD_MESSAGE_INVALID \
45  "<gsad_msg status_text=\"%s\" operation=\"%s\">" \
46  "At least one entered value contains invalid characters or exceeds" \
47  " a size limit. You may use the Back button of your browser to adjust" \
48  " the entered values. If in doubt, the online help of the respective section" \
49  " will lead you to the appropriate help page." \
50  "</gsad_msg>"
51 
53 #define GSAD_MESSAGE_INVALID_PARAM(op) \
54  "<gsad_msg status_text=\"Invalid parameter\" operation=\"" op "\">" \
55  "At least one entered value contains invalid characters or exceeds" \
56  " a size limit. You may use the Back button of your browser to adjust" \
57  " the entered values. If in doubt, the online help of the respective section" \
58  " will lead you to the appropriate help page." \
59  "</gsad_msg>"
60 
61 #define params_t GHashTable
62 
66 typedef struct
67 {
68  struct timeval cmd_start;
69  char *username;
70  char *password;
71  char *role;
72  char *timezone;
73  char *token;
74  char *caller;
75  char *current_page;
76  char *capabilities;
77  char *language;
78  char *severity;
79  char *pw_warning;
81  GTree *chart_prefs;
82  char *autorefresh;
83  GTree *last_filt_ids;
85  int charts;
86  int guest;
88 
92 typedef struct {
94  gchar *redirect;
96 
97 int gsad_base_init ();
98 int gsad_base_cleanup ();
99 int get_chroot_state ();
100 void set_chroot_state (int);
101 void vendor_version_set (const gchar *);
102 const gchar *vendor_version_get ();
103 int label_name_set (const gchar *);
104 const gchar *label_name_get ();
105 void set_language_code (gchar **, const gchar *);
106 char *ctime_r_strip_newline (time_t *, char *);
107 char * xsl_transform_with_stylesheet (const char *, const char *,
109 char * xsl_transform (const char *, cmd_response_data_t *);
110 char * gsad_message (credentials_t *, const char *, const char *, int,
111  const char *, const char *, cmd_response_data_t *);
112 gchar *login_xml (const gchar *, const gchar *, const gchar *, const gchar *,
113  const gchar *, const gchar *);
114 
119 {
136 } ;
137 
138 
139 /* Params. */
140 
144 struct param
145 {
146  gchar *value; /* Value. */
147  gchar *original_value; /* Original value, before validation. */
148  gchar *filename; /* Filename. */
149  params_t *values; /* Multiple binary values. */
150  int valid; /* Validation flag. */
151  int valid_utf8; /* UTF8 validation flag. */
152  int value_size; /* Size of value, excluding trailing NULL. */
153  int array_len; /* The number of items of "array" params */
154 };
155 
159 typedef struct param param_t;
160 
161 params_t *params_new ();
162 
163 void params_free (params_t *);
164 
165 int params_given (params_t *, const char *);
166 
167 const char *params_value (params_t *, const char *);
168 
169 int params_value_size (params_t *, const char *);
170 
171 const char *params_original_value (params_t *, const char *);
172 
173 const char *params_filename (params_t *, const char *);
174 
175 params_t *params_values (params_t *, const char *);
176 
177 param_t *params_get (params_t *, const char *);
178 
179 int params_valid (params_t *, const char *);
180 
181 param_t *params_add (params_t *, const char *, const char *);
182 
183 param_t *params_append_bin (params_t *, const char *, const char *, int, int);
184 
185 #define params_iterator_t GHashTableIter
186 
187 #define params_iterator_init g_hash_table_iter_init
188 
189 gboolean params_iterator_next (params_iterator_t *, char **, param_t **);
190 
191 /* temporary setting to show charts - defined in gsad.c */
192 int user_set_charts (const gchar*, const int);
193 
194 /* default refresh interval setting */
195 int user_set_autorefresh (const gchar*, const gchar*);
196 
197 #endif /* not _GSAD_BASE_H */
gchar * value
Definition: gsad_base.h:146
int user_set_autorefresh(const gchar *, const gchar *)
Set default autorefresh interval of user.
Definition: gsad.c:816
void vendor_version_set(const gchar *)
Set the vendor version.
Definition: gsad_base.c:136
char * capabilities
Capabilites of manager.
Definition: gsad_base.h:76
int user_set_charts(const gchar *, const int)
Set charts setting of user.
Definition: gsad.c:756
char * timezone
User's timezone.
Definition: gsad_base.h:72
content_type
Content types.
Definition: gsad_base.h:118
params_t * params_new()
Make a params.
Definition: gsad_base.c:624
char * caller
Caller URL, for POST relogin.
Definition: gsad_base.h:74
void set_chroot_state(int)
Sets the chroot state.
Definition: gsad_base.c:125
Response information for commands.
Definition: gsad_base.h:92
int gsad_base_init()
Base init.
Definition: gsad_base.c:82
int valid_utf8
Definition: gsad_base.h:151
gchar * filename
Definition: gsad_base.h:148
int params_given(params_t *, const char *)
Get whether a param was given at all.
Definition: gsad_base.c:666
char * xsl_transform_with_stylesheet(const char *, const char *, cmd_response_data_t *)
XSL Transformation.
Definition: gsad_base.c:254
Structure of credential related information.
Definition: gsad_base.h:66
gboolean params_iterator_next(params_iterator_t *, char **, param_t **)
Increment a params iterator.
Definition: gsad_base.c:858
gchar * original_value
Definition: gsad_base.h:147
char * username
Name of user.
Definition: gsad_base.h:69
char * ctime_r_strip_newline(time_t *, char *)
Return string from ctime_r with newline replaces with terminator.
Definition: gsad_base.c:214
char * autorefresh
Auto-refresh interval.
Definition: gsad_base.h:82
GTree * last_filt_ids
Last filter ids.
Definition: gsad_base.h:83
char * client_address
Client's address.
Definition: gsad_base.h:80
Special marker.
Definition: gsad_base.h:128
int get_chroot_state()
Gets the chroot state.
Definition: gsad_base.c:114
int value_size
Definition: gsad_base.h:152
char * gsad_message(credentials_t *, const char *, const char *, int, const char *, const char *, cmd_response_data_t *)
Handles fatal errors.
Definition: gsad_base.c:440
param_t * params_get(params_t *, const char *)
Get param.
Definition: gsad_base.c:650
const gchar * vendor_version_get()
Get the vendor version.
Definition: gsad_base.c:148
int params_value_size(params_t *, const char *)
Get the size of the value of param.
Definition: gsad_base.c:698
int array_len
Definition: gsad_base.h:153
param_t * params_add(params_t *, const char *, const char *)
Add a param.
Definition: gsad_base.c:779
#define params_t
Definition: gsad_base.h:61
int params_valid(params_t *, const char *)
Get whether a param is valid.
Definition: gsad_base.c:764
Request parameter.
Definition: gsad_base.h:144
params_t * params_values(params_t *, const char *)
Get values of param.
Definition: gsad_base.c:748
const char * params_filename(params_t *, const char *)
Get filename of param.
Definition: gsad_base.c:732
int guest
Whether the user is a guest user.
Definition: gsad_base.h:86
const char * params_original_value(params_t *, const char *)
Get original value of param, before validation.
Definition: gsad_base.c:716
int gsad_base_cleanup()
Base init.
Definition: gsad_base.c:99
char * token
Session token.
Definition: gsad_base.h:73
param_t * params_append_bin(params_t *, const char *, const char *, int, int)
Append binary data to a param.
Definition: gsad_base.c:812
char * role
User's role.
Definition: gsad_base.h:71
int charts
Whether to show charts for this user.
Definition: gsad_base.h:85
const gchar * label_name_get()
Get the login label name.
Definition: gsad_base.c:159
char * pw_warning
Password policy warning message.
Definition: gsad_base.h:79
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
char * xsl_transform(const char *, cmd_response_data_t *)
XSL Transformation.
Definition: gsad_base.c:418
GTree * chart_prefs
Chart preferences.
Definition: gsad_base.h:81
char * severity
Severity class.
Definition: gsad_base.h:78
char * current_page
Current page URL, for refresh.
Definition: gsad_base.h:75
char * language
Accept-Language browser header.
Definition: gsad_base.h:77
gchar * login_xml(const gchar *, const gchar *, const gchar *, const gchar *, const gchar *, const gchar *)
Generate XML for login page.
Definition: gsad_base.c:557
int valid
Definition: gsad_base.h:150
params_t * params
Request parameters.
Definition: gsad_base.h:84
#define params_iterator_t
Definition: gsad_base.h:185
int label_name_set(const gchar *)
Set the login label.
Definition: gsad_base.c:172
void set_language_code(gchar **, const gchar *)
Set language code of user.
Definition: gsad_base.c:191
params_t * values
Definition: gsad_base.h:149
char * password
User's password.
Definition: gsad_base.h:70
const char * params_value(params_t *, const char *)
Get value of param.
Definition: gsad_base.c:682
void params_free(params_t *)
Make a params.
Definition: gsad_base.c:635