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

« back to all changes in this revision

Viewing changes to main/manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Dave Walker (Daviey)
  • Date: 2009-09-22 16:22:14 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090922162214-awce8id0lt9v51jb
Tags: 1:1.6.2.0~rc2-0ubuntu1

* New upstream version, upstream is now DFSG compliant.
  - ilibc has been removed upstream.
  - Music on Hold is now cc-by-sa.
  - binary firmware iaxy.bin has been removed upstream.
* debian/rules: Santitised UPSTREAM variable for compatiability
  with Ubuntu and other variants.
* debian/control: Removed Debian Vcs-Svn entry and replaced 
  with ubuntu-voip Vcs-Bzr, to reflect divergence in packages.
* patches/makefile_appdocs_dtd: Removed, merged upstream.
* patches/disable_moh: Previosly disabled, removed from pool.
* patches/ubuntu-banner: Ported debian-banner to display Ubuntu
  centric bug report information.
* Refresh quilt patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
#include "asterisk.h"
45
45
 
46
 
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 207727 $")
 
46
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 214515 $")
47
47
 
48
48
#include "asterisk/_private.h"
49
49
#include "asterisk/paths.h"     /* use various ast_config_AST_* */
1169
1169
                return 0;
1170
1170
        }
1171
1171
        cfg = ast_config_load2(fn, "manager", config_flags);
1172
 
        if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
 
1172
        if (cfg == CONFIG_STATUS_FILEMISSING) {
1173
1173
                astman_send_error(s, m, "Config file not found");
1174
1174
                return 0;
 
1175
        } else if (cfg == CONFIG_STATUS_FILEINVALID) {
 
1176
                astman_send_error(s, m, "Config file has invalid format");
 
1177
                return 0;
1175
1178
        }
1176
1179
 
1177
1180
        astman_start_ack(s, m);
1211
1214
                return 0;
1212
1215
        }
1213
1216
        if (!(cfg = ast_config_load2(fn, "manager", config_flags))) {
1214
 
                astman_send_error(s, m, "Config file not found or file has invalid syntax");
 
1217
                astman_send_error(s, m, "Config file not found");
 
1218
                return 0;
 
1219
        } else if (cfg == CONFIG_STATUS_FILEINVALID) {
 
1220
                astman_send_error(s, m, "Config file has invalid format");
1215
1221
                return 0;
1216
1222
        }
1217
1223
        astman_start_ack(s, m);
1267
1273
        if (!(cfg = ast_config_load2(fn, "manager", config_flags))) {
1268
1274
                astman_send_error(s, m, "Config file not found");
1269
1275
                return 0;
 
1276
        } else if (cfg == CONFIG_STATUS_FILEINVALID) {
 
1277
                astman_send_error(s, m, "Config file has invalid format");
 
1278
                return 0;
1270
1279
        }
1271
1280
 
1272
1281
        buf_len = 512;
1486
1495
        if (!(cfg = ast_config_load2(sfn, "manager", config_flags))) {
1487
1496
                astman_send_error(s, m, "Config file not found");
1488
1497
                return 0;
 
1498
        } else if (cfg == CONFIG_STATUS_FILEINVALID) {
 
1499
                astman_send_error(s, m, "Config file has invalid format");
 
1500
                return 0;
1489
1501
        }
1490
1502
        result = handle_updates(s, m, cfg, dfn);
1491
1503
        if (!result) {
1591
1603
                idText[0] = '\0';
1592
1604
 
1593
1605
        if (!ast_strlen_zero(timeouts)) {
1594
 
                sscanf(timeouts, "%i", &timeout);
 
1606
                sscanf(timeouts, "%30i", &timeout);
1595
1607
                if (timeout < -1)
1596
1608
                        timeout = -1;
1597
1609
                /* XXX maybe put an upper bound, or prevent the use of 0 ? */
2077
2089
                astman_send_error(s, m, "Channel not specified");
2078
2090
                return 0;
2079
2091
        }
2080
 
        if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) {
 
2092
        if (!ast_strlen_zero(priority) && (sscanf(priority, "%30d", &pi) != 1)) {
2081
2093
                if ((pi = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) {
2082
2094
                        astman_send_error(s, m, "Invalid priority");
2083
2095
                        return 0;
2242
2254
        const char *id = astman_get_header(m, "ActionID");
2243
2255
        char *buf, *final_buf;
2244
2256
        char template[] = "/tmp/ast-ami-XXXXXX";        /* template for temporary file */
2245
 
        int fd = mkstemp(template);
 
2257
        int fd;
2246
2258
        off_t l;
2247
2259
 
2248
2260
        if (ast_strlen_zero(cmd)) {
2255
2267
                return 0;
2256
2268
        }
2257
2269
 
 
2270
        fd = mkstemp(template);
 
2271
 
2258
2272
        astman_append(s, "Response: Follows\r\nPrivilege: Command\r\n");
2259
2273
        if (!ast_strlen_zero(id))
2260
2274
                astman_append(s, "ActionID: %s\r\n", id);
2398
2412
                astman_send_error(s, m, "Channel not specified");
2399
2413
                return 0;
2400
2414
        }
2401
 
        if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) {
 
2415
        if (!ast_strlen_zero(priority) && (sscanf(priority, "%30d", &pi) != 1)) {
2402
2416
                if ((pi = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) {
2403
2417
                        astman_send_error(s, m, "Invalid priority");
2404
2418
                        return 0;
2405
2419
                }
2406
2420
        }
2407
 
        if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%d", &to) != 1)) {
 
2421
        if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%30d", &to) != 1)) {
2408
2422
                astman_send_error(s, m, "Invalid timeout");
2409
2423
                return 0;
2410
2424
        }
3793
3807
 
3794
3808
        for (v = params; v; v = v->next) {
3795
3809
                if (!strcasecmp(v->name, "mansession_id")) {
3796
 
                        sscanf(v->value, "%x", &ident);
 
3810
                        sscanf(v->value, "%30x", &ident);
3797
3811
                        break;
3798
3812
                }
3799
3813
        }
4089
4103
                return 0;
4090
4104
 
4091
4105
        displayconnects = 1;
4092
 
        if (!cfg) {
4093
 
                ast_log(LOG_NOTICE, "Unable to open AMI configuration manager.conf. Asterisk management interface (AMI) disabled.\n");
 
4106
        if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
 
4107
                ast_log(LOG_NOTICE, "Unable to open AMI configuration manager.conf, or configuration is invalid. Asterisk management interface (AMI) disabled.\n");
4094
4108
                return 0;
4095
4109
        }
4096
4110
 
4168
4182
 
4169
4183
        /* First, get users from users.conf */
4170
4184
        ucfg = ast_config_load2("users.conf", "manager", config_flags);
4171
 
        if (ucfg && (ucfg != CONFIG_STATUS_FILEUNCHANGED)) {
 
4185
        if (ucfg && (ucfg != CONFIG_STATUS_FILEUNCHANGED) && ucfg != CONFIG_STATUS_FILEINVALID) {
4172
4186
                const char *hasmanager;
4173
4187
                int genhasmanager = ast_true(ast_variable_retrieve(ucfg, "general", "hasmanager"));
4174
4188