Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/scripting/python/modules.c

    r414 r745  
    1818*/
    1919
     20#include <Python.h>
    2021#include "includes.h"
    2122#include "scripting/python/modules.h"
    22 #include <Python.h>
     23#include "dynconfig/dynconfig.h"
    2324
    24 extern void init_ldb(void);
    25 extern void init_security(void);
    26 extern void init_registry(void);
    27 extern void init_param(void);
    28 extern void init_misc(void);
    29 extern void init_ldb(void);
    30 extern void init_auth(void);
    31 extern void init_credentials(void);
    32 extern void init_tdb(void);
    33 extern void init_dcerpc(void);
    34 extern void init_events(void);
    35 extern void inituuid(void);
    36 extern void init_net(void);
    37 extern void initecho(void);
    38 extern void initdfs(void);
    39 extern void initdrsuapi(void);
    40 extern void initwinreg(void);
    41 extern void initepmapper(void);
    42 extern void initinitshutdown(void);
    43 extern void initmgmt(void);
    44 extern void initnet(void);
    45 extern void initatsvc(void);
    46 extern void initsamr(void);
    47 extern void initlsa(void);
    48 extern void initsvcctl(void);
    49 extern void initwkssvc(void);
    50 extern void initunixinfo(void);
    51 extern void init_libcli_nbt(void);
    52 extern void init_libcli_smb(void);
     25static bool PySys_PathPrepend(PyObject *list, const char *path)
     26{
     27        PyObject *py_path = PyString_FromString(path);
     28        if (py_path == NULL)
     29                return false;
    5330
    54 static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES };
    55 
    56 void py_load_samba_modules(void)
    57 {
    58         int i;
    59         for (i = 0; i < ARRAY_SIZE(py_modules); i++) {
    60                 PyImport_ExtendInittab(&py_modules[i]);
    61         }
     31        return (PyList_Insert(list, 0, py_path) == 0);
    6232}
    6333
    64 void py_update_path(const char *bindir)
     34bool py_update_path(void)
    6535{
    66         char *newpath;
    67         asprintf(&newpath, "%s/python:%s/../scripting/python:%s", bindir, bindir, Py_GetPath());
    68         PySys_SetPath(newpath);
    69         free(newpath);
     36        PyObject *mod_sys, *py_path;
     37
     38        mod_sys = PyImport_ImportModule("sys");
     39        if (mod_sys == NULL) {
     40                return false;
     41        }
     42
     43        py_path = PyObject_GetAttrString(mod_sys, "path");
     44        if (py_path == NULL) {
     45                return false;
     46        }       
     47
     48        if (!PyList_Check(py_path)) {
     49                return false;
     50        }
     51
     52        if (!PySys_PathPrepend(py_path, dyn_PYTHONDIR)) {
     53                return false;
     54        }
     55
     56        if (strcmp(dyn_PYTHONARCHDIR, dyn_PYTHONDIR) != 0) {
     57                if (!PySys_PathPrepend(py_path, dyn_PYTHONARCHDIR)) {
     58                        return false;
     59                }
     60        }
     61
     62        return true;
    7063}
Note: See TracChangeset for help on using the changeset viewer.