[Vm-dev] trouble with FFI primitives
Michael Haupt
mhaupt at gmail.com
Fri Oct 23 12:41:41 UTC 2009
Hi,
we're experiencing something strange with Squeak and FFI on Linux.
Could someone please give us some insight on the problem at hand, and
how to solve it?
/usr/lib/squeak/3.11.3-2135/so.SqueakFFIPrims: cannot enable
executable stack as shared object requires: Permission denied
We have code compiled with gcc 4.4.2. We expose one method that works
perfectly well when called from C - but we need to call it from
Squeak. The code is pasted below.
Best,
Michael
-----header file-----
#include <krb5.h>
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
static int Krb5_get_init_creds_password_proxy(char* userString, int
userSize, char* pwString, int pwSize);
static char Krb5_get_init_creds_password(char* user, char* pass);
-----end of header-----
-----C file-----
#include <krb5_simple_auth.h>
struct krb5_object {
krb5_context ctx;
krb5_creds creds;
krb5_principal princ;
};
/*
* call-seq:
* new
*
* Create a new Krb5Auth::Krb5 object. This must be called before any
other methods are called. Returns true on success, raises
Krb5Auth::Krb5::Exception on failure.
*/
static struct krb5_object * Krb5_new()
{
struct krb5_object *kerb;
krb5_error_code krbret;
kerb = (struct krb5_object *)malloc(sizeof(struct krb5_object));
if (kerb == NULL) /* fail */;
memset(kerb, 0, sizeof(struct krb5_object));
krbret = krb5_init_context(&kerb->ctx);
if (krbret) /* fail */;
return kerb;
}
/*
* call-seq:
* get_init_creds_password(username, password)
*
* Call krb5_get_init_creds_password() to get credentials based on a
username and password. Returns true on success, raises
Krb5Auth::Krb5::Exception on failure.
*/
static char Krb5_get_init_creds_password(char* user, char* pass)
{
struct krb5_object *kerb = Krb5_new();
krb5_error_code krbret;
krbret = krb5_parse_name(kerb->ctx, user, &kerb->princ);
if (krbret) {
//fail
}
krbret = krb5_get_init_creds_password(kerb->ctx, &kerb->creds, kerb->princ,
pass, 0, NULL, 0,NULL, NULL);
if (krbret)
return 0;
else
return 1;
}
static int Krb5_get_init_creds_password_proxy(char* userString, int
userSize, char* pwString, int pwSize) {
char* user = (char*)calloc(userSize+1, sizeof(char));
char* password = (char*)calloc(pwSize+1, sizeof(char));
strncpy(user, userString, userSize);
user[userSize] = '\0';
strncpy(password, pwString, pwSize);
user[pwSize] = '\0';
return (int)Krb5_get_init_creds_password(user, password);
}
int main(int argc, char** argv) {
if (argc < 3) return 1;
printf("User %s with %s: %d\n", argv[1], argv[2],
(int)Krb5_get_init_creds_password(argv[1], argv[2]));
return 0;
}
-----end of C file-----
More information about the Vm-dev
mailing list