Greenbone Security Assistant  7.0.3~git
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 int get_http_only ();
102 void set_http_only (int);
103 void vendor_version_set (const gchar *);
104 const gchar *vendor_version_get ();
105 int label_name_set (const gchar *);
106 const gchar *label_name_get ();
107 void set_language_code (gchar **, const gchar *);
108 char *ctime_r_strip_newline (time_t *, char *);
109 char * xsl_transform_with_stylesheet (const char *, const char *,
111 char * xsl_transform (const char *, cmd_response_data_t *);
112 char * gsad_message (credentials_t *, const char *, const char *, int,
113  const char *, const char *, cmd_response_data_t *);
114 gchar *login_xml (const gchar *, const gchar *, const gchar *, const gchar *,
115  const gchar *, const gchar *);
116 
121 {
138 } ;
139 
140 
141 /* Params. */
142 
146 struct param
147 {
148  gchar *value; /* Value. */
149  gchar *original_value; /* Original value, before validation. */
150  gchar *filename; /* Filename. */
151  params_t *values; /* Multiple binary values. */
152  int valid; /* Validation flag. */
153  int valid_utf8; /* UTF8 validation flag. */
154  int value_size; /* Size of value, excluding trailing NULL. */
155  int array_len; /* The number of items of "array" params */
156 };
157 
161 typedef struct param param_t;
162 
163 params_t *params_new ();
164 
165 void params_free (params_t *);
166 
167 int params_given (params_t *, const char *);
168 
169 const char *params_value (params_t *, const char *);
170 
171 int params_value_size (params_t *, const char *);
172 
173 const char *params_original_value (params_t *, const char *);
174 
175 const char *params_filename (params_t *, const char *);
176 
177 params_t *params_values (params_t *, const char *);
178 
179 param_t *params_get (params_t *, const char *);
180 
181 int params_valid (params_t *, const char *);
182 
183 param_t *params_add (params_t *, const char *, const char *);
184 
185 param_t *params_append_bin (params_t *, const char *, const char *, int, int);
186 
187 #define params_iterator_t GHashTableIter
188 
189 #define params_iterator_init g_hash_table_iter_init
190 
191 gboolean params_iterator_next (params_iterator_t *, char **, param_t **);
192 
193 /* temporary setting to show charts - defined in gsad.c */
194 int user_set_charts (const gchar*, const int);
195 
196 /* default refresh interval setting */
197 int user_set_autorefresh (const gchar*, const gchar*);
198 
199 #endif /* not _GSAD_BASE_H */
gchar * value
Definition: gsad_base.h:148
int user_set_autorefresh(const gchar *, const gchar *)
Set default autorefresh interval of user.
Definition: gsad.c:852
void vendor_version_set(const gchar *)
Set the vendor version.
Definition: gsad_base.c:163
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:792
char * timezone
User's timezone.
Definition: gsad_base.h:72
content_type
Content types.
Definition: gsad_base.h:120
params_t * params_new()
Make a params.
Definition: gsad_base.c:653
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:130
Response information for commands.
Definition: gsad_base.h:92
int gsad_base_init()
Base init.
Definition: gsad_base.c:87
int valid_utf8
Definition: gsad_base.h:153
gchar * filename
Definition: gsad_base.h:150
int params_given(params_t *, const char *)
Get whether a param was given at all.
Definition: gsad_base.c:695
char * xsl_transform_with_stylesheet(const char *, const char *, cmd_response_data_t *)
XSL Transformation.
Definition: gsad_base.c:281
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:887
gchar * original_value
Definition: gsad_base.h:149
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:241
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:130
int get_chroot_state()
Gets the chroot state.
Definition: gsad_base.c:119
int value_size
Definition: gsad_base.h:154
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:467
param_t * params_get(params_t *, const char *)
Get param.
Definition: gsad_base.c:679
const gchar * vendor_version_get()
Get the vendor version.
Definition: gsad_base.c:175
int params_value_size(params_t *, const char *)
Get the size of the value of param.
Definition: gsad_base.c:727
void set_http_only(int)
Sets the http_only state.
Definition: gsad_base.c:152
int array_len
Definition: gsad_base.h:155
param_t * params_add(params_t *, const char *, const char *)
Add a param.
Definition: gsad_base.c:808
#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:793
Request parameter.
Definition: gsad_base.h:146
params_t * params_values(params_t *, const char *)
Get values of param.
Definition: gsad_base.c:777
const char * params_filename(params_t *, const char *)
Get filename of param.
Definition: gsad_base.c:761
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:745
int gsad_base_cleanup()
Base init.
Definition: gsad_base.c:104
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:841
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:186
char * pw_warning
Password policy warning message.
Definition: gsad_base.h:79
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
int get_http_only()
Gets the http_only state.
Definition: gsad_base.c:141
char * xsl_transform(const char *, cmd_response_data_t *)
XSL Transformation.
Definition: gsad_base.c:445
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:584
int valid
Definition: gsad_base.h:152
params_t * params
Request parameters.
Definition: gsad_base.h:84
#define params_iterator_t
Definition: gsad_base.h:187
int label_name_set(const gchar *)
Set the login label.
Definition: gsad_base.c:199
void set_language_code(gchar **, const gchar *)
Set language code of user.
Definition: gsad_base.c:218
params_t * values
Definition: gsad_base.h:151
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:711
void params_free(params_t *)
Make a params.
Definition: gsad_base.c:664