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


C++ check_access函数代码示例

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


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

示例1: rtems_filesystem_eval_path_continue

void rtems_filesystem_eval_path_continue(
  rtems_filesystem_eval_path_context_t *ctx
)
{
  int eval_flags;

  while (ctx->pathlen > 0) {
    (*ctx->currentloc.mt_entry->ops->eval_path_h)(ctx);
  }

  eval_flags = rtems_filesystem_eval_path_get_flags(ctx);
  if (rtems_filesystem_eval_path_has_token(ctx)) {
    bool make = (eval_flags & RTEMS_FS_MAKE) != 0;

    if (make) {
      check_access(ctx, RTEMS_FS_PERMS_WRITE);
    } else {
      rtems_filesystem_eval_path_error(ctx, ENOENT);
    }
  } else {
    bool exclusive = (eval_flags & RTEMS_FS_EXCLUSIVE) != 0;

    if (!exclusive) {
      check_access(ctx, ctx->flags);
    } else {
      rtems_filesystem_eval_path_error(ctx, EEXIST);
    }
  }
}
开发者ID:0871087123,项目名称:rtems,代码行数:29,代码来源:sup_fs_eval_path.c

示例2: sbrack_inode_rename

/* check permission for creating mv/cp */
static int sbrack_inode_rename(struct inode *old_inode, struct dentry *old_dentry,
                struct inode *new_inode, struct dentry *new_dentry)
{   
    int ret = 0;

    if(get_current_user()->uid.val >= 1000){
    
        /* checking if permission is to mv/cp the file/directory */    
        ret = check_access(get_current_user()->uid.val, old_dentry->d_inode->i_ino);
        
        if(ret == 1){
        
            /* checking if permission is to mv/cp the file/directory to the new parent directory*/
            ret = check_access(get_current_user()->uid.val, new_inode->i_ino);
            
            if(ret == 1)
                return 0;
            else if(ret == 0)
                return -EACCES;
            else 
                return 0;
        }
        else if(ret == 0)
            return -EACCES;
        else 
            return 0;
    }

    return 0;
}
开发者ID:abhishekgupta8,项目名称:Role-Based-Access-Controlled-Security-Model-for-linux,代码行数:31,代码来源:sbrack.c

示例3: do_invite

int do_invite(User * u, Channel *c, char *nick) {
	ChannelInfo *ci = c->ci;

	if (!nick)
		noticeLang(ci->bi->nick, u, LANG_INVITE_SYNTAX);

	else {
		if (check_access(u, ci, CA_OPDEOP)	&& check_access(u, ci, CA_OPDEOPME)) {
			User *u2;

			if ((u2 = finduser(nick))) {
				if (stricmp(u2->nick, u->nick) != 0) {
					if (!is_on_chan(c, u2)) {
						anope_cmd_invite(ci->bi->nick, ci->name, u2->nick);
						notice(ci->bi->nick, ci->name, "%s was invited to the channel.", u2->nick);
					} else
						noticeLang(ci->bi->nick, u, LANG_INVITE_IS_ON);
				} else
					noticeLang(ci->bi->nick, u, LANG_INVITE_YOURSELF);
			} else
				noticeLang(ci->bi->nick, u, LANG_INVITE_NO_USER);
		} else
			notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	}

	return MOD_CONT;
}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:27,代码来源:misc_cmds.c

示例4: return

char			*find_path_exec(char *exec, t_gen *envp)
{
	char		*path;
	char		**split;
	int			i;

	i = -1;
	if ((path = get_var_env("PATH=", envp->env)) == NULL)
		return (NULL);
	split = ft_strsplit(path, ':');
	while (split[++i])
	{
		path = concat_path(split[i], exec);
		if ((access(path, F_OK) != -1) &&
				((envp->ret = check_access(path)) == 0))
			break ;
		else
		{
			envp->ret = check_access(path);
			ft_strdel(&path);
			if (envp->ret == ENPERM)
				break ;
		}
	}
	free_split(&split);
	return (path);
}
开发者ID:michelschmit,项目名称:42sh,代码行数:27,代码来源:find_path.c

示例5: set_topic

int set_topic(User * u, Channel *c, char *topic) {
	ChannelInfo *ci = c->ci;

	if (!my_check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !my_check_access(u, ci, CA_OPDEOPME)))
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	else {
		if (ci->last_topic)
			free(ci->last_topic);
		ci->last_topic = topic ? sstrdup(topic) : NULL;
		strscpy(ci->last_topic_setter, u->nick, NICKMAX);
		ci->last_topic_time = time(NULL);

		if (c->topic)
			free(c->topic);
		c->topic = topic ? sstrdup(topic) : NULL;
		strscpy(c->topic_setter, u->nick, NICKMAX);
		if (ircd->topictsbackward) {
			c->topic_time = c->topic_time - 1;
		} else {
			c->topic_time = ci->last_topic_time;
		}

		if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC) &&
				((ci->flags & CI_TOPICLOCK) || !check_access(u, ci, CA_OPDEOPME)))
			alog("%s: %s!%[email protected]%s changed topic of %s as services admin.",
				ci->bi->nick, u->nick, u->username, u->host, c->name);

		anope_cmd_topic(ci->bi->nick, c->name, u->nick, topic ? topic : "", c->topic_time);
	}
	return MOD_CONT;
}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:31,代码来源:misc_cmds.c

示例6: topic_replace_prepend

int topic_replace_prepend(User * u, Channel *c, char *newtopic) {
	char topic[1024], buf[1024], *mtopic;
	ChannelInfo *ci = c->ci;

	if (ci->flags & CI_VERBOTEN) {
		notice_lang(ci->bi->nick, u, CHAN_X_FORBIDDEN, ci->name);
		return MOD_STOP;
	}

	if (!my_check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !my_check_access(u, ci, CA_OPDEOPME))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
		return MOD_STOP;
	}

	memset(topic, 0, 1024);
	if (ci->last_topic) {
		/* Copy topic starting after the first delimiter.. */
		mtopic = strstr(ci->last_topic, (AppendToTopicDel ? AppendToTopicDel : "||"));
		if (mtopic) {
			memset(buf, 0, 1024);
			strcat(buf, mtopic + strlen((AppendToTopicDel ? AppendToTopicDel : "||")));

			if (newtopic)
				snprintf(topic, sizeof(topic), "%s %s%s", newtopic,
						(AppendToTopicDel ? AppendToTopicDel : "||"), buf);
			else
				snprintf(topic, sizeof(topic), "%s", buf);
		} else
			snprintf(topic, sizeof(topic), "%s %s %s", newtopic,
					(AppendToTopicDel ? AppendToTopicDel : "||"), ci->last_topic);
	} else if (newtopic)
		strcpy(topic, newtopic);

	ci->last_topic = *topic ? sstrdup(topic) : NULL;
	strscpy(ci->last_topic_setter, u->nick, NICKMAX);
	ci->last_topic_time = time(NULL);

	if (c->topic) free(c->topic);
	c->topic = *topic ? sstrdup(topic) : NULL;
	strscpy(c->topic_setter, u->nick, NICKMAX);

	if (ircd->topictsbackward) {
		c->topic_time = c->topic_time - 1;
	} else {
		c->topic_time = ci->last_topic_time;
	}

	if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC) &&
			((ci->flags & CI_TOPICLOCK) || !check_access(u, ci, CA_OPDEOPME)))
		alog("%s: %s!%[email protected]%s changed topic of %s as services admin.",
			ci->bi->nick, u->nick, u->username, u->host, c->name);

	anope_cmd_topic(ci->bi->nick, c->name, u->nick, topic, c->topic_time);

	return MOD_CONT;
}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:56,代码来源:misc_cmds.c

示例7: bink_mkdir

/*
 * Create directory for zone/points if needed
 */
int bink_mkdir(Node *node)
{
    char buf[MAXPATH];
    char *base;
    size_t rest;
    
    /*
     * Outbound dir + zone dir
     */
    BUF_COPY2(buf, cf_p_btbasedir(), "/");
#ifndef AMIGADOS_4D_OUTBOUND
    if((base = cf_zones_out(node->zone)) == NULL)
#else
    if((base = cf_zones_out(0)) == NULL)
#endif
	return ERROR;
    BUF_APPEND(buf, base);
    base = buf + strlen(buf);
    rest = sizeof(buf) - strlen(buf);

    if(check_access(buf, CHECK_DIR) == ERROR)
    {
	if(mkdir(buf, DIR_MODE) == -1)
	{
	    fglog("$WARNING: can't create dir %s", buf);
	    return ERROR;
	}
	chmod(buf, DIR_MODE);
    }
    
#ifndef AMIGADOS_4D_OUTBOUND
    /*
     * Point directory for point addresses
     */
    if(node->point > 0)
    {
	str_printf(base, rest, "/%04x%04x.pnt", node->net, node->node);
	if(check_access(buf, CHECK_DIR) == ERROR)
	{
	    if(mkdir(buf, DIR_MODE) == -1)
	    {
		fglog("$WARNING: can't create dir %s", buf);
		return ERROR;
	    }
	    chmod(buf, DIR_MODE);
	}
    }
#endif /**AMIGADOS_4D_OUTBOUND**/

    return OK;
}
开发者ID:oldprogs,项目名称:fidogate-ds,代码行数:54,代码来源:binkley.c

示例8: append_to_topic

int append_to_topic(User * u, Channel *c, char *newtopic) {
	char topic[1024];
	ChannelInfo *ci = c->ci;

	if (!newtopic) {
		noticeLang(ci->bi->nick, u, LANG_APPENDT_SYNTAX);
		return MOD_STOP;
	}

	if (ci->flags & CI_VERBOTEN) {
		notice_lang(ci->bi->nick, u, CHAN_X_FORBIDDEN, ci->name);
		return MOD_STOP;
	}

	if (!my_check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !my_check_access(u, ci, CA_OPDEOPME))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
		return MOD_STOP;
	}

	if (ci->last_topic) {
		snprintf(topic, sizeof(topic), "%s %s %s", ci->last_topic,
			(AppendToTopicDel ? AppendToTopicDel : "||"), newtopic);
		free(ci->last_topic);
	} else
		strcpy(topic, newtopic);

	ci->last_topic = *topic ? sstrdup(topic) : NULL;
	strscpy(ci->last_topic_setter, u->nick, NICKMAX);
	ci->last_topic_time = time(NULL);

	if (c->topic) free(c->topic);
	c->topic = *topic ? sstrdup(topic) : NULL;
	strscpy(c->topic_setter, u->nick, NICKMAX);

	if (ircd->topictsbackward) {
		c->topic_time = c->topic_time - 1;
	} else {
		c->topic_time = ci->last_topic_time;
	}

	if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC) &&
			((ci->flags & CI_TOPICLOCK) || !check_access(u, ci, CA_OPDEOPME)))
		alog("%s: %s!%[email protected]%s changed topic of %s as services admin.",
			ci->bi->nick, u->nick, u->username, u->host, c->name);

	anope_cmd_topic(ci->bi->nick, c->name, u->nick, topic, c->topic_time);

	return MOD_CONT;
}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:49,代码来源:misc_cmds.c

示例9: check_access

bool regkey_t::access_allowed( ACCESS_MASK required, ACCESS_MASK handle )
{
	return check_access( required, handle,
			 KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS|KEY_NOTIFY,
			 KEY_SET_VALUE|KEY_CREATE_SUB_KEY|KEY_CREATE_LINK,
			 KEY_ALL_ACCESS );
}
开发者ID:killvxk,项目名称:ring3k,代码行数:7,代码来源:reg.cpp

示例10: do_fantasy

/**
 * Handle unban fantasy command.
 * @param argc Argument count
 * @param argv Argument list
 * @return MOD_CONT or MOD_STOP
 **/
static int do_fantasy(int argc, char **argv)
{
    User *u;
    ChannelInfo *ci;
    char *target = NULL;

    if (argc < 3)
        return MOD_CONT;

    if (stricmp(argv[0], "unban") == 0) {
        u = finduser(argv[1]);
        ci = cs_findchan(argv[2]);
        if (!u || !ci || !check_access(u, ci, CA_UNBAN))
            return MOD_CONT;

        if (argc >= 4)
            target = myStrGetToken(argv[3], ' ', 0);
        if (!target)
            common_unban_full(ci, u->nick, true);
        else
            common_unban(ci, target);

        /* free target if needed (#852) */
        Anope_Free(target);
    }

    return MOD_CONT;
}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:34,代码来源:bs_fantasy_unban.c

示例11: valid_read

nomask int valid_read(string what, object act_ob) {
    string eff_user;
    int security;

    if (!act_ob) return 0;
    eff_user = geteuid(act_ob);
    security = check_access(what);
    debug("check_access ok, security level " + security + " returned.");
    // Okay, let's check the access situation before going further.
    if(!intp(security))  security = 0;
    switch (security) {
    case PUBLIC :
    case READ_ONLY :
    case MASTER_ONLY :
    case LOCKED :
        return 1;
        break;
    case OWNER_ONLY :
    case PRIVATE :
        if (eff_user != geteuid() && eff_user != ROOT_UID)
            return 0;
        break;
    default :
        debug("default case reached.");
        return 0;
        break;
    }
    // anything that makes it to this point should be ok, right?
    return 1;
}
开发者ID:Hobbitron,项目名称:tmi2_fluffos_v3,代码行数:30,代码来源:priv.c

示例12: path_finding

int					path_finding(t_tree *current, char **all_path, char *name)
{
	if (sgt_sh()->env == NULL || !current->args || !current->args[0])
		return (g_return);
	if (current->args[0][0] != '.' && current->args[0][0] != '/')
	{
		all_path = ft_strsplit(sh_getenv(sgt_sh()->env, "PATH"), ':');
		if (all_path == NULL)
			return (g_return);
		if ((name = get_executable_path(all_path, current->args[0], 0)) \
			&& (g_return = 1))
			current->full_path = name;
		ft_strtable_clear(&all_path);
	}
	else if ((current->args[0][0] == '.' || current->args[0][0] == '/')
		&& ft_strcmp(current->args[0], ".."))
	{
		if (check_access(current->args[0]) != 0 && (g_return = 1))
		{
			if (current->args[0])
				current->full_path = ft_strdup(current->args[0]);
			current->args = update_name(current->args, 0, 0);
		}
	}
	if (!ft_strcmp(current->args[0], ".."))
		return (-2);
	return (g_return);
}
开发者ID:w0dm4n,项目名称:42sh,代码行数:28,代码来源:path_finding.c

示例13: cd_tild

int		cd_tild(char **args, t_dlist *env, t_cmd *cmd, int i)
{
  char		*path;

  path = get_path_from_opt(args[1]);
  if (check_access(env, cmd, i) == -1)
    return (-1);
  chdir(get_my_home(env));
  if (strcmp(path, "\0") == 0)
    {
      modif_oldpwd(get_env("PWD", env), env);
      modif_pwd_from_home_to_path(args[1], env);
      return (0);
    }
  path = realloc_path(path, env);
  if (access(path, F_OK) == -1 || access(path, R_OK) == -1)
    {
      if (access(path, F_OK) == -1)
	fprintf(stderr, "42sh: cd: No such file or directory\n");
      else
	print_permission_denied(cmd, i);
      return (-1);
    }
  chdir(path);
  modif_oldpwd(get_env("PWD", env), env);
  modif_pwd_from_home_to_path(args[1], env);
  return (0);
}
开发者ID:girards,项目名称:42sh,代码行数:28,代码来源:func_my_cd.c

示例14: check_access

bool event_impl_t::access_allowed( ACCESS_MASK required, ACCESS_MASK handle )
{
	return check_access( required, handle,
			 EVENT_QUERY_STATE,
			 EVENT_MODIFY_STATE,
			 EVENT_ALL_ACCESS );
}
开发者ID:killvxk,项目名称:ring3k,代码行数:7,代码来源:event.cpp

示例15: display_nametab

void display_nametab(dbref player, NAMETAB * ntab, char *prefix,
					 int list_if_none)
{
	char *buf, *bp, *cp;
	NAMETAB *nt;
	int got_one;

	buf = alloc_lbuf("display_nametab");
	bp = buf;
	got_one = 0;
	for(cp = prefix; *cp; cp++)
		*bp++ = *cp;
	for(nt = ntab; nt->name; nt++) {
		if(God(player) || check_access(player, nt->perm)) {
			*bp++ = ' ';
			for(cp = nt->name; *cp; cp++)
				*bp++ = *cp;
			got_one = 1;
		}
	}
	*bp = '\0';
	if(got_one || list_if_none)
		notify(player, buf);
	free_lbuf(buf);
}
开发者ID:chazu,项目名称:btmux,代码行数:25,代码来源:nametab.c


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