~ubuntu-branches/ubuntu/karmic/asterisk/karmic

« back to all changes in this revision

Viewing changes to main/manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Faidon Liambotis, Tzafrir Cohen, Faidon Liambotis
  • Date: 2007-12-06 17:20:21 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206172021-pd0wrjirz3os7hia
Tags: 1:1.4.15~dfsg-1
* New upstream release (Closes: #452054)
  - Fix a potential corrupt of voicemail.conf on simultaneous PIN updates
    (Closes: #353227)

[ Tzafrir Cohen ]
* Add some sample/reference config files as documentation.
* Provide asterisk-bristuff for upgrading from Etch.
* Move libc-client to not be last, so debian/backports/xorcom.etch would
  still work.

[ Faidon Liambotis ]
* Really enable the libcap/ToS functionality; the previous patch didn't
  enable the functionality, even though the code and the libcap.so
  dependency were there. (Closes: #454342)
* Fix a minor issue with init script's stop target when running with
  safe_asterisk.
* Add chan_vpb, adding support for VoiceTronix OpenSwitch and OpenLine
  cards. (Closes: #396499)
* Fix debian/watch by using a pkg-voip wrapper to avoid upstream's silly
  redirections. (Closes: #449706)
* Use DEBVERSION as asterisk's version string.
* Disable the MD5 build sum that breaks all out-of-tree plugins (duh!).
* Create /usr/local/share/asterisk/sounds to put all site-specific
  non-modifiable sounds.
* Add a note about bugs.debian.org to the banner.
* Add noload for res_config_* since loading them results in errors and
  doesn't provide any functionality.
* News entries were added but we never shipped the file; ship NEWS.Debian.
* Add an entry to NEWS.Debian warning users about app_voicemail_*.so
  (Closes: #452596)
* Provide options in /etc/default/asterisk for configuring safe_asterisk.
  (Closes: #381786)

[ Tzafrir Cohen ]
* Provide a custom sounds directory under /var/lib - user-modifieble at
  runtime and hence not under /usr. (Closes: #337209)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
#include "asterisk.h"
36
36
 
37
 
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 84742 $")
 
37
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 90098 $")
38
38
 
39
39
#include <stdio.h>
40
40
#include <stdlib.h>
69
69
#include "asterisk/threadstorage.h"
70
70
#include "asterisk/linkedlists.h"
71
71
#include "asterisk/term.h"
 
72
#include "asterisk/astobj2.h"
72
73
 
73
74
struct fast_originate_helper {
74
75
        char tech[AST_MAX_EXTENSION];
274
275
        }
275
276
}
276
277
 
 
278
struct variable_count {
 
279
        char *varname;
 
280
        int count;
 
281
};
 
282
 
 
283
static int compress_char(char c)
 
284
{
 
285
        c &= 0x7f;
 
286
        if (c < 32)
 
287
                return 0;
 
288
        else if (c >= 'a' && c <= 'z')
 
289
                return c - 64;
 
290
        else if (c > 'z')
 
291
                return '_';
 
292
        else
 
293
                return c - 32;
 
294
}
 
295
 
 
296
static int variable_count_hash_fn(const void *vvc, const int flags)
 
297
{
 
298
        const struct variable_count *vc = vvc;
 
299
        int res = 0, i;
 
300
        for (i = 0; i < 5; i++) {
 
301
                if (vc->varname[i] == '\0')
 
302
                        break;
 
303
                res += compress_char(vc->varname[i]) << (i * 6);
 
304
        }
 
305
        return res;
 
306
}
 
307
 
 
308
static int variable_count_cmp_fn(void *obj, void *vstr, int flags)
 
309
{
 
310
        /* Due to the simplicity of struct variable_count, it makes no difference
 
311
         * if you pass in objects or strings, the same operation applies. This is
 
312
         * due to the fact that the hash occurs on the first element, which means
 
313
         * the address of both the struct and the string are exactly the same. */
 
314
        struct variable_count *vc = obj;
 
315
        char *str = vstr;
 
316
        return !strcmp(vc->varname, str) ? CMP_MATCH : 0;
 
317
}
 
318
 
277
319
static char *xml_translate(char *in, struct ast_variable *vars)
278
320
{
279
321
        struct ast_variable *v;
287
329
        int escaped = 0;
288
330
        int inobj = 0;
289
331
        int x;
290
 
        
 
332
        struct variable_count *vc = NULL;
 
333
        struct ao2_container *vco = NULL;
 
334
 
291
335
        for (v = vars; v; v = v->next) {
292
336
                if (!dest && !strcasecmp(v->name, "ajaxdest"))
293
337
                        dest = v->value;
303
347
                        colons++;
304
348
                else if (in[x] == '\n')
305
349
                        breaks++;
306
 
                else if (strchr("&\"<>", in[x]))
 
350
                else if (strchr("&\"<>\'", in[x]))
307
351
                        escaped++;
308
352
        }
309
353
        len = (size_t) (strlen(in) + colons * 5 + breaks * (40 + strlen(dest) + strlen(objtype)) + escaped * 10); /* foo="bar", "<response type=\"object\" id=\"dest\"", "&amp;" */
319
363
                        if ((count > 3) && inobj) {
320
364
                                ast_build_string(&tmp, &len, " /></response>\n");
321
365
                                inobj = 0;
 
366
 
 
367
                                /* Entity is closed, so close out the name cache */
 
368
                                ao2_ref(vco, -1);
 
369
                                vco = NULL;
322
370
                        }
323
371
                        count = 0;
324
372
                        while (*in && (*in < 32)) {
333
381
                                if (*val == ' ')
334
382
                                        val++;
335
383
                                if (!inobj) {
 
384
                                        vco = ao2_container_alloc(37, variable_count_hash_fn, variable_count_cmp_fn);
336
385
                                        ast_build_string(&tmp, &len, "<response type='object' id='%s'><%s", dest, objtype);
337
386
                                        inobj = 1;
338
387
                                }
339
 
                                ast_build_string(&tmp, &len, " ");                              
 
388
 
 
389
                                /* Check if the var has been used already */
 
390
                                if ((vc = ao2_find(vco, var, 0)))
 
391
                                        vc->count++;
 
392
                                else {
 
393
                                        /* Create a new entry for this one */
 
394
                                        vc = ao2_alloc(sizeof(*vc), NULL);
 
395
                                        vc->varname = var;
 
396
                                        vc->count = 1;
 
397
                                        /* Increment refcount, because we're going to deref once later */
 
398
                                        ao2_ref(vc, 1);
 
399
                                        ao2_link(vco, vc);
 
400
                                }
 
401
 
 
402
                                ast_build_string(&tmp, &len, " ");
340
403
                                xml_copy_escape(&tmp, &len, var, 1);
 
404
                                if (vc->count > 1)
 
405
                                        ast_build_string(&tmp, &len, "-%d", vc->count);
341
406
                                ast_build_string(&tmp, &len, "='");
342
407
                                xml_copy_escape(&tmp, &len, val, 0);
343
408
                                ast_build_string(&tmp, &len, "'");
 
409
                                ao2_ref(vc, -1);
344
410
                        }
345
411
                }
346
412
        }
347
413
        if (inobj)
348
414
                ast_build_string(&tmp, &len, " /></response>\n");
 
415
        if (vco)
 
416
                ao2_ref(vco, -1);
349
417
        return out;
350
418
}
351
419
 
986
1054
                struct ast_variable *v;
987
1055
                const char *password = NULL;
988
1056
                int hasmanager = 0;
 
1057
                const char *readperms = NULL;
 
1058
                const char *writeperms = NULL;
 
1059
 
989
1060
                if (strcasecmp(cat, user) || !strcasecmp(cat, "general")) {
990
1061
                        cat = ast_category_browse(cfg, cat);
991
1062
                        continue;
995
1066
                                password = v->value;
996
1067
                        else if (!strcasecmp(v->name, "hasmanager"))
997
1068
                                hasmanager = ast_true(v->value);
 
1069
                        else if (!strcasecmp(v->name, "managerread"))
 
1070
                                readperms = v->value;
 
1071
                        else if (!strcasecmp(v->name, "managerwrite"))
 
1072
                                writeperms = v->value;
998
1073
                }
999
1074
                if (!hasmanager)
1000
1075
                        break;
1004
1079
                        return -1;
1005
1080
                }
1006
1081
                ast_copy_string(s->username, cat, sizeof(s->username));
1007
 
                s->readperm = -1;
1008
 
                s->writeperm = -1;
 
1082
                s->readperm = readperms ? get_perm(readperms) : -1;
 
1083
                s->writeperm = writeperms ? get_perm(writeperms) : -1;
1009
1084
                ast_config_destroy(cfg);
1010
1085
                if (events)
1011
1086
                        set_eventmask(s, events);
1648
1723
                        term_strip(final_buf, buf, l);
1649
1724
                        final_buf[l] = '\0';
1650
1725
                }
1651
 
                astman_append(s, S_OR(final_buf, buf));
 
1726
                astman_append(s, "%s", S_OR(final_buf, buf));
1652
1727
                ast_free(buf);
1653
1728
        }
1654
1729
        close(fd);