[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

lightdm: PAM unable to resolve symbol: pam_sm_setcred



Hello,

I have a pam module which I am able to compile and link without any
errors. However I keep on getting ...lightdm: PAM unable to resolve
symbol: pam_sm_setcred.

I saw somewhere that I was supposed to define pam_sm_setcred in my
module...I did that, but I keep on getting the same error...

I have attached my source code so that anybody who wish to help me will
get a clear understanding of what I'm trying to do....the module is
suppose to with matlab, everything from the matlab end is working
perfectly...I believe the only problem I have for the proper execution of
this code is ....

PAM unable to resolve symbol: pam_sm_setcred.

Thanks
Donkor Nicholas
/* $Revision: 1.1.6.2 $ */
/*
 *	engdemo.cpp
 *
 *	This is a simple program that illustrates how to call the MATLAB
 *	Engine functions from a C++ program.
 *
 * Copyright 1984-2007 The MathWorks, Inc.
 * All rights reserved
 */
#define DEFAULT_USER "nobody"
#define PAM_SM_AUTH
#define PAM_SM_ACCOUNT
#define PAM_SM_SESSION
/*#define PAM_SM_PASSWORD */
#include <security/pam_modules.h>
#include <security/_pam_macros.h>
#include <security/_pam_types.h>
/*#include <pwd.h>  getpwdid */

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include     <X11/Xlib.h>
#include     <X11/Xutil.h>

#include <engine.h>
//#include<string.h>


//#define  BUFSIZE 256

/**
*/


double val;







char * prevmsg;





PAM_EXTERN int
pam_sm_setcred(pam_handle_t *pamh, int flags,
    int argc, const char *argv[])
	{
	
	        (void)pamh;
	        (void)flags;
	        (void)argc;
	        (void)argv;
	        return (PAM_SUCCESS);
	}

/* --- account management functions --- */

PAM_EXTERN
int pam_sm_acct_mgmt(pam_handle_t *pamh,int flags,int argc
                     ,const char **argv)
{
    return PAM_SUCCESS;
}

/* --- password management --- */

PAM_EXTERN
int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc
                     ,const char **argv)
{
    return PAM_SUCCESS;
}

/* --- session management --- */

PAM_EXTERN
int pam_sm_open_session(pam_handle_t *pamh,int flags,int argc
                        ,const char **argv)
{
    return PAM_SUCCESS;
}

PAM_EXTERN
int pam_sm_close_session(pam_handle_t *pamh,int flags,int argc
                         ,const char **argv)
{
    return PAM_SUCCESS;
}





int msgPipeLiner(const char *msg)
{
    if (prevmsg!=0)
    {
        if (strcmp(prevmsg,msg)==0)
            return 0;
    }

    if (prevmsg!=0)
        free(prevmsg);
    prevmsg=(char *)calloc(strlen(msg)+1,sizeof(char));
    strcpy(prevmsg,msg);
    return 1;
}

static int send_info_msg(pam_handle_t *pamh, const char  *msg)
{
    if (msgPipeLiner(msg)==0)
        return 0;
    struct pam_message mymsg;
    mymsg.msg_style = PAM_TEXT_INFO;
    mymsg.msg = msg;
    const struct pam_message *msgp = &mymsg;
    const struct pam_conv *pc;
    struct pam_response *resp;
    int r;

    r = pam_get_item(pamh, PAM_CONV, (const void **) &pc);
    if (r != PAM_SUCCESS)
        return -1;

    if (!pc || !pc->conv)
        return -1;

    return pc->conv(1, &msgp, &resp, pc->appdata_ptr);
}



static int send_err_msg(pam_handle_t *pamh, const char *msg)
{
    if (msgPipeLiner(msg)==0)
        return 0;
    struct pam_message mymsg;
    mymsg.msg_style = PAM_ERROR_MSG;
    mymsg.msg = msg;

    const struct pam_message *msgp = &mymsg;
    const struct pam_conv *pc;
    struct pam_response *resp;
    int r;

    r = pam_get_item(pamh, PAM_CONV, (const void **) &pc);
    if (r != PAM_SUCCESS)
        return -1;

    if (!pc || !pc->conv)
        return -1;

    return pc->conv(1, &msgp, &resp, pc->appdata_ptr);
}




PAM_EXTERN
int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc
                        ,const char **argv)
{


/*
    
    struct pam_conv *conv;
	struct pam_message msg;
	const struct pam_message *msgp;
	struct pam_response *resp;

	struct passwd *pwd;
	//const char *user;
	char *pass, *password;
    int pam_err;
    
    
    
   	//struct pam_message msg;
    msg.msg_style = PAM_ERROR_MSG;
    //msg.msg = msg;
    msgp = &msg;

pam_err = (*conv->conv)(1, &msgp, &resp, conv->appdata_ptr);





password = resp->resp;

free(resp);

*/


//Custom authentication takes place here

Engine *ep;
	
	/*
	 * Plot the result
	 */

if (!(ep = engOpen(NULL))) {
      fprintf(stderr, "\nCan't start MATLAB engine\n");
      return EXIT_FAILURE;
   }



	engEvalString(ep, "chos=menu('Speaker Recognition System','Add a new sound from files','Add a new sound from microphone','Speaker Recognition from file','Speaker recognition from microphone','Load a sound from file for listening','Load a sound from microphone for listening','Database Info','Delete database','Source code','Exit');");




double *newr;
	mxArray *result;

	

	result = engGetVariable(ep,"chos");
	newr = mxGetPr(result);



	
if (*newr==1)
{
    
    


engEvalString(ep, "fs = 10000;");
engEvalString(ep, "t = hamming(4000);");
engEvalString(ep, "w = [t ; zeros(6000,1)];");
engEvalString(ep, "f = (1:10000);");
engEvalString(ep, "mel (f) = 2595 * log(1 + f / 700);");
engEvalString(ep, "tri = triang(100);");
engEvalString(ep, "win1 = [tri ; zeros(9900,1)];");
engEvalString(ep, "win2 = [zeros(50,1) ; tri ; zeros(9850,1)];");
engEvalString(ep, "win3 = [zeros(100,1) ; tri ; zeros(9800,1)];");
engEvalString(ep, "win4 = [zeros(150,1) ; tri ; zeros(9750,1)];");
engEvalString(ep, "win5 = [zeros(200,1) ; tri ; zeros(9700,1)];");
engEvalString(ep, "win6 = [zeros(250,1) ; tri ; zeros(9650,1)];");
engEvalString(ep, "win7 = [zeros(300,1) ; tri ; zeros(9600,1)];");
engEvalString(ep, "win8 = [zeros(350,1) ; tri ; zeros(9550,1)];");
engEvalString(ep, "win9 = [zeros(400,1) ; tri ; zeros(9500,1)];");
engEvalString(ep, "win10 = [zeros(450,1) ; tri ; zeros(9450,1)];");
engEvalString(ep, "win11 = [zeros(500,1) ; tri ; zeros(9400,1)];");
engEvalString(ep, "win12 = [zeros(550,1) ; tri ; zeros(9350,1)];");
engEvalString(ep, "win13 = [zeros(600,1) ; tri ; zeros(9300,1)];");
engEvalString(ep, "win14 = [zeros(650,1) ; tri ; zeros(9250,1)];");
engEvalString(ep, "win15 = [zeros(700,1) ; tri ; zeros(9200,1)];");
engEvalString(ep, "win16 = [zeros(750,1) ; tri ; zeros(9150,1)];");
engEvalString(ep, "win17 = [zeros(800,1) ; tri ; zeros(9100,1)];");
engEvalString(ep, "win18 = [zeros(850,1) ; tri ; zeros(9050,1)];");
engEvalString(ep, "win19 = [zeros(900,1) ; tri ; zeros(9000,1)];");
engEvalString(ep, "win20 = [zeros(950,1) ; tri ; zeros(8950,1)];");


engEvalString(ep, "x_object = audiorecorder(fs,8,1);");
engEvalString(ep, "recordblocking (x_object,1);");
engEvalString(ep, "x =getaudiodata (x_object,'double');");
engEvalString(ep, "");
//engEvalString(ep, "plot(x);");
engEvalString(ep, "sound(x,fs);");
//engEvalString(ep, "plot(x);");
engEvalString(ep, "i = 1;");
engEvalString(ep, "while (abs(x(i)) > 0.05)\
                          i = i + 1;\
                   end");
//engEvalString(ep, "            i = i + 1;");
//engEvalString(ep, "end");
engEvalString(ep, "plot(x);");


engEvalString(ep, "x(1 : i) = [];");
engEvalString(ep, "x(6000 : 10000) = 0;");
engEvalString(ep, "x1 = x.* w;");
engEvalString(ep, "mx = fft(x1);");
engEvalString(ep, "nx = abs(mx(floor(mel(f))));");
engEvalString(ep, "nx = nx./ max(nx);");
engEvalString(ep, "nx1 = nx.* win1;");
engEvalString(ep, "nx2 = nx.* win2;");
engEvalString(ep, "nx3 = nx.* win3;");
engEvalString(ep, "nx4 = nx.* win4;");
engEvalString(ep, "nx5 = nx.* win5;");
engEvalString(ep, "nx6 = nx.* win6;");
engEvalString(ep, "nx7 = nx.* win7;");
engEvalString(ep, "nx8 = nx.* win8;");
engEvalString(ep, "nx9 = nx.* win9;");
engEvalString(ep, "nx10 = nx.* win10;");
engEvalString(ep, "nx11 = nx.* win11;");
engEvalString(ep, "nx12 = nx.* win12;");
engEvalString(ep, "nx13 = nx.* win13;");
engEvalString(ep, "nx14 = nx.* win14;");
engEvalString(ep, "nx15 = nx.* win15;");
engEvalString(ep, "nx16 = nx.* win16;");
engEvalString(ep, "nx17 = nx.* win17;");
engEvalString(ep, "nx18 = nx.* win18;");
engEvalString(ep, "nx19 = nx.* win19;");
engEvalString(ep, "nx20 = nx.* win20;");
engEvalString(ep, "sx1 = sum(nx1.^ 2);");
engEvalString(ep, "sx2 = sum(nx2.^ 2);");
engEvalString(ep, "sx3 = sum(nx3.^ 2);");
engEvalString(ep, "sx4 = sum(nx4.^ 2);");
engEvalString(ep, "sx5 = sum(nx5.^ 2);");
engEvalString(ep, "sx6 = sum(nx6.^ 2);");
engEvalString(ep, "sx7 = sum(nx7.^ 2);");
engEvalString(ep, "sx8 = sum(nx8.^ 2);");
engEvalString(ep, "sx9 = sum(nx9.^ 2);");
engEvalString(ep, "sx10 = sum(nx10.^ 2);");
engEvalString(ep, "sx11 = sum(nx11.^ 2);");
engEvalString(ep, "sx12 = sum(nx12.^ 2);");
engEvalString(ep, "sx13 = sum(nx13.^ 2);");
engEvalString(ep, "sx14 = sum(nx14.^ 2);");
engEvalString(ep, "sx15 = sum(nx15.^ 2);");
engEvalString(ep, "sx16 = sum(nx16.^ 2);");
engEvalString(ep, "sx17 = sum(nx17.^ 2);");
engEvalString(ep, "sx18 = sum(nx18.^ 2);");
engEvalString(ep, "sx19 = sum(nx19.^ 2);");
engEvalString(ep, "sx20 = sum(nx20.^ 2);");
engEvalString(ep, "sx = [sx1, sx2, sx3, sx4, sx5, sx6, sx7, sx8, sx9, sx10, sx11, sx12, sx13, sx14, sx15, sx16, sx17,sx18, sx19, sx20];");
engEvalString(ep, "sx = log(sx);");
engEvalString(ep, "dx = dct(sx);");
engEvalString(ep, "fid=fopen('sample.dat','w+');");

engEvalString(ep, "fwrite (fid,dx,'real*8');");
engEvalString(ep, "fclose (fid);");

}
else if(*newr==4)
{
    
    
    send_info_msg(pamh, "Voice Verification Pluggable Authentication Module Started");

engEvalString(ep, "fs = 10000;");
engEvalString(ep, "t = hamming(4000);");
engEvalString(ep, "w = [t ; zeros(6000,1)];");
engEvalString(ep, "f = (1:10000);");
engEvalString(ep, "mel (f) = 2595 * log(1 + f / 700);");
engEvalString(ep, "tri = triang(100);");
engEvalString(ep, "win1 = [tri ; zeros(9900,1)];");
engEvalString(ep, "win2 = [zeros(50,1) ; tri ; zeros(9850,1)];");
engEvalString(ep, "win3 = [zeros(100,1) ; tri ; zeros(9800,1)];");
engEvalString(ep, "win4 = [zeros(150,1) ; tri ; zeros(9750,1)];");
engEvalString(ep, "win5 = [zeros(200,1) ; tri ; zeros(9700,1)];");
engEvalString(ep, "win6 = [zeros(250,1) ; tri ; zeros(9650,1)];");
engEvalString(ep, "win7 = [zeros(300,1) ; tri ; zeros(9600,1)];");
engEvalString(ep, "win8 = [zeros(350,1) ; tri ; zeros(9550,1)];");
engEvalString(ep, "win9 = [zeros(400,1) ; tri ; zeros(9500,1)];");
engEvalString(ep, "win10 = [zeros(450,1) ; tri ; zeros(9450,1)];");
engEvalString(ep, "win11 = [zeros(500,1) ; tri ; zeros(9400,1)];");
engEvalString(ep, "win12 = [zeros(550,1) ; tri ; zeros(9350,1)];");
engEvalString(ep, "win13 = [zeros(600,1) ; tri ; zeros(9300,1)];");
engEvalString(ep, "win14 = [zeros(650,1) ; tri ; zeros(9250,1)];");
engEvalString(ep, "win15 = [zeros(700,1) ; tri ; zeros(9200,1)];");
engEvalString(ep, "win16 = [zeros(750,1) ; tri ; zeros(9150,1)];");
engEvalString(ep, "win17 = [zeros(800,1) ; tri ; zeros(9100,1)];");
engEvalString(ep, "win18 = [zeros(850,1) ; tri ; zeros(9050,1)];");
engEvalString(ep, "win19 = [zeros(900,1) ; tri ; zeros(9000,1)];");
engEvalString(ep, "win20 = [zeros(950,1) ; tri ; zeros(8950,1)];");


engEvalString(ep, "y_object = audiorecorder(fs,8,1);");
engEvalString(ep, "recordblocking (y_object,1);");
engEvalString(ep, "y =getaudiodata (y_object,'double');");
engEvalString(ep, "");
engEvalString(ep, "sound(y,fs);");

engEvalString(ep, "i = 1;");
engEvalString(ep, "while (abs(y(i)) > 0.05)\
                                   i = i + 1;\
                   end");



engEvalString(ep, "y(1 : i) = [];");
engEvalString(ep, "y(6000 : 10000) = 0;");
engEvalString(ep, "y1 = y.* w;");
engEvalString(ep, "my = fft(y1);");
engEvalString(ep, "ny = abs(my(floor(mel(f))));");
engEvalString(ep, "ny = ny./ max(ny);");
engEvalString(ep, "ny1 = ny.* win1;");
engEvalString(ep, "ny2 = ny.* win2;");
engEvalString(ep, "ny3 = ny.* win3;");
engEvalString(ep, "ny4 = ny.* win4;");
engEvalString(ep, "ny5 = ny.* win5;");
engEvalString(ep, "ny6 = ny.* win6;");
engEvalString(ep, "ny7 = ny.* win7;");
engEvalString(ep, "ny8 = ny.* win8;");
engEvalString(ep, "ny9 = ny.* win9;");
engEvalString(ep, "ny10 = ny.* win10;");
engEvalString(ep, "ny11 = ny.* win11;");
engEvalString(ep, "ny12 = ny.* win12;");
engEvalString(ep, "ny13 = ny.* win13;");
engEvalString(ep, "ny14 = ny.* win14;");
engEvalString(ep, "ny15 = ny.* win15;");
engEvalString(ep, "ny16 = ny.* win16;");
engEvalString(ep, "ny17 = ny.* win17;");
engEvalString(ep, "ny18 = ny.* win18;");
engEvalString(ep, "ny19 = ny.* win19;");
engEvalString(ep, "ny20 = ny.* win20;");
engEvalString(ep, "sy1 = sum(ny1.^ 2);");
engEvalString(ep, "sy2 = sum(ny2.^ 2);");
engEvalString(ep, "sy3 = sum(ny3.^ 2);");
engEvalString(ep, "sy4 = sum(ny4.^ 2);");
engEvalString(ep, "sy5 = sum(ny5.^ 2);");
engEvalString(ep, "sy6 = sum(ny6.^ 2);");
engEvalString(ep, "sy7 = sum(ny7.^ 2);");
engEvalString(ep, "sy8 = sum(ny8.^ 2);");
engEvalString(ep, "sy9 = sum(ny9.^ 2);");
engEvalString(ep, "sy10 = sum(ny10.^ 2);");
engEvalString(ep, "sy11 = sum(ny11.^ 2);");
engEvalString(ep, "sy12 = sum(ny12.^ 2);");
engEvalString(ep, "sy13 = sum(ny13.^ 2);");
engEvalString(ep, "sy14 = sum(ny14.^ 2);");
engEvalString(ep, "sy15 = sum(ny15.^ 2);");
engEvalString(ep, "sy16 = sum(ny16.^ 2);");
engEvalString(ep, "sy17 = sum(ny17.^ 2);");
engEvalString(ep, "sy18 = sum(ny18.^ 2);");
engEvalString(ep, "sy19 = sum(ny19.^ 2);");
engEvalString(ep, "sy20 = sum(ny20.^ 2);");
engEvalString(ep, "sy = [sy1, sy2, sy3, sy4, sy5, sy6, sy7, sy8, sy9, sy10, sy11, sy12, sy13, sy14, sy15, sy16, sy17,sy18, sy19, sy20];");
engEvalString(ep, "sy = log(sy);");
engEvalString(ep, "dy = dct(sy);");

engEvalString(ep, "fid=fopen('sample.dat','r');");
//engEvalString(ep, "fprintf(fid);");

engEvalString(ep, "dx = fread(fid, 20,'real*8');");
engEvalString(ep, "fclose (fid);");

engEvalString(ep, "dx = dx.';");

engEvalString(ep, "MSE=(sum((dx - dy).^ 2)) / 20;");

engEvalString(ep, "if MSE < 1.5\
                      v=1;\
                     else\
                       v=2;\
end");

//engEvalString(ep, "plot(y);");

double *newrx;
mxArray *resultx;

	

	resultx = engGetVariable(ep,"v");
	newrx = mxGetPr(resultx);
        double u = *newrx;
        val=u;
}







 //  val=u;
                        if (val==1)
                        {
                            //*commAuth=STOPPED;
                            // cvSaveImage("/home/rohan/new1.jpg",newDetector.clipFace(queryImage));
                       //     send_info_msg(pamh, "Verification successful.");
                           
                            send_info_msg(pamh, "Verification successful.");
                            //writeImageToMemory(zeroFrame,shared);
                           // webcam.stopCamera();

                           // return 0;
                            return PAM_SUCCESS;
                        } else 
                        {
                            
                       send_info_msg(pamh, "Verification Unsuccessful.");
                       
                        return PAM_AUTHINFO_UNAVAIL;
                        }



	printf("Done!\n");
	//mxDestroyArray(result);
	engClose(ep);
       // *commAuth=STOPPED;
//custom authentication ends here
/* we shouldn't read this point, but if we do, we might as well return something bad */
	return PAM_AUTHINFO_UNAVAIL;

}






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]