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