Back to index

im-sdk  12.3.91
Functions
iwrap.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int permit_access (const char *cmdname, int h)
int authenticate_with_pam (const char *user, const char *password, const char *command_name, const char *hostname)

Function Documentation

int authenticate_with_pam ( const char *  user,
const char *  password,
const char *  command_name,
const char *  hostname 
)

Definition at line 119 of file iwrap.c.

{
#ifdef HAVE_PAM
    struct pam_conv cv;
    pam_handle_t *ph = NULL;
    int ret;

    cv.conv = local_conv_for_pam;
    cv.appdata_ptr = (void*) password;
    ret = pam_start(command_name, user, &cv, &ph);
    if (ret != PAM_SUCCESS) goto fail;

    if (hostname) {
       ret = pam_set_item(ph, PAM_RHOST, hostname);
       if (ret != PAM_SUCCESS) goto fail;
    }

    /* Account checking. */
    ret = pam_acct_mgmt(ph, PAM_SILENT);
    if (ret != PAM_SUCCESS) goto fail;

    /* Password checking. */
    if (password) {
       ret = pam_set_item(ph, PAM_AUTHTOK, password);
       /* 
          Don't check the return value for the PAM not supporting
          PAM_AUTHTOK.
          if (ret != PAM_SUCCESS) goto fail;
       */
       ret = pam_authenticate(ph, PAM_SILENT);
       if (ret != PAM_SUCCESS) goto fail;
    }

    pam_end(ph, ret);
    return 1;
fail:
    pam_end(ph, ret);
    return 0;
#else /* not HAVE_PAM */
    return 0;
#endif /* not HAVE_PAM */
}

Here is the caller graph for this function:

int permit_access ( const char *  cmdname,
int  h 
)

Definition at line 68 of file iwrap.c.

{
#ifdef HAVE_LIBWRAP
    struct request_info req;

    request_init(&req, RQ_DAEMON, cmdname, RQ_FILE, h, 0);
    fromhost(&req);

    if (!hosts_access(&req)) return 0;
#endif

    return 1;
}

Here is the caller graph for this function: