[英]Undefined symbol when attempting to call pam_start from js-ctypes
Having recently fallen in love with js-ctypes (really handy for writing small applications that need access to some underlying OS functionality), I'm attempting to use them for a small login manager prototype where I'd like to expose PAM. 最近爱上了js-ctypes(对于编写需要访问某些底层操作系统功能的小应用程序非常方便),我试图将它们用于我想要公开PAM的小型登录管理器原型。
For this, I've been following a GNU/Linux display manager tutorial, compiling the pam.c file found in its Github ^1 repository and calling login(const char *username, const char *password, pid_t *child_pid)
from my javascript code. 为此,我一直在关注GNU / Linux显示管理器教程,编译在其Github ^ 1存储库中找到的pam.c文件,并从我的javascript调用
login(const char *username, const char *password, pid_t *child_pid)
码。
I used the following commands to compile the library : 我使用以下命令编译库:
The javascript calling code is as follows (user and pw are two textboxes defined in XUL): javascript调用代码如下(用户和pw是在XUL中定义的两个文本框):
function login(user, pw) {
var {ctypes} = Components.utils.import("resource://gre/modules/ctypes.jsm", null);
Components.utils.import("resource://gre/modules/Services.jsm");
var cr = Components.classes['@mozilla.org/chrome/chrome-registry;1'].getService(Components.interfaces.nsIChromeRegistry);
var chromeURI_myLib = Services.io.newURI('chrome://app/content/lib/pam.so', 'UTF-8', null);
var localFile_myLib = cr.convertChromeURL(chromeURI_myLib);
var jarPath_myLib = localFile_myLib.spec;
var filePath_myLib = localFile_myLib.path;
var libc = ctypes.open(filePath_myLib);
/* Import a function */
var loginFunc = libc.declare("login", /* function name */
ctypes.default_abi, /* call ABI */
ctypes.int,
ctypes.char.ptr,
ctypes.char.ptr);
loginFunc(user, pw);
}
Unfortunately, when running the application and calling this function, the application quits with the following error message 不幸的是,在运行应用程序并调用此函数时,应用程序退出并显示以下错误消息
symbol lookup error: /login-manager/chrome/content/lib/pam.so: undefined symbol: pam_start
pam_start is defined outside the scope of the pam.c/pam.h provided with the tutorial. pam_start的定义超出了本教程提供的pam.c / pam.h的范围。 It's definition can be found inside
/usr/lib/security/pam_appl.h
. 它的定义可以在
/usr/lib/security/pam_appl.h
找到。 How can I alleviate this fact and create a shared object that will let me properly call the login()
and logout()
functions provided as part of the original tutorial ^2 ? 如何缓解这一事实并创建一个共享对象,让我正确调用作为原始教程^ 2的一部分提供的
login()
和logout()
函数?
Fixed it about a month ago. 修正了大约一个月前。 Turned out to be a linking problem.
原来是一个链接问题。 Here is how to properly compile it against libpam.
以下是如何针对libpam正确编译它。
gcc -fPIC -c DM.c
gcc -shared -o DM.so DM.o -lpam
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.