1 | /********************************************************************\ |
---|
2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
3 | * * |
---|
4 | * Copyright 2002-2006 Wilmer van der Gaast and others * |
---|
5 | \********************************************************************/ |
---|
6 | |
---|
7 | /* Storage backend that uses an XMLish format for all data. */ |
---|
8 | |
---|
9 | /* |
---|
10 | This program is free software; you can redistribute it and/or modify |
---|
11 | it under the terms of the GNU General Public License as published by |
---|
12 | the Free Software Foundation; either version 2 of the License, or |
---|
13 | (at your option) any later version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License with |
---|
21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
22 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
23 | Suite 330, Boston, MA 02111-1307 USA |
---|
24 | */ |
---|
25 | |
---|
26 | #define BITLBEE_CORE |
---|
27 | #include "bitlbee.h" |
---|
28 | #include "base64.h" |
---|
29 | #include "arc.h" |
---|
30 | #include "md5.h" |
---|
31 | #include <glib/gstdio.h> |
---|
32 | |
---|
33 | #if GLIB_CHECK_VERSION(2,8,0) |
---|
34 | #include <glib/gstdio.h> |
---|
35 | #else |
---|
36 | /* GLib < 2.8.0 doesn't have g_access, so just use the system access(). */ |
---|
37 | #include <unistd.h> |
---|
38 | #define g_access access |
---|
39 | #endif |
---|
40 | |
---|
41 | typedef enum |
---|
42 | { |
---|
43 | XML_PASS_CHECK_ONLY = -1, |
---|
44 | XML_PASS_UNKNOWN = 0, |
---|
45 | XML_PASS_WRONG, |
---|
46 | XML_PASS_OK |
---|
47 | } xml_pass_st; |
---|
48 | |
---|
49 | /* To make it easier later when extending the format: */ |
---|
50 | #define XML_FORMAT_VERSION 1 |
---|
51 | |
---|
52 | struct xml_parsedata |
---|
53 | { |
---|
54 | irc_t *irc; |
---|
55 | char *current_setting; |
---|
56 | account_t *current_account; |
---|
57 | char *given_nick; |
---|
58 | char *given_pass; |
---|
59 | xml_pass_st pass_st; |
---|
60 | }; |
---|
61 | |
---|
62 | static char *xml_attr( const gchar **attr_names, const gchar **attr_values, const gchar *key ) |
---|
63 | { |
---|
64 | int i; |
---|
65 | |
---|
66 | for( i = 0; attr_names[i]; i ++ ) |
---|
67 | if( g_strcasecmp( attr_names[i], key ) == 0 ) |
---|
68 | return (char*) attr_values[i]; |
---|
69 | |
---|
70 | return NULL; |
---|
71 | } |
---|
72 | |
---|
73 | static void xml_destroy_xd( gpointer data ) |
---|
74 | { |
---|
75 | struct xml_parsedata *xd = data; |
---|
76 | |
---|
77 | g_free( xd->given_nick ); |
---|
78 | g_free( xd->given_pass ); |
---|
79 | g_free( xd ); |
---|
80 | } |
---|
81 | |
---|
82 | static void xml_start_element( GMarkupParseContext *ctx, const gchar *element_name, const gchar **attr_names, const gchar **attr_values, gpointer data, GError **error ) |
---|
83 | { |
---|
84 | struct xml_parsedata *xd = data; |
---|
85 | irc_t *irc = xd->irc; |
---|
86 | |
---|
87 | if( g_strcasecmp( element_name, "user" ) == 0 ) |
---|
88 | { |
---|
89 | char *nick = xml_attr( attr_names, attr_values, "nick" ); |
---|
90 | char *pass = xml_attr( attr_names, attr_values, "password" ); |
---|
91 | int st; |
---|
92 | |
---|
93 | if( !nick || !pass ) |
---|
94 | { |
---|
95 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
96 | "Missing attributes for %s element", element_name ); |
---|
97 | } |
---|
98 | else if( ( st = md5_verify_password( xd->given_pass, pass ) ) == -1 ) |
---|
99 | { |
---|
100 | xd->pass_st = XML_PASS_WRONG; |
---|
101 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
102 | "Error while decoding password attribute" ); |
---|
103 | } |
---|
104 | else if( st == 0 ) |
---|
105 | { |
---|
106 | if( xd->pass_st != XML_PASS_CHECK_ONLY ) |
---|
107 | xd->pass_st = XML_PASS_OK; |
---|
108 | } |
---|
109 | else |
---|
110 | { |
---|
111 | xd->pass_st = XML_PASS_WRONG; |
---|
112 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
113 | "Password mismatch" ); |
---|
114 | } |
---|
115 | } |
---|
116 | else if( xd->pass_st < XML_PASS_OK ) |
---|
117 | { |
---|
118 | /* Let's not parse anything else if we only have to check |
---|
119 | the password. */ |
---|
120 | } |
---|
121 | else if( g_strcasecmp( element_name, "account" ) == 0 ) |
---|
122 | { |
---|
123 | char *protocol, *handle, *server, *password = NULL, *autoconnect; |
---|
124 | char *pass_b64 = NULL; |
---|
125 | unsigned char *pass_cr = NULL; |
---|
126 | int pass_len; |
---|
127 | struct prpl *prpl = NULL; |
---|
128 | |
---|
129 | handle = xml_attr( attr_names, attr_values, "handle" ); |
---|
130 | pass_b64 = xml_attr( attr_names, attr_values, "password" ); |
---|
131 | server = xml_attr( attr_names, attr_values, "server" ); |
---|
132 | autoconnect = xml_attr( attr_names, attr_values, "autoconnect" ); |
---|
133 | |
---|
134 | protocol = xml_attr( attr_names, attr_values, "protocol" ); |
---|
135 | if( protocol ) |
---|
136 | prpl = find_protocol( protocol ); |
---|
137 | |
---|
138 | if( !handle || !pass_b64 || !protocol ) |
---|
139 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
140 | "Missing attributes for %s element", element_name ); |
---|
141 | else if( !prpl ) |
---|
142 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
143 | "Unknown protocol: %s", protocol ); |
---|
144 | else if( ( pass_len = base64_decode( pass_b64, (unsigned char**) &pass_cr ) ) && |
---|
145 | arc_decode( pass_cr, pass_len, &password, xd->given_pass ) ) |
---|
146 | { |
---|
147 | xd->current_account = account_add( irc, prpl, handle, password ); |
---|
148 | if( server ) |
---|
149 | set_setstr( &xd->current_account->set, "server", server ); |
---|
150 | if( autoconnect ) |
---|
151 | set_setstr( &xd->current_account->set, "auto_connect", autoconnect ); |
---|
152 | } |
---|
153 | else |
---|
154 | { |
---|
155 | /* Actually the _decode functions don't even return error codes, |
---|
156 | but maybe they will later... */ |
---|
157 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
158 | "Error while decrypting account password" ); |
---|
159 | } |
---|
160 | |
---|
161 | g_free( pass_cr ); |
---|
162 | g_free( password ); |
---|
163 | } |
---|
164 | else if( g_strcasecmp( element_name, "setting" ) == 0 ) |
---|
165 | { |
---|
166 | char *setting; |
---|
167 | |
---|
168 | if( xd->current_setting ) |
---|
169 | { |
---|
170 | g_free( xd->current_setting ); |
---|
171 | xd->current_setting = NULL; |
---|
172 | } |
---|
173 | |
---|
174 | if( ( setting = xml_attr( attr_names, attr_values, "name" ) ) ) |
---|
175 | xd->current_setting = g_strdup( setting ); |
---|
176 | else |
---|
177 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
178 | "Missing attributes for %s element", element_name ); |
---|
179 | } |
---|
180 | else if( g_strcasecmp( element_name, "buddy" ) == 0 ) |
---|
181 | { |
---|
182 | char *handle, *nick; |
---|
183 | |
---|
184 | handle = xml_attr( attr_names, attr_values, "handle" ); |
---|
185 | nick = xml_attr( attr_names, attr_values, "nick" ); |
---|
186 | |
---|
187 | if( xd->current_account && handle && nick ) |
---|
188 | { |
---|
189 | nick_set( xd->current_account, handle, nick ); |
---|
190 | } |
---|
191 | else |
---|
192 | { |
---|
193 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, |
---|
194 | "Missing attributes for %s element", element_name ); |
---|
195 | } |
---|
196 | } |
---|
197 | else |
---|
198 | { |
---|
199 | g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT, |
---|
200 | "Unkown element: %s", element_name ); |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | static void xml_end_element( GMarkupParseContext *ctx, const gchar *element_name, gpointer data, GError **error ) |
---|
205 | { |
---|
206 | struct xml_parsedata *xd = data; |
---|
207 | |
---|
208 | if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting ) |
---|
209 | { |
---|
210 | g_free( xd->current_setting ); |
---|
211 | xd->current_setting = NULL; |
---|
212 | } |
---|
213 | else if( g_strcasecmp( element_name, "account" ) == 0 ) |
---|
214 | { |
---|
215 | xd->current_account = NULL; |
---|
216 | } |
---|
217 | } |
---|
218 | |
---|
219 | static void xml_text( GMarkupParseContext *ctx, const gchar *text_orig, gsize text_len, gpointer data, GError **error ) |
---|
220 | { |
---|
221 | char text[text_len+1]; |
---|
222 | struct xml_parsedata *xd = data; |
---|
223 | irc_t *irc = xd->irc; |
---|
224 | |
---|
225 | strncpy( text, text_orig, text_len ); |
---|
226 | text[text_len] = 0; |
---|
227 | |
---|
228 | if( xd->pass_st < XML_PASS_OK ) |
---|
229 | { |
---|
230 | /* Let's not parse anything else if we only have to check |
---|
231 | the password, or if we didn't get the chance to check it |
---|
232 | yet. */ |
---|
233 | } |
---|
234 | else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && xd->current_setting ) |
---|
235 | { |
---|
236 | set_setstr( xd->current_account ? &xd->current_account->set : &irc->set, |
---|
237 | xd->current_setting, (char*) text ); |
---|
238 | g_free( xd->current_setting ); |
---|
239 | xd->current_setting = NULL; |
---|
240 | } |
---|
241 | } |
---|
242 | |
---|
243 | GMarkupParser xml_parser = |
---|
244 | { |
---|
245 | xml_start_element, |
---|
246 | xml_end_element, |
---|
247 | xml_text, |
---|
248 | NULL, |
---|
249 | NULL |
---|
250 | }; |
---|
251 | |
---|
252 | static void xml_init( void ) |
---|
253 | { |
---|
254 | if( g_access( global.conf->configdir, F_OK ) != 0 ) |
---|
255 | log_message( LOGLVL_WARNING, "The configuration directory `%s' does not exist. Configuration won't be saved.", global.conf->configdir ); |
---|
256 | else if( g_access( global.conf->configdir, F_OK ) != 0 || |
---|
257 | g_access( global.conf->configdir, W_OK ) != 0 ) |
---|
258 | log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to `%s'.", global.conf->configdir ); |
---|
259 | } |
---|
260 | |
---|
261 | static storage_status_t xml_load_real( const char *my_nick, const char *password, irc_t *irc, xml_pass_st action ) |
---|
262 | { |
---|
263 | GMarkupParseContext *ctx; |
---|
264 | struct xml_parsedata *xd; |
---|
265 | char *fn, buf[512]; |
---|
266 | GError *gerr = NULL; |
---|
267 | int fd, st; |
---|
268 | |
---|
269 | if( irc && irc->status & USTATUS_IDENTIFIED ) |
---|
270 | return( 1 ); |
---|
271 | |
---|
272 | xd = g_new0( struct xml_parsedata, 1 ); |
---|
273 | xd->irc = irc; |
---|
274 | xd->given_nick = g_strdup( my_nick ); |
---|
275 | xd->given_pass = g_strdup( password ); |
---|
276 | xd->pass_st = action; |
---|
277 | nick_lc( xd->given_nick ); |
---|
278 | |
---|
279 | fn = g_strdup_printf( "%s%s%s", global.conf->configdir, xd->given_nick, ".xml" ); |
---|
280 | if( ( fd = open( fn, O_RDONLY ) ) < 0 ) |
---|
281 | { |
---|
282 | xml_destroy_xd( xd ); |
---|
283 | g_free( fn ); |
---|
284 | return STORAGE_NO_SUCH_USER; |
---|
285 | } |
---|
286 | g_free( fn ); |
---|
287 | |
---|
288 | ctx = g_markup_parse_context_new( &xml_parser, 0, xd, xml_destroy_xd ); |
---|
289 | |
---|
290 | while( ( st = read( fd, buf, sizeof( buf ) ) ) > 0 ) |
---|
291 | { |
---|
292 | if( !g_markup_parse_context_parse( ctx, buf, st, &gerr ) || gerr ) |
---|
293 | { |
---|
294 | xml_pass_st pass_st = xd->pass_st; |
---|
295 | |
---|
296 | g_markup_parse_context_free( ctx ); |
---|
297 | close( fd ); |
---|
298 | |
---|
299 | if( pass_st == XML_PASS_WRONG ) |
---|
300 | { |
---|
301 | g_clear_error( &gerr ); |
---|
302 | return STORAGE_INVALID_PASSWORD; |
---|
303 | } |
---|
304 | else |
---|
305 | { |
---|
306 | if( gerr && irc ) |
---|
307 | irc_usermsg( irc, "Error from XML-parser: %s", gerr->message ); |
---|
308 | |
---|
309 | g_clear_error( &gerr ); |
---|
310 | return STORAGE_OTHER_ERROR; |
---|
311 | } |
---|
312 | } |
---|
313 | } |
---|
314 | /* Just to be sure... */ |
---|
315 | g_clear_error( &gerr ); |
---|
316 | |
---|
317 | g_markup_parse_context_free( ctx ); |
---|
318 | close( fd ); |
---|
319 | |
---|
320 | if( action == XML_PASS_CHECK_ONLY ) |
---|
321 | return STORAGE_OK; |
---|
322 | |
---|
323 | irc->status |= USTATUS_IDENTIFIED; |
---|
324 | |
---|
325 | return STORAGE_OK; |
---|
326 | } |
---|
327 | |
---|
328 | static storage_status_t xml_load( const char *my_nick, const char *password, irc_t *irc ) |
---|
329 | { |
---|
330 | return xml_load_real( my_nick, password, irc, XML_PASS_UNKNOWN ); |
---|
331 | } |
---|
332 | |
---|
333 | static storage_status_t xml_check_pass( const char *my_nick, const char *password ) |
---|
334 | { |
---|
335 | /* This is a little bit risky because we have to pass NULL for the |
---|
336 | irc_t argument. This *should* be fine, if I didn't miss anything... */ |
---|
337 | return xml_load_real( my_nick, password, NULL, XML_PASS_CHECK_ONLY ); |
---|
338 | } |
---|
339 | |
---|
340 | static int xml_printf( int fd, int indent, char *fmt, ... ) |
---|
341 | { |
---|
342 | va_list params; |
---|
343 | char *out; |
---|
344 | char tabs[9] = "\t\t\t\t\t\t\t\t"; |
---|
345 | int len; |
---|
346 | |
---|
347 | /* Maybe not very clean, but who needs more than 8 levels of indentation anyway? */ |
---|
348 | if( write( fd, tabs, indent <= 8 ? indent : 8 ) != indent ) |
---|
349 | return 0; |
---|
350 | |
---|
351 | va_start( params, fmt ); |
---|
352 | out = g_markup_vprintf_escaped( fmt, params ); |
---|
353 | va_end( params ); |
---|
354 | |
---|
355 | len = strlen( out ); |
---|
356 | len -= write( fd, out, len ); |
---|
357 | g_free( out ); |
---|
358 | |
---|
359 | return len == 0; |
---|
360 | } |
---|
361 | |
---|
362 | static gboolean xml_save_nick( gpointer key, gpointer value, gpointer data ); |
---|
363 | |
---|
364 | static storage_status_t xml_save( irc_t *irc, int overwrite ) |
---|
365 | { |
---|
366 | char path[512], *path2, *pass_buf = NULL; |
---|
367 | set_t *set; |
---|
368 | account_t *acc; |
---|
369 | int fd; |
---|
370 | md5_byte_t pass_md5[21]; |
---|
371 | md5_state_t md5_state; |
---|
372 | |
---|
373 | if( irc->password == NULL ) |
---|
374 | { |
---|
375 | irc_usermsg( irc, "Please register yourself if you want to save your settings." ); |
---|
376 | return STORAGE_OTHER_ERROR; |
---|
377 | } |
---|
378 | |
---|
379 | path2 = g_strdup( irc->nick ); |
---|
380 | nick_lc( path2 ); |
---|
381 | g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, path2, ".xml" ); |
---|
382 | g_free( path2 ); |
---|
383 | |
---|
384 | if( !overwrite && g_access( path, F_OK ) == 0 ) |
---|
385 | return STORAGE_ALREADY_EXISTS; |
---|
386 | |
---|
387 | strcat( path, "~" ); |
---|
388 | if( ( fd = open( path, O_WRONLY | O_CREAT | O_TRUNC, 0600 ) ) < 0 ) |
---|
389 | { |
---|
390 | irc_usermsg( irc, "Error while opening configuration file." ); |
---|
391 | return STORAGE_OTHER_ERROR; |
---|
392 | } |
---|
393 | |
---|
394 | /* Generate a salted md5sum of the password. Use 5 bytes for the salt |
---|
395 | (to prevent dictionary lookups of passwords) to end up with a 21- |
---|
396 | byte password hash, more convenient for base64 encoding. */ |
---|
397 | random_bytes( pass_md5 + 16, 5 ); |
---|
398 | md5_init( &md5_state ); |
---|
399 | md5_append( &md5_state, (md5_byte_t*) irc->password, strlen( irc->password ) ); |
---|
400 | md5_append( &md5_state, pass_md5 + 16, 5 ); /* Add the salt. */ |
---|
401 | md5_finish( &md5_state, pass_md5 ); |
---|
402 | /* Save the hash in base64-encoded form. */ |
---|
403 | pass_buf = base64_encode( pass_md5, 21 ); |
---|
404 | |
---|
405 | if( !xml_printf( fd, 0, "<user nick=\"%s\" password=\"%s\" version=\"%d\">\n", irc->nick, pass_buf, XML_FORMAT_VERSION ) ) |
---|
406 | goto write_error; |
---|
407 | |
---|
408 | g_free( pass_buf ); |
---|
409 | |
---|
410 | for( set = irc->set; set; set = set->next ) |
---|
411 | if( set->value && set->def ) |
---|
412 | if( !xml_printf( fd, 1, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) |
---|
413 | goto write_error; |
---|
414 | |
---|
415 | for( acc = irc->accounts; acc; acc = acc->next ) |
---|
416 | { |
---|
417 | unsigned char *pass_cr; |
---|
418 | char *pass_b64; |
---|
419 | int pass_len; |
---|
420 | |
---|
421 | pass_len = arc_encode( acc->pass, strlen( acc->pass ), (unsigned char**) &pass_cr, irc->password, 12 ); |
---|
422 | pass_b64 = base64_encode( pass_cr, pass_len ); |
---|
423 | g_free( pass_cr ); |
---|
424 | |
---|
425 | if( !xml_printf( fd, 1, "<account protocol=\"%s\" handle=\"%s\" password=\"%s\" autoconnect=\"%d\"", acc->prpl->name, acc->user, pass_b64, acc->auto_connect ) ) |
---|
426 | { |
---|
427 | g_free( pass_b64 ); |
---|
428 | goto write_error; |
---|
429 | } |
---|
430 | g_free( pass_b64 ); |
---|
431 | |
---|
432 | if( acc->server && acc->server[0] && !xml_printf( fd, 0, " server=\"%s\"", acc->server ) ) |
---|
433 | goto write_error; |
---|
434 | if( !xml_printf( fd, 0, ">\n" ) ) |
---|
435 | goto write_error; |
---|
436 | |
---|
437 | for( set = acc->set; set; set = set->next ) |
---|
438 | if( set->value && set->def && !( set->flags & ACC_SET_NOSAVE ) ) |
---|
439 | if( !xml_printf( fd, 2, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) |
---|
440 | goto write_error; |
---|
441 | |
---|
442 | /* This probably looks pretty strange. g_hash_table_foreach |
---|
443 | is quite a PITA already (but it can't get much better in |
---|
444 | C without using #define, I'm afraid), and since it |
---|
445 | doesn't seem to be possible to abort the foreach on write |
---|
446 | errors, so instead let's use the _find function and |
---|
447 | return TRUE on write errors. Which means, if we found |
---|
448 | something, there was an error. :-) */ |
---|
449 | if( g_hash_table_find( acc->nicks, xml_save_nick, & fd ) ) |
---|
450 | goto write_error; |
---|
451 | |
---|
452 | if( !xml_printf( fd, 1, "</account>\n" ) ) |
---|
453 | goto write_error; |
---|
454 | } |
---|
455 | |
---|
456 | if( !xml_printf( fd, 0, "</user>\n" ) ) |
---|
457 | goto write_error; |
---|
458 | |
---|
459 | close( fd ); |
---|
460 | |
---|
461 | path2 = g_strndup( path, strlen( path ) - 1 ); |
---|
462 | if( rename( path, path2 ) != 0 ) |
---|
463 | { |
---|
464 | irc_usermsg( irc, "Error while renaming temporary configuration file." ); |
---|
465 | |
---|
466 | g_free( path2 ); |
---|
467 | unlink( path ); |
---|
468 | |
---|
469 | return STORAGE_OTHER_ERROR; |
---|
470 | } |
---|
471 | |
---|
472 | g_free( path2 ); |
---|
473 | |
---|
474 | return STORAGE_OK; |
---|
475 | |
---|
476 | write_error: |
---|
477 | g_free( pass_buf ); |
---|
478 | |
---|
479 | irc_usermsg( irc, "Write error. Disk full?" ); |
---|
480 | close( fd ); |
---|
481 | |
---|
482 | return STORAGE_OTHER_ERROR; |
---|
483 | } |
---|
484 | |
---|
485 | static gboolean xml_save_nick( gpointer key, gpointer value, gpointer data ) |
---|
486 | { |
---|
487 | return !xml_printf( *( (int*) data ), 2, "<buddy handle=\"%s\" nick=\"%s\" />\n", key, value ); |
---|
488 | } |
---|
489 | |
---|
490 | static storage_status_t xml_remove( const char *nick, const char *password ) |
---|
491 | { |
---|
492 | char s[512], *lc; |
---|
493 | storage_status_t status; |
---|
494 | |
---|
495 | status = xml_check_pass( nick, password ); |
---|
496 | if( status != STORAGE_OK ) |
---|
497 | return status; |
---|
498 | |
---|
499 | lc = g_strdup( nick ); |
---|
500 | nick_lc( lc ); |
---|
501 | g_snprintf( s, 511, "%s%s%s", global.conf->configdir, lc, ".xml" ); |
---|
502 | g_free( lc ); |
---|
503 | |
---|
504 | if( unlink( s ) == -1 ) |
---|
505 | return STORAGE_OTHER_ERROR; |
---|
506 | |
---|
507 | return STORAGE_OK; |
---|
508 | } |
---|
509 | |
---|
510 | storage_t storage_xml = { |
---|
511 | .name = "xml", |
---|
512 | .init = xml_init, |
---|
513 | .check_pass = xml_check_pass, |
---|
514 | .remove = xml_remove, |
---|
515 | .load = xml_load, |
---|
516 | .save = xml_save |
---|
517 | }; |
---|