Merge "ARI: Run 'make ari-stubs'"
authorJoshua Colp <jcolp@digium.com>
Tue, 16 Apr 2019 12:29:45 +0000 (07:29 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Tue, 16 Apr 2019 12:29:45 +0000 (07:29 -0500)
addons/chan_ooh323.c
addons/chan_ooh323.h
addons/ooh323c/src/ooh323ep.c
addons/ooh323c/src/ooh323ep.h
apps/app_voicemail.c
main/pbx.c
res/ael/pval.c
tests/CI/gateTestGroups.json
tests/CI/gates.jenkinsfile
tests/CI/periodic-dailyTestGroups.json
tests/CI/periodics-daily.jenkinsfile

index 6a65b5f..3fe29cc 100644 (file)
@@ -82,7 +82,7 @@
 /* Defaults */
 #define DEFAULT_CONTEXT "default"
 #define DEFAULT_H323ID "Asterisk PBX"
-#define DEFAULT_LOGFILE "/var/log/asterisk/h323_log"
+#define DEFAULT_LOGFILE "h323_log"
 #define DEFAULT_H323ACCNT "ast_h323"
 
 /* Flags */
@@ -346,7 +346,8 @@ void onModeChanged(ooCallData *call, int t38mode);
 
 extern OOH323EndPoint gH323ep;
 
-static char gLogFile[256] = DEFAULT_LOGFILE;
+static char gLogFile[PATH_MAX] = DEFAULT_LOGFILE;
+static char gInitError[256] = "";
 static int  gPort = 1720;
 static char gIP[2+8*4+7];      /* Max for IPv6 addr */
 struct ast_sockaddr bindaddr;
@@ -2856,7 +2857,7 @@ int reload_config(int reload)
        }
 
        /* Inintialize everything to default */
-       strcpy(gLogFile, DEFAULT_LOGFILE);
+       snprintf(gLogFile, sizeof(gLogFile), "%s/%s", ast_config_AST_LOG_DIR, DEFAULT_LOGFILE);
        gPort = 1720;
        gIP[0] = '\0';
        strcpy(gCallerID, DEFAULT_H323ID);
@@ -3034,7 +3035,11 @@ int reload_config(int reload)
                        ast_copy_string(gRASIP, v->value, sizeof(gRASIP));
                        ast_verb(3, "  == Setting RAS IP to %s\n", gRASIP);
                } else if (!strcasecmp(v->name, "logfile")) {
-                       ast_copy_string(gLogFile, v->value, sizeof(gLogFile));
+                       if (v->value[0] == '/') {
+                               ast_copy_string(gLogFile, v->value, sizeof(gLogFile));
+                       } else {
+                               snprintf(gLogFile, sizeof(gLogFile), "%s/%s", ast_config_AST_LOG_DIR, v->value);
+                       }
                } else if (!strcasecmp(v->name, "context")) {
                        ast_copy_string(gContext, v->value, sizeof(gContext));
                        ast_verb(3, "  == Setting default context to %s\n", gContext);
@@ -3838,9 +3843,9 @@ static int load_module(void)
        if (!reload_config(0)) {
 
                /* fire up the H.323 Endpoint */
-               if (OO_OK != ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, gLogFile)) {
-                       ast_log(LOG_ERROR, "Failed to initialize OOH323 endpoint-"
-                            "OOH323 Disabled\n");
+               if (OO_OK != ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, gLogFile, gInitError, sizeof(gInitError))) {
+                       ast_log(LOG_ERROR, "Failed to initialize OOH323 endpoint: %s"
+                               "OOH323 Disabled\n", gInitError);
                        ao2_ref(gCap, -1);
                        gCap = NULL;
                        ao2_ref(ooh323_tech.capabilities, -1);
index e4d285e..1bd3812 100644 (file)
@@ -65,6 +65,7 @@
 #include "asterisk/udptl.h"
 #include "asterisk/stasis_channels.h"
 #include "asterisk/format_cache.h"
+#include "asterisk/paths.h"
 
 #include "ootypes.h"
 #include "ooUtils.h"
index 1dedecd..be43896 100644 (file)
@@ -34,7 +34,7 @@ ast_mutex_t bindPortLock;
 extern DList g_TimerList;
 
 int ooH323EpInitialize
-   (enum OOCallMode callMode, const char* tracefile)
+   (enum OOCallMode callMode, const char* tracefile, char* errstr, int errstr_max)
 {
 
    memset(&gH323ep, 0, sizeof(ooEndPoint));
@@ -46,7 +46,7 @@ int ooH323EpInitialize
    {
       if(strlen(tracefile)>= MAXFILENAME)
       {
-         printf("Error:File name longer than allowed maximum %d\n",
+         snprintf(errstr, errstr_max, "Error:File name longer than allowed maximum %d\n",
                  MAXFILENAME-1);
          return OO_FAILED;
       }
@@ -59,7 +59,7 @@ int ooH323EpInitialize
    gH323ep.fptraceFile = fopen(gH323ep.traceFile, "a");
    if(gH323ep.fptraceFile == NULL)
    {
-      printf("Error:Failed to open trace file %s for write.\n",
+      snprintf(errstr, errstr_max, "Error:Failed to open trace file %s for write.\n",
                   gH323ep.traceFile);
       return OO_FAILED;
    }
index a77b9e3..5c9c3dd 100644 (file)
@@ -163,7 +163,7 @@ typedef struct OOH323EndPoint {
  * @return               OO_OK, on success. OO_FAILED, on failure
  */
 EXTERN int ooH323EpInitialize
-   (enum OOCallMode callMode, const char* tracefile);
+   (enum OOCallMode callMode, const char* tracefile, char* errstr, int errstr_max);
 
 /**
  * This function is used to represent the H.323 application endpoint as
index a151f0c..0e24731 100644 (file)
@@ -3812,6 +3812,54 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
 
 #endif /* IMAP_STORAGE */
 
+static void cleanup_orphaned_lock_files(const char *base)
+{
+       DIR *dir;
+       struct dirent *e;
+
+       dir = opendir(base);
+       if (!dir) {
+               /* Don't complain about this too loudly */
+               ast_debug(2, "Unable to open `%s': %s\n", base, strerror(errno));
+               return;
+       }
+
+       while ((e = readdir(dir))) {
+               char *fullpath;
+               struct stat s;
+
+               /* Always skip . and .. */
+               if (!strcmp(e->d_name, ".") || !strcmp(e->d_name, "..")) {
+                       continue;
+               }
+
+               /* Build up the full path (using dynamic memory because PATH_MAX is crap) */
+               if (ast_asprintf(&fullpath, "%s/%s", base, e->d_name) == -1) {
+                       break;
+               }
+
+               if (lstat(fullpath, &s) < 0) {
+                       ast_free(fullpath);
+                       continue;
+               }
+
+               /* This is exposing an implementation detail of ast_lock_path, but it makes
+                * our life a bit easier */
+               if (!strcmp(e->d_name, ".lock") && S_ISLNK(s.st_mode)) {
+                       if (!ast_unlock_path(base)) {
+                               ast_log(AST_LOG_NOTICE, "Cleaned up orphaned lock file: %s/.lock\n", base);
+                       }
+               } else if (S_ISDIR(s.st_mode)) {
+                       /* If it is a directory, let's dive down */
+                       cleanup_orphaned_lock_files(fullpath);
+               }
+
+               ast_free(fullpath);
+       }
+
+       closedir(dir);
+}
+
 /*! \brief Lock file path
  * only return failure if ast_lock_path returns 'timeout',
  * not if the path does not exist or any other reason
@@ -15355,6 +15403,9 @@ static int load_module(void)
        /* compute the location of the voicemail spool directory */
        snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);
 
+       /* Now that we have a spool directory, clean up old lock files */
+       cleanup_orphaned_lock_files(VM_SPOOL_DIR);
+
        if (!(mwi_subscription_tps = ast_taskprocessor_get("app_voicemail", 0))) {
                ast_log(AST_LOG_WARNING, "failed to reference mwi subscription taskprocessor.  MWI will not work\n");
        }
index ee5ed7e..4a83453 100644 (file)
@@ -8760,6 +8760,7 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string,
        char *stringp;
        int ipri;
        int mode = 0;
+       char rest[2] = "";
 
        if (ast_strlen_zero(goto_string)) {
                ast_log(LOG_WARNING, "Goto requires an argument ([[context,]extension,]priority)\n");
@@ -8785,7 +8786,7 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string,
                mode = -1;
                pri++;
        }
-       if (sscanf(pri, "%30d", &ipri) != 1) {
+       if (sscanf(pri, "%30d%1s", &ipri, rest) != 1) {
                ipri = ast_findlabel_extension(chan, context ? context : ast_channel_context(chan),
                        exten ? exten : ast_channel_exten(chan), pri,
                        S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
index f927077..c6623a4 100644 (file)
@@ -759,10 +759,10 @@ static int extension_matches(pval *here, const char *exten, const char *pattern)
                                *r++ = '.';
                                *r++ = '*';
                                break;
-                       case '*':
+                       case '*': /* regex metacharacter */
+                       case '+': /* regex metacharacter */
                                *r++ = '\\';
-                               *r++ = '*';
-                               break;
+                               /* fall through */
                        default:
                                *r++ = *p;
                                break;
@@ -792,14 +792,9 @@ static int extension_matches(pval *here, const char *exten, const char *pattern)
                           exten, pattern); */
                        return 1;
                }
-
-
-       } else {
-               if ( strcmp(exten,pattern) == 0 ) {
-                       return 1;
-               } else
-                       return 0;
        }
+
+       return 0;
 }
 
 
@@ -2924,7 +2919,7 @@ void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *arg_not
 /* "CODE" GENERATOR -- Convert the AEL representation to asterisk extension language */
 /* =============================================================================================== */
 
-static int control_statement_count = 0;
+static int control_statement_count;
 
 struct ael_priority *new_prio(void)
 {
@@ -4427,6 +4422,9 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo
        struct ael_extension *exten;
        struct ael_extension *exten_list = 0;
 
+       /* Reset the counter so that we get consistent labels between reloads */
+       control_statement_count = 0;
+
        for (p=root; p; p=p->next ) { /* do the globals first, so they'll be there
                                                                         when we try to eval them */
                switch (p->type) {
index d048896..415a7d7 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * This file is for reference/documentation only.
+ * The live configuration is defined in the Config Files
+ * settings of the Asterisk Gates Jenkins job.
+ * This allows is to alter the parameters at runtime.
+ */
+
 [
        {
                "name": "ari1",
index bc23781..a90b0cf 100644 (file)
@@ -159,7 +159,16 @@ pipeline {
                                                }
                                        }
 
-                                       def testGroups = readJSON file: "tests/CI/gateTestGroups.json"
+                                       def testGroups
+                                       configFileProvider([configFile(fileId: 'asterisk_gate_test_groups', variable: 'GATE_TEST_GROUPS')]) {
+                                       echo "Retrieved config file from ${env.GATE_TEST_GROUPS}"
+                                               testGroups = readJSON file: env.GATE_TEST_GROUPS
+                                       }
+                                       echo "Running test groups:"
+                                       for (def testGroup in testGroups) {
+                                               echo "${testGroup.name} ${testGroup.dir} ${testGroup.testcmd}"
+                                       }
+
                                        def parallelTasks = [ : ]
 
                                        for (def testGroup in testGroups) {
index 7f0fd7e..cc837f6 100644 (file)
@@ -1,3 +1,9 @@
+/*
+ * This file is for reference/documentation only.
+ * The live configuration is defined in the Config Files
+ * settings of the Asterisk Gates Jenkins job.
+ * This allows is to alter the parameters at runtime.
+ */
 [
        {
                "name": "ari ",
index ae762f8..ae5a5f4 100644 (file)
@@ -91,7 +91,12 @@ pipeline {
                                                }
                                        }
 
-                                       def testGroups = readJSON file: "tests/CI/periodic-dailyTestGroups.json"
+                                       def testGroups
+                                       configFileProvider([configFile(fileId: 'asterisk_daily_test_groups', variable: 'DAILY_TEST_GROUPS')]) {
+                                       echo "Retrieved config file from ${env.DAILY_TEST_GROUPS}"
+                                               testGroups = readJSON file: env.DAILY_TEST_GROUPS
+                                       }
+
                                        def parallelTasks = [ : ]
 
                                        for (def testGroup in testGroups) {