• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pam_get_item函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: converse

static int converse(pam_handle_t *pamh, int style, lo_const char *text,
    struct pam_response **resp)
{
	struct pam_conv *conv;
	struct pam_message msg, *pmsg;
	int status;

	status = pam_get_item(pamh, PAM_CONV, (pam_item_t *)&conv);
	if (status != PAM_SUCCESS)
		return status;

	pmsg = &msg;
	msg.msg_style = style;
	msg.msg = text;

	*resp = NULL;
	return conv->conv(1, (lo_const struct pam_message **)&pmsg, resp,
	    conv->appdata_ptr);
}
开发者ID:2014-class,项目名称:freerouter,代码行数:19,代码来源:pam_passwdqc.c


示例17: EscalateModuleStartAddItem

/**
 * EscalateModuleStartAddItem:
 * @self: Module containing the PAM handle.
 * @items: Array to append PAM item type and value tuples to.
 * @item: Item type of the value to fetch using pam_get_item().
 * @error: (out)(allow-none): Error return location or #NULL.
 *
 * Returns: #TRUE if there was no fatal error.
 */
static gboolean EscalateModuleStartAddItem(EscalateModule *self,
                                           GVariantBuilder *items, gint item,
                                           GError **error) {
  const gchar *value = NULL;
  gint status = pam_get_item(self->pamh, item, (const void **) &value);
  switch (status) {
    case PAM_SUCCESS:
      g_variant_builder_add(items, "{ims}", item, value);
      return TRUE;
    case PAM_BAD_ITEM:
      return TRUE;
    default:
      g_set_error(error, ESCALATE_MODULE_ERROR,
                  ESCALATE_MODULE_ERROR_GET_ITEM_FAILED,
                  "Failed to get PAM item %d: %s", item,
                  pam_strerror(self->pamh, status));
      return FALSE;
  }
}
开发者ID:passy,项目名称:libpam-policycache,代码行数:28,代码来源:escalate_module.c


示例18: pamGssGetAuthTok

static int
pamGssGetAuthTok(pam_handle_t *pamh,
                 int confFlags,
                 gss_buffer_t passwordBuf)
{
    int status;
    struct pam_conv *conv;
    struct pam_message msg;
    const struct pam_message *msgp;
    struct pam_response *resp;

    status = pam_get_item(pamh, PAM_CONV, (const void **)&conv);
    BAIL_ON_PAM_ERROR(status);

    if (conv == NULL) {
        status = PAM_CONV_ERR;
        goto cleanup;
    }

    msg.msg_style = PAM_PROMPT_ECHO_OFF;
    msg.msg = PASSWORD_PROMPT;
    msgp = &msg;
    resp = NULL;

    status = (*conv->conv)(1, &msgp, &resp, conv->appdata_ptr);

    if (resp != NULL) {
        if (status == PAM_SUCCESS)
            passwordBuf->value = resp->resp;
        else
            free(resp->resp);
        free(resp);
    }

    passwordBuf->length = passwordBuf->value ? strlen((char *)passwordBuf->value) : 0;
    if (passwordBuf->length == 0 && (confFlags & FLAG_NULLOK) == 0) {
        status = PAM_AUTH_ERR;
        goto cleanup;
    }

cleanup:
    return status;
}
开发者ID:PADL,项目名称:pam_gss,代码行数:43,代码来源:pam_gss.c


示例19: get_pam_user

/*
 * get_pam_user - Get the username according to PAM
 *
 * ptr_pam_user shall point to a malloc'ed string (or NULL).
 */
static void get_pam_user (char **ptr_pam_user)
{
	int retcode;
	void *ptr_user;

	assert (NULL != ptr_pam_user);

	retcode = pam_get_item (pamh, PAM_USER, (const void **)&ptr_user);
	PAM_FAIL_CHECK;

	if (NULL != *ptr_pam_user) {
		free (*ptr_pam_user);
	}
	if (NULL != ptr_user) {
		*ptr_pam_user = xstrdup ((const char *)ptr_user);
	} else {
		*ptr_pam_user = NULL;
	}
}
开发者ID:justinc1985,项目名称:IntelRangeley,代码行数:24,代码来源:login.c


示例20: pam_sm_open_session

/*
 * Entry point from pam_open_session call.
 */
PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags,
                                   int argc, const char **argv)
{
    /* Parse arguments. */
    if (argc < 1) {
       	pam_syslog(pamh, LOG_ERR, "usage: pam_unshare.so [group name]");
	return PAM_SESSION_ERR;
    }

    pam_syslog(pamh, LOG_INFO, "Getting PAM_USER");
    /* See http://www.linux-pam.org/Linux-PAM-html/mwg-expected-by-module-item.html */
    const void *item_v;
    int rc = pam_get_item(pamh, PAM_USER, &item_v);
    const char *username = "didn't get user";
    if(rc == PAM_SUCCESS) {
        username = item_v;
    }
    pam_syslog(pamh, LOG_INFO, "pam_unshare, return code %d, found user %s", rc, username);

    struct passwd* user = getpwnam(username);
    if (user == NULL) {
        pam_syslog(pamh, LOG_ERR, "getpwnam(%s) == NULL", username);
	return PAM_SESSION_ERR;
    }
    struct group* group = getgrgid(user->pw_gid);
    if (group == NULL) {
        pam_syslog(pamh, LOG_ERR, "getgrgid(%d) == NULL", user->pw_gid);
	return PAM_SESSION_ERR;
    }
    
    const char* target_group = argv[0];

    if (strcmp(target_group, group->gr_name) == 0) {
	pam_syslog(pamh, LOG_INFO, "found user in target group! calling unshare()");

	if(unshare(CLONE_NEWNS) < 0) {
            pam_syslog(pamh, LOG_ERR, "Unable to unshare from parent namespace, %m");
            return PAM_SESSION_ERR;
	}
    }

    return PAM_SUCCESS;
}
开发者ID:scraperwiki,项目名称:pam_unshare,代码行数:46,代码来源:pam_unshare.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pam_get_user函数代码示例发布时间:2022-05-30
下一篇:
C++ pam_end函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap