{
    "mode": "man",
    "parameter": "pam_set_data",
    "section": "3",
    "url": "https://www.chedong.com/phpMan.php/man/pam_set_data/3/json",
    "generated": "2026-07-05T02:11:33Z",
    "synopsis": "#include <security/pammodules.h>\nint pamsetdata(pamhandlet *pamh, const char *moduledataname, void *data,\nvoid (*cleanup)(pamhandlet *pamh, void *data, int errorstatus));",
    "sections": {
        "NAME": {
            "content": "pamsetdata - set module internal data\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "#include <security/pammodules.h>\n\nint pamsetdata(pamhandlet *pamh, const char *moduledataname, void *data,\nvoid (*cleanup)(pamhandlet *pamh, void *data, int errorstatus));\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The pamsetdata function associates a pointer to an object with the (hopefully) unique\nstring moduledataname in the PAM context specified by the pamh argument.\n\nPAM modules may be dynamically loadable objects. In general such files should not contain\nstatic variables. This function and its counterpart pamgetdata(3), provide a mechanism for\na module to associate some data with the handle pamh. Typically a module will call the\npamsetdata function to register some data under a (hopefully) unique moduledataname. The\ndata is available for use by other modules too but not by an application. Since this\nfunctions stores only a pointer to the data, the module should not modify or free the content\nof it.\n\nThe function cleanup() is associated with the data and, if non-NULL, it is called when this\ndata is over-written or following a call to pamend(3).\n\nThe errorstatus argument is used to indicate to the module the sort of action it is to take\nin cleaning this data item. As an example, Kerberos creates a ticket file during the\nauthentication phase, this file might be associated with a data item. When pamend(3) is\ncalled by the module, the errorstatus carries the return value of the pamauthenticate(3) or\nother libpam function as appropriate. Based on this value the Kerberos module may choose to\ndelete the ticket file (authentication failure) or leave it in place.\n\nThe errorstatus may have been logically OR'd with either of the following two values:\n\nPAMDATAREPLACE\nWhen a data item is being replaced (through a second call to pamsetdata) this mask is\nused. Otherwise, the call is assumed to be from pamend(3).\n\nPAMDATASILENT\nWhich indicates that the process would prefer to perform the cleanup() quietly. That is,\ndiscourages logging/messages to the user.\n",
            "subsections": []
        },
        "RETURN VALUES": {
            "content": "PAMBUFERR\nMemory buffer error.\n\nPAMSUCCESS\nData was successful stored.\n\nPAMSYSTEMERR\nA NULL pointer was submitted as PAM handle or the function was called by an application.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pamend(3), pamgetdata(3), pamstrerror(3)\n\n\n\nLinux-PAM Manual                             06/08/2020                              PAMSETDATA(3)",
            "subsections": []
        }
    },
    "summary": "pamsetdata - set module internal data",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "pamend",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/pamend/3/json"
        },
        {
            "name": "pamgetdata",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/pamgetdata/3/json"
        },
        {
            "name": "pamstrerror",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/pamstrerror/3/json"
        }
    ]
}