如何解决:在udev规则启动的脚本中,“无法为ffi.callback()分配写+执行内存”

问题描述 投票:0回答:1

通过cli启动时,我使用位于包azure.storage.blob中的BlockBlobService的python脚本运行完美,但是当通过udev规则启动时,它将显示以下消息:

azure.common.AzureException: Cannot allocate write+execute memory for ffi.callback().
You might be running on a system that prevents this.
For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks

我已经检查了某些安全模块,例如SELinux或PaX是否可以阻止内存分配。

user@hostname:~$ getenforce
Disabled
root@hostname:/# sysctl -a | grep pax
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.br-d8bcb5699c15.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.docker0.stable_secret"
sysctl: reading key "net.ipv6.conf.eno1.stable_secret"
sysctl: reading key "net.ipv6.conf.eno2.stable_secret"
sysctl: reading key "net.ipv6.conf.eno3.stable_secret"
sysctl: reading key "net.ipv6.conf.eno4.stable_secret"
sysctl: reading key "net.ipv6.conf.enp134s0f0.stable_secret"
sysctl: reading key "net.ipv6.conf.enp134s0f1.stable_secret"
sysctl: reading key "net.ipv6.conf.enp134s0f2.stable_secret"
sysctl: reading key "net.ipv6.conf.enp134s0f3.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.veth8b380d4.stable_secret"
sysctl: reading key "net.ipv6.conf.veth94be59b.stable_secret"

查看BlockBlobStorage代码。该文件的以下片段中引发了异常:azure.storage.common.storageclient.py:

415: logger.error("%s Retry policy did not allow for a retry: "
                  "%s, HTTP status code=%s, Exception=%s.",
                   client_request_id_prefix,
                   timestamp_and_request_id,
                   status_code,
                   exception_str_in_one_line)
     raise ex

查看cffi代码时。以下代码段似乎格式化了消息:文件:cffi / _cffi_backend.c

#ifdef CFFI_TRUST_LIBFFI
    closure = ffi_closure_alloc(sizeof(ffi_closure), &closure_exec);
#else
    closure = cffi_closure_alloc();
    closure_exec = closure;
#endif
    if (closure == NULL) {
        Py_DECREF(infotuple);
        PyErr_SetString(PyExc_MemoryError,
            "Cannot allocate write+execute memory for ffi.callback(). "
            "You might be running on a system that prevents this. "
            "For more information, see "
            "https://cffi.readthedocs.io/en/latest/using.html#callbacks");
        return NULL;
    }

根据udev规则启动时如何运行此脚本?

azure-blob-storage udev cffi
1个回答
0
投票

就我而言,上述错误是由于selinux增强了安全性配置。该错误指向django应用程序使用的cffi模块。我通过运行以下命令解决了该错误。希望对您有所帮助。

sudo setsebool -P httpd_execmem 1

请确保为您打算使用的服务寻找selinux bool设置并启用正确的配置。以下命令将列出您的服务的可用设置,并告诉您服务是打开还是关闭:

sudo getsebool -a | grep <service>
© www.soinside.com 2019 - 2024. All rights reserved.