当前位置: 首页>>代码示例>>C++>>正文


C++ pam_get_item函数代码示例

本文整理汇总了C++中pam_get_item函数的典型用法代码示例。如果您正苦于以下问题:C++ pam_get_item函数的具体用法?C++ pam_get_item怎么用?C++ pam_get_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pam_get_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: do_item

static int
do_item(pam_handle_t *pamh, struct tac_handle *tach, int item,
    set_func func, const char *funcname)
{
	int retval;
	const void *value;

	retval = pam_get_item(pamh, item, &value);
	if (retval != PAM_SUCCESS)
	    return retval;
	if (value != NULL && (*func)(tach, (const char *)value) == -1) {
		syslog(LOG_CRIT, "%s: %s", funcname, tac_strerror(tach));
		tac_close(tach);
		return PAM_SERVICE_ERR;
	}
	return PAM_SUCCESS;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:17,代码来源:pam_tacplus.c

示例2: switch

const void* Authenticator::get_item(const Authenticator::ItemType item) {
    const void* data;
    switch ((last_result=pam_get_item(pam_handle, item, &data))) {
    default:
    case PAM_SYSTEM_ERR:
#ifdef __LIBPAM_VERSION
    case PAM_BAD_ITEM:
#endif
        _end();
        throw Exception(pam_handle, "pam_get_item()", last_result);

    case PAM_PERM_DENIED: // The value of item was NULL
    case PAM_SUCCESS:
        break;
    }
    return data;
}
开发者ID:JackDanger,项目名称:chromiumos,代码行数:17,代码来源:PAM.cpp

示例3: pam_get_rhost

static int pam_get_rhost(pam_handle_t *pamh, const char **rhost
			 , const char *prompt)
{
    int retval;
    const char   *current;

    retval = pam_get_item (pamh, PAM_RHOST, (const void **)&current);
    if (retval != PAM_SUCCESS)
        return retval;

    if (current == NULL) {
	return PAM_AUTH_ERR;
    }
    *rhost = current;

    return retval;        /* pass on any error from conversation */
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:17,代码来源:pam_rhosts_auth.c

示例4: record_user

static int record_user(const abl_args *args, abl_info *info, time_t tm) {
    const void *user;
    int err;
    if (err = pam_get_item(args->pamh, PAM_USER, &user), PAM_SUCCESS != err) {
        log_pam_error(args, err, "getting PAM_USER");
        return err;
    }
    if (NULL != user) {
        info->subject = USER;
        info->user = user;
        return record(args, info, tm, args->user_purge);
    } else {
        log_debug(args, "PAM_USER is NULL");
        return 0;
    }
    return 1;
}
开发者ID:mestia,项目名称:pam-abl4deb,代码行数:17,代码来源:pam_abl.c

示例5: pam_sm_authenticate

/* expected hook, this is where custom stuff happens */
PAM_EXTERN int pam_sm_authenticate(pam_handle_t* pamh, int flags, int argc, const char **argv) {
	int ret = 0;

	const char* pUsername = NULL;
	const char* pUrl = NULL;
	const char* pCaFile = NULL;

	struct pam_message msg;
	struct pam_conv* pItem;
	struct pam_response* pResp;
	const struct pam_message* pMsg = &msg;

	msg.msg_style = PAM_PROMPT_ECHO_OFF;
	msg.msg = "Cool buddy: ";
	
	printf("I got called\n");

	if (pam_get_user(pamh, &pUsername, NULL) != PAM_SUCCESS) {
		return PAM_AUTH_ERR;
	}

	pUrl = getArg("url", argc, argv);
	if (!pUrl) {
		return PAM_AUTH_ERR;
	}

	pCaFile = getArg("cafile", argc, argv);
	if (pam_get_item(pamh, PAM_CONV, (const void**)&pItem) != PAM_SUCCESS || !pItem) {
		fprintf(stderr, "Couldn't get pam_conv\n");
		return PAM_AUTH_ERR;
	}

	pItem->conv(1, &pMsg, &pResp, pItem->appdata_ptr);

	ret = PAM_SUCCESS;

	if (getUrl(pUrl, pUsername, pResp[0].resp, pCaFile) != 0) {
		ret = PAM_AUTH_ERR;
	}
	
	memset(pResp[0].resp, 0, strlen(pResp[0].resp));
	free(pResp);
	
	return ret;
}
开发者ID:beatgammit,项目名称:filesync-client,代码行数:46,代码来源:mypam.c

示例6: _get_authtok

static int _get_authtok (pam_handle_t * pamh)
{
  int rc;
  char *p;
  struct pam_message msg[1], *pmsg[1];
  struct pam_response *resp;
  struct pam_conv *conv;

  pmsg[0] = &msg[0];
  msg[0].msg_style = PAM_PROMPT_ECHO_OFF;
  msg[0].msg = "Password: ";
  resp = NULL;

  rc = pam_get_item (pamh, PAM_CONV, (const void **) &conv);
  if (rc == PAM_SUCCESS)
  {
      rc = conv->conv (1,
		       (const struct pam_message **) pmsg,
		       &resp, conv->appdata_ptr);
  }
  else
  {
      return rc;
  }
  if (resp != NULL)
  {
      if (resp[0].resp == NULL)
      {
	  free (resp);
	  return PAM_AUTH_ERR;
      }

      p = resp[0].resp;
      /* leak if resp[0].resp is malloced. */
      resp[0].resp = NULL;
  }
  else
  {
      return PAM_CONV_ERR;
  }
  free (resp);
  pam_set_item (pamh, PAM_AUTHTOK, p);

  return PAM_SUCCESS;
}
开发者ID:Openroadvietnam,项目名称:obm-integration,代码行数:45,代码来源:pam_cas.c

示例7: log_message

static void log_message(int priority, pam_handle_t *pamh, const char *format, ...) {
        char *service = NULL;
        if (pamh)
                pam_get_item(pamh, PAM_SERVICE, (void *)&service);
        if (!service)
                service = "";

        char logname[80];
        snprintf(logname, sizeof(logname), "%s(" MODULE_NAME ")", service);

        va_list args;
        va_start(args, format);
        openlog(logname, LOG_CONS | LOG_PID, LOG_AUTHPRIV);
        vsyslog(priority, format, args);
        va_end(args);

        closelog();
}
开发者ID:mogorman,项目名称:pam_pig,代码行数:18,代码来源:pam_pig.c

示例8: set_the_terminal

static int set_the_terminal(pam_handle_t *pamh)
{
    const char *tty;

    if (pam_get_item(pamh, PAM_TTY, (const void **)&tty) != PAM_SUCCESS
	|| tty == NULL) {
	tty = ttyname(STDIN_FILENO);
	if (tty == NULL) {
	    _pam_log(LOG_ERR, "couldn't get the tty name");
	    return PAM_ABORT;
	}
	if (pam_set_item(pamh, PAM_TTY, tty) != PAM_SUCCESS) {
	    _pam_log(LOG_ERR, "couldn't set tty name");
	    return PAM_ABORT;
	}
    }
    return PAM_SUCCESS;
}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:18,代码来源:pam_filter.c

示例9: pam_prompt

int pam_prompt(pam_handle_t *pamh, int style, char **response,
               const char *format, ...)
{
  int rc;
  struct pam_conv *aconv;
  char buffer[200];
  va_list ap;
  struct pam_message msg, *pmsg;
  struct pam_response *resp;
  /* the the conversion function */
  rc = pam_get_item(pamh, PAM_CONV, (PAM_ITEM_CONST void **)&aconv);
  if (rc != PAM_SUCCESS)
    return rc;
  /* make the message string */
  va_start(ap, format);
  vsnprintf(buffer, sizeof(buffer), format, ap);
  buffer[sizeof(buffer) - 1] = '\0';
  va_end(ap);
  /* build the message */
  msg.msg_style = style;
  msg.msg = buffer;
  pmsg = &msg;
  resp = NULL;
  rc = aconv->conv(1, (const struct pam_message **)&pmsg, &resp, aconv->appdata_ptr);
  if (rc != PAM_SUCCESS)
    return rc;
  /* assign response if it is set */
  if (response != NULL)
  {
    if (resp == NULL)
      return PAM_CONV_ERR;
    if (resp[0].resp == NULL)
    {
      free(resp);
      return PAM_CONV_ERR;
    }
    *response = resp[0].resp;
  }
  else
    free(resp[0].resp);
  free(resp);
  return PAM_SUCCESS;
}
开发者ID:arthurdejong,项目名称:nss-pam-ldapd,代码行数:43,代码来源:pam_prompt.c

示例10: get_tty

static const char *
get_tty(pam_handle_t *pamh)
{
    const void *void_terminal_line = NULL;
    const char *terminal_line;

    if (pam_get_item(pamh, PAM_TTY, &void_terminal_line) != PAM_SUCCESS
	|| void_terminal_line == NULL) {
	terminal_line = DEFAULT_TERM;
    } else {
	terminal_line = void_terminal_line;
    }
    if (!strncmp("/dev/", terminal_line, 5)) {
	/* strip leading "/dev/" from tty. */
	terminal_line += 5;
    }
    D(("terminal = %s", terminal_line));
    return terminal_line;
}
开发者ID:tizenorg,项目名称:toolchains.pam,代码行数:19,代码来源:pam_lastlog.c

示例11: _PAMCreateAttributesFromHandle

static int
_PAMCreateAttributesFromHandle(pam_handle_t *pamh, CFDictionaryRef *pAttributes)
{
    CFMutableDictionaryRef attributes = NULL;
    const char *user;
    int rc;

    rc = pam_get_item(pamh, PAM_USER, (const void **)&user);
    if (rc != PAM_SUCCESS)
        return rc;

    CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, user, kCFStringEncodingUTF8);
    if (name == NULL) {
        CFRelease(attributes);
        return PAM_BUF_ERR;
    }

    /* In case module returned PAM_TRY_AGAIN */
    rc = pam_get_data(pamh, CREDUI_ATTR_DATA, (const void **)&attributes);
    if (rc == PAM_SUCCESS && attributes) {
        CFStringRef assertedName = (CFStringRef)CFDictionaryGetValue(attributes, kCUIAttrName);
        
        if (assertedName && CFEqual(assertedName, name)) {
            *pAttributes = (CFDictionaryRef)CFRetain(attributes);
            CFRelease(name);
            return PAM_SUCCESS;
        }
    }
    
    attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    if (attributes == NULL)
        return PAM_BUF_ERR;
    
    CFDictionarySetValue(attributes, kCUIAttrNameType, kCUIAttrNameTypePosixName);
    CFDictionarySetValue(attributes, kCUIAttrName, name);
    
    /* we don't get AUTHTOK because it might prompt */
    
    CFRelease(name);
    
    *pAttributes = attributes;
    return PAM_SUCCESS;
}
开发者ID:PADL,项目名称:CredUI,代码行数:43,代码来源:pam_credui.cpp

示例12: converse

static int converse( pam_handle_t * pamh,
                     struct pam_message ** message,
                     struct pam_response ** response )
{
   int retval;
   void const * void_conv;
   struct pam_conv const * conv;

   retval = pam_get_item( pamh, PAM_CONV, & void_conv );
   conv = (struct pam_conv const *) void_conv;

   if( retval == PAM_SUCCESS )
   {
      retval = conv->conv( 1, (struct pam_message const **) message,
                           response, conv->appdata_ptr );
   }

   return retval;
}
开发者ID:greyson,项目名称:pam_couchdb,代码行数:19,代码来源:pam.cpp

示例13: get_password

/*
 * This is a conversation function to obtain the user's password
 */
static int get_password(pam_handle_t * pamh, const char *message, const char **passwd)
{
    struct pam_message msg[2], *pmsg[2];
    struct pam_response *resp;
    const struct pam_conv *conv;

    pmsg[0] = &msg[0];
    msg[0].msg = message;
    msg[0].msg_style = PAM_PROMPT_ECHO_OFF;

    if (pam_get_item(pamh, PAM_CONV, (const void **) &conv) == PAM_SUCCESS &&
        conv->conv(1, (const struct pam_message **) &pmsg, &resp, conv->appdata_ptr) == PAM_SUCCESS && 
        resp != NULL) {
        *passwd = resp[0].resp;
        free(resp);
        return PAM_SUCCESS;
    }
    return PAM_SYSTEM_ERR;
}
开发者ID:vseryakov,项目名称:ossweb,代码行数:22,代码来源:pam_ossweb.c

示例14: pam_get_item

char *get_response(pam_handle_t *pamh, const char *prompt, int verbose) {
    struct pam_conv *conv;
    int retval;
    struct pam_message msg;
    const struct pam_message *msgp;
    struct pam_response *resp;
    char *response;
    char buffer[MAXBUFSIZE];

    retval = pam_get_item(pamh, PAM_CONV, (const void**) &conv);
    if (retval != PAM_SUCCESS) {
        return NULL;
    }

    /* check if we want verbose input */
    if ( verbose != 0 )
        msg.msg_style = PAM_PROMPT_ECHO_ON;
    else
        msg.msg_style = PAM_PROMPT_ECHO_OFF;

    if (prompt) {
        snprintf(buffer, MAXBUFSIZE, "%s: ", prompt);
    } else {
        strcpy(buffer, "Password: ");
    }

    /* set up the conversation */
    msg.msg = buffer;
    msgp = &msg;
    resp = NULL;
    response = NULL;
    retval = (*conv->conv)(1, &msgp, &resp, conv->appdata_ptr);
    if (resp != NULL) {
        if (retval == PAM_SUCCESS) {
            response = resp->resp;
        } else {
            free(resp->resp);
        }
        free(resp);
    }

    return response;
}
开发者ID:ElevenPaths,项目名称:latch-plugin-unix,代码行数:43,代码来源:pam_latch.c

示例15: converse

int converse(pam_handle_t * pamh, int nargs, const struct pam_message *message,
    struct pam_response **response) {

    int retval;
    struct pam_conv *conv;

    if ((retval = pam_get_item (pamh, PAM_CONV, (const void **)&conv)) == PAM_SUCCESS) {
        retval = conv->conv(nargs, &message, response, conv->appdata_ptr);

        if (retval != PAM_SUCCESS) {
            _pam_log(LOG_ERR, "(pam_tacplus) converse returned %d", retval);
            _pam_log(LOG_ERR, "that is: %s", pam_strerror (pamh, retval));
        }
    } else {
        _pam_log (LOG_ERR, "(pam_tacplus) converse failed to get pam_conv");
    }

    return retval;
}
开发者ID:jeroennijhof,项目名称:pam_tacplus,代码行数:19,代码来源:support.c


注:本文中的pam_get_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。