~ubuntu-branches/ubuntu/trusty/couchdb/trusty

« back to all changes in this revision

Viewing changes to src/couchdb/priv/couch_js/sm180.c

  • Committer: Package Import Robot
  • Author(s): Jason Gerard DeRose
  • Date: 2013-08-28 16:28:32 UTC
  • mfrom: (1.3.4)
  • Revision ID: package-import@ubuntu.com-20130828162832-gp22vmgpfzhk2zyu
Tags: 1.4.0-0ubuntu1
* New upstream release (LP: #1212481)
* Switch from CDBS to pure debhelper (compat 9)
* Bump Standards-Version to 3.9.4
* Use an Upstart job instead of the upstream SysV init.d script
* Remove Build-Depends: cdbs, libreadline-dev
* Add Build-Depends: erlang-os-mon, erlang-syntax-tools, python-sphinx,
  texlive-latex-base, texlive-latex-recommended, texlive-latex-extra,
  texlive-fonts-recommended, texinfo
* Remove couchdb-bin Depends: procps, lsb-base (needed for SysV init.d script)
* Remove couchdb-bin Depends: libjs-jquery (1.7.2 is in Saucy, but the
  internal CouchDB jquery is now at version 1.8.3)
* Simplify Erlang couchdb-bin Depends to just:
  ${erlang-abi:Depends}, ${erlang:Depends}
* Add couchdb Depends: upstart
* Remove deprecated couchdb-bin.postrm
* Thanks to the Upstart job, couchdb.postrm no longer needs `sleep 3` hack,
  nor needs to `rm -r -f "/var/run/couchdb"`
* Stop using versioned database_dir /var/lib/couchdb/VERSION as this isn't
  done upstream and CouchDB is no longer considered alpha software
* Remove README.Debian, README.source as they're no longer applicable
* Drop patches superseded upstream for CVE-2012-5649, CVE-2012-5650:
  - improve_parsing_of_mochiweb_relative_paths.patch
  - improve_script_url_validation.patch
  - include_a_comment_before_jsonp_output.patch
* Because of the switch to Upstart, drop unneeded SysV init.d script patches:
  - force-reload.patch
  - couchdb_own_rundir.patch
  - wait_for_couchdb_stop.patch
* Drop couchdb_sighup.patch, superseded upstream
* Drop logrotate_as_couchdb.patch as it doesn't make sense for the CouchDB
  daemon to be able to modify its own archived log files
* Move static data and docs in "/usr/share/couchdb" from `couchdb-bin` into
  new `couchdb-common` Architecture:all package
* Add couchdb-bin Depends: couchdb-common (= ${source:Version})
* debian/watch: point to current download location
* debian/rules: replace `get-orig-source` with `get-packaged-orig-source`

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
 
117
117
 
118
118
static JSBool
 
119
base_url(JSContext *cx, JSObject* obj, jsid pid, jsval* vp)
 
120
{
 
121
    couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
 
122
    return http_uri(cx, obj, args, &JS_RVAL(cx, vp));
 
123
}
 
124
 
 
125
 
 
126
static JSBool
119
127
evalcx(JSContext *cx, uintN argc, jsval* vp)
120
128
{
121
129
    jsval* argv = JS_ARGV(cx, vp);
126
134
    size_t srclen;
127
135
    jsval rval;
128
136
    JSBool ret = JS_FALSE;
 
137
    char *name = NULL;
129
138
 
130
139
    sandbox = NULL;
131
140
    if(!JS_ConvertArguments(cx, argc, argv, "S / o", &str, &sandbox)) {
150
159
        }
151
160
    }
152
161
 
 
162
    if(argc > 2) {
 
163
      name = enc_string(cx, argv[2], NULL);
 
164
    }
 
165
 
153
166
    if(srclen == 0) {
154
167
        JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(sandbox));
155
168
    } else {
156
 
        JS_EvaluateUCScript(subcx, sandbox, src, srclen, NULL, 0, &rval);
 
169
        JS_EvaluateUCScript(subcx, sandbox, src, srclen, name, 1, &rval);
157
170
        JS_SET_RVAL(cx, vp, rval);
158
171
    }
159
172
    
160
173
    ret = JS_TRUE;
161
174
 
162
175
done:
 
176
    if(name) JS_free(cx, name);
163
177
    FINISH_REQUEST(subcx);
164
178
    JS_DestroyContext(subcx);
165
179
    return ret;
253
267
 
254
268
JSPropertySpec CouchHTTPProperties[] = {
255
269
    {"status", 0, JSPROP_READONLY, req_status, NULL},
 
270
    {"base_url", 0, JSPROP_READONLY | JSPROP_SHARED, base_url, NULL},
256
271
    {0, 0, 0, 0, 0}
257
272
};
258
273
 
304
319
    size_t slen;
305
320
    jsval sroot;
306
321
    jsval result;
 
322
    int i;
307
323
 
308
324
    couch_args* args = couch_parse_args(argc, argv);
309
 
    
310
 
    rt = JS_NewRuntime(64L * 1024L * 1024L);
 
325
 
 
326
    rt = JS_NewRuntime(args->stack_size);
311
327
    if(rt == NULL)
312
328
        return 1;
313
329
 
314
 
    cx = JS_NewContext(rt, args->stack_size);
 
330
    cx = JS_NewContext(rt, 8L * 1024L);
315
331
    if(cx == NULL)
316
332
        return 1;
317
333
 
318
334
    JS_SetErrorReporter(cx, couch_error);
319
335
    JS_ToggleOptions(cx, JSOPTION_XML);
 
336
    JS_SetContextPrivate(cx, args);
320
337
    
321
338
    SETUP_REQUEST(cx);
322
339
 
351
368
        }
352
369
    } 
353
370
 
354
 
    // Convert script source to jschars.
355
 
    scriptsrc = dec_string(cx, args->script, strlen(args->script));
356
 
    if(!scriptsrc)
357
 
        return 1;
358
 
 
359
 
    schars = JS_GetStringChars(scriptsrc);
360
 
    slen = JS_GetStringLength(scriptsrc);
361
 
    
362
 
    // Root it so GC doesn't collect it.
363
 
    sroot = STRING_TO_JSVAL(scriptsrc); 
364
 
    if(JS_AddRoot(cx, &sroot) != JS_TRUE) {
365
 
        fprintf(stderr, "Internal root error.\n");
366
 
        return 1;
367
 
    }
368
 
 
369
 
    // Compile and run
370
 
    script = JS_CompileUCScript(cx, global, schars, slen, args->script_name, 1);
371
 
    if(!script) {
372
 
        fprintf(stderr, "Failed to compile script.\n");
373
 
        return 1;
374
 
    }
375
 
    
376
 
    JS_ExecuteScript(cx, global, script, &result);
377
 
 
378
 
    // Warning message if we don't remove it.
379
 
    JS_RemoveRoot(cx, &sroot);
 
371
    for (i = 0 ; args->scripts[i] ; i++) {
 
372
        // Convert script source to jschars.
 
373
        scriptsrc = couch_readfile(cx, args->scripts[i]);
 
374
        if(!scriptsrc)
 
375
            return 1;
 
376
 
 
377
        schars = JS_GetStringChars(scriptsrc);
 
378
        slen = JS_GetStringLength(scriptsrc);
 
379
 
 
380
        // Root it so GC doesn't collect it.
 
381
        sroot = STRING_TO_JSVAL(scriptsrc);
 
382
        if(JS_AddRoot(cx, &sroot) != JS_TRUE) {
 
383
            fprintf(stderr, "Internal root error.\n");
 
384
            return 1;
 
385
        }
 
386
 
 
387
        // Compile and run
 
388
        script = JS_CompileUCScript(cx, global, schars, slen,
 
389
                                    args->scripts[i], 1);
 
390
        if(!script) {
 
391
            fprintf(stderr, "Failed to compile script.\n");
 
392
            return 1;
 
393
        }
 
394
 
 
395
        JS_ExecuteScript(cx, global, script, &result);
 
396
 
 
397
        // Warning message if we don't remove it.
 
398
        JS_RemoveRoot(cx, &sroot);
 
399
    }
380
400
 
381
401
    FINISH_REQUEST(cx);
382
402
    JS_DestroyContext(cx);