Changeset 39 in openpam for trunk/lib


Ignore:
Timestamp:
Feb 7, 2002, 12:22:08 PM (19 years ago)
Author:
Dag-Erling Smørgrav
Message:

Introduce pam_v{info,error,prompt}().
Move OpenPAM API extensions into <security/openpam.h> to avoid
namespace pollution for apps or modules that do not use them.

Sponsored by: DARPA, NAI Labs

Location:
trunk/lib
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Makefile

    r21 r39  
    7171SRCS            += pam_start.c
    7272SRCS            += pam_strerror.c
     73SRCS            += pam_verror.c
     74SRCS            += pam_vinfo.c
     75SRCS            += pam_vprompt.c
    7376
    7477.if 0
  • trunk/lib/pam_error.c

    r16 r39  
    4040
    4141#include <security/pam_appl.h>
     42#include <security/openpam.h>
    4243
    4344/*
     
    5253        ...)
    5354{
    54         char msgbuf[PAM_MAX_MSG_SIZE];
    55         struct pam_message msg;
    56         const struct pam_message *msgp;
    57         struct pam_response *rsp;
    58         struct pam_conv conv;
    5955        va_list ap;
     56        char *rsp;
    6057        int r;
    6158
    62         if ((r = pam_get_item(pamh, PAM_CONV, (void *)&conv)) != PAM_SUCCESS)
    63                 return (r);
    6459        va_start(ap, fmt);
    65         vsnprintf(msgbuf, PAM_MAX_MSG_SIZE, fmt, ap);
     60        r = pam_vprompt(pamh, PAM_ERROR_MSG, &rsp, fmt, ap);
    6661        va_end(ap);
    67         msg.msg_style = PAM_ERROR_MSG;
    68         msg.msg = msgbuf;
    69         msgp = &msg;
    70         r = (conv.conv)(1, &msgp, &rsp, conv.appdata_ptr);
    7162        free(rsp); /* ignore response */
    7263        return (r);
  • trunk/lib/pam_get_authtok.c

    r38 r39  
    3838
    3939#include <security/pam_appl.h>
     40#include <security/openpam.h>
    4041
    4142#include "openpam_impl.h"
     
    6667                        prompt = "Password:";
    6768        }
    68         r = pam_prompt(pamh, &resp, 0, "%s", prompt ? prompt : p);
     69        r = pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &resp,
     70            "%s", prompt ? prompt : p);
    6971        if (r != PAM_SUCCESS)
    7072                return (r);
  • trunk/lib/pam_get_user.c

    r35 r39  
    3838
    3939#include <security/pam_appl.h>
     40#include <security/openpam.h>
    4041
    4142#include "openpam_impl.h"
     
    6768                        prompt = "Login: ";
    6869        }
    69         r = pam_prompt(pamh, &resp, 0, "%s", prompt ? prompt : p);
     70        r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp,
     71            "%s", prompt ? prompt : p);
    7072        if (r != PAM_SUCCESS)
    7173                return (r);
  • trunk/lib/pam_info.c

    r16 r39  
    4040
    4141#include <security/pam_appl.h>
     42#include <security/openpam.h>
    4243
    4344/*
     
    5253        ...)
    5354{
    54         char msgbuf[PAM_MAX_MSG_SIZE];
    55         struct pam_message msg;
    56         const struct pam_message *msgp;
    57         struct pam_response *rsp;
    58         struct pam_conv conv;
    5955        va_list ap;
     56        char *rsp;
    6057        int r;
    6158
    62         if ((r = pam_get_item(pamh, PAM_CONV, (void *)&conv)) != PAM_SUCCESS)
    63                 return (r);
    6459        va_start(ap, fmt);
    65         vsnprintf(msgbuf, PAM_MAX_MSG_SIZE, fmt, ap);
     60        r = pam_vprompt(pamh, PAM_TEXT_INFO, &rsp, fmt, ap);
    6661        va_end(ap);
    67         msg.msg_style = PAM_TEXT_INFO;
    68         msg.msg = msgbuf;
    69         msgp = &msg;
    70         r = (conv.conv)(1, &msgp, &rsp, conv.appdata_ptr);
    7162        free(rsp); /* ignore response */
    7263        return (r);
  • trunk/lib/pam_prompt.c

    r16 r39  
    3636
    3737#include <stdarg.h>
    38 #include <stdio.h>
    39 #include <stdlib.h>
    4038
    4139#include <security/pam_appl.h>
     40#include <security/openpam.h>
    4241
    4342/*
    4443 * OpenPAM extension
    4544 *
    46  * Prompt the user for information
     45 * Call the conversation function
    4746 */
    4847
    4948int
    5049pam_prompt(pam_handle_t *pamh,
     50        int style,
    5151        char **resp,
    52         int echo,
    5352        const char *fmt,
    5453        ...)
    5554{
    56         char msgbuf[PAM_MAX_MSG_SIZE];
    57         struct pam_message msg;
    58         const struct pam_message *msgp;
    59         struct pam_response *rsp;
    60         struct pam_conv conv;
    6155        va_list ap;
    6256        int r;
    6357
    64         if ((r = pam_get_item(pamh, PAM_CONV, (void *)&conv)) != PAM_SUCCESS)
    65                 return (r);
    6658        va_start(ap, fmt);
    67         vsnprintf(msgbuf, PAM_MAX_MSG_SIZE, fmt, ap);
     59        r = pam_vprompt(pamh, style, resp, fmt, ap);
    6860        va_end(ap);
    69         msg.msg_style = echo ? PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF;
    70         msg.msg = msgbuf;
    71         msgp = &msg;
    72         r = (conv.conv)(1, &msgp, &rsp, conv.appdata_ptr);
    73         *resp = rsp == NULL ? NULL : rsp->resp;
    74         free(rsp);
    7561        return (r);
    7662}
Note: See TracChangeset for help on using the changeset viewer.