{
    "mode": "info",
    "parameter": "pam_conv",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/pam_conv/json",
    "generated": "2026-07-06T04:10:06Z",
    "synopsis": "#include <security/pamappl.h>\nstruct pammessage {\nint msgstyle;\nconst char *msg;\n};\nstruct pamresponse {\nchar *resp;\nint respretcode;\n};\nstruct pamconv {\nint (*conv)(int nummsg, const struct pammessage msg,\nstruct pamresponse resp, void *appdataptr);\nvoid *appdataptr;\n};",
    "sections": {
        "NAME": {
            "content": "pamconv - PAM conversation function\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "#include <security/pamappl.h>\n\nstruct pammessage {\nint msgstyle;\nconst char *msg;\n};\n\nstruct pamresponse {\nchar *resp;\nint respretcode;\n};\n\nstruct pamconv {\nint (*conv)(int nummsg, const struct pammessage msg,\nstruct pamresponse resp, void *appdataptr);\nvoid *appdataptr;\n};\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The PAM library uses an application-defined callback to allow a direct\ncommunication between a loaded module and the application. This\ncallback is specified by the struct pamconv passed to pamstart(3) at\nthe start of the transaction.\n\nWhen a module calls the referenced conv() function, the argument\nappdataptr is set to the second element of this structure.\n\nThe other arguments of a call to conv() concern the information\nexchanged by module and application. That is to say, nummsg holds the\nlength of the array of pointers, msg. After a successful return, the\npointer resp points to an array of pamresponse structures, holding the\napplication supplied text. The respretcode member of this struct is\nunused and should be set to zero. It is the caller's responsibility to\nrelease both, this array and the responses themselves, using free(3).\nNote, *resp is a struct pamresponse array and not an array of\npointers.\n\nThe number of responses is always equal to the nummsg conversation\nfunction argument. This does require that the response array is\nfree(3)'d after every call to the conversation function. The index of\nthe responses corresponds directly to the prompt index in the\npammessage array.\n\nOn failure, the conversation function should release any resources it\nhas allocated, and return one of the predefined PAM error codes.\n\nEach message can have one of four types, specified by the msgstyle\nmember of struct pammessage:\n\nPAMPROMPTECHOOFF\nObtain a string without echoing any text.\n\nPAMPROMPTECHOON\nObtain a string whilst echoing text.\n\nPAMERRORMSG\nDisplay an error message.\n\nPAMTEXTINFO\nDisplay some text.\n\nThe point of having an array of messages is that it becomes possible to\npass a number of things to the application in a single call from the\nmodule. It can also be convenient for the application that related\nthings come at once: a windows based application can then present a\nsingle form with many messages/prompts on at once.\n\nIn passing, it is worth noting that there is a discrepancy between the\nway Linux-PAM handles the const struct pammessage msg conversation\nfunction argument and the way that Solaris' PAM (and derivatives, known\nto include HP/UX, are there others?) does. Linux-PAM interprets the msg\nargument as entirely equivalent to the following prototype const struct\npammessage *msg[] (which, in spirit, is consistent with the commonly\nused prototypes for argv argument to the familiar main() function: char\nargv; and char *argv[]). Said another way Linux-PAM interprets the\nmsg argument as a pointer to an array of nummsg read only 'struct\npammessage' pointers. Solaris' PAM implementation interprets this\nargument as a pointer to a pointer to an array of nummsg pammessage\nstructures. Fortunately, perhaps, for most module/application\ndevelopers when nummsg has a value of one these two definitions are\nentirely equivalent. Unfortunately, casually raising this number to two\nhas led to unanticipated compatibility problems.\n\nFor what its worth the two known module writer work-arounds for trying\nto maintain source level compatibility with both PAM implementations\nare:\n\no   never call the conversation function with nummsg greater than one.\n\no   set up msg as doubly referenced so both types of conversation\nfunction can find the messages. That is, make\n\nmsg[n] = & (( *msg )[n])\n",
            "subsections": []
        },
        "RETURN VALUES": {
            "content": "PAMBUFERR\nMemory buffer error.\n\nPAMCONVERR\nConversation failure. The application should not set *resp.\n\nPAMSUCCESS\nSuccess.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pamstart(3), pamsetitem(3), pamgetitem(3), pamstrerror(3), pam(7)\n\nLinux-PAM Manual                  06/08/2020                       PAMCONV(3)",
            "subsections": []
        }
    },
    "summary": "pamconv - PAM conversation function",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "pamstart",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/pamstart/3/json"
        },
        {
            "name": "pamsetitem",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/pamsetitem/3/json"
        },
        {
            "name": "pamgetitem",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/pamgetitem/3/json"
        },
        {
            "name": "pamstrerror",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/pamstrerror/3/json"
        },
        {
            "name": "pam",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/pam/7/json"
        }
    ]
}