Пример #1
0
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);
    }
  }
}
/* 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;
}
Пример #3
0
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;
}
Пример #4
0
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);
}
Пример #5
0
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!%s@%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;
}
Пример #6
0
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!%s@%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;
}
Пример #7
0
/*
 * 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;
}
Пример #8
0
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!%s@%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;
}
Пример #9
0
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 );
}
Пример #10
0
/**
 * 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;
}
Пример #11
0
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;
}
Пример #12
0
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);
}
Пример #13
0
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);
}
Пример #14
0
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 );
}
Пример #15
0
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);
}
Пример #16
0
static status_t
packagefs_open_dir(fs_volume* fsVolume, fs_vnode* fsNode, void** _cookie)
{
	Volume* volume = (Volume*)fsVolume->private_volume;
	Node* node = (Node*)fsNode->private_node;

	FUNCTION("volume: %p, node: %p (%" B_PRId64 ")\n", volume, node,
		node->ID());
	TOUCH(volume);

	if (!S_ISDIR(node->Mode()))
		return B_NOT_A_DIRECTORY;

	Directory* dir = dynamic_cast<Directory*>(node);

	status_t error = check_access(dir, R_OK);
	if (error != B_OK)
		return error;

	// create a cookie
	NodeWriteLocker dirLocker(dir);
	DirectoryCookie* cookie = new(std::nothrow) DirectoryCookie(dir);
	if (cookie == NULL)
		RETURN_ERROR(B_NO_MEMORY);

	*_cookie = cookie;
	return B_OK;
}
Пример #17
0
static status_t
packagefs_open(fs_volume* fsVolume, fs_vnode* fsNode, int openMode,
	void** _cookie)
{
	Volume* volume = (Volume*)fsVolume->private_volume;
	Node* node = (Node*)fsNode->private_node;

	FUNCTION("volume: %p, node: %p (%" B_PRId64 "), openMode %#x\n",
		volume, node, node->ID(), openMode);
	TOUCH(volume);

	NodeReadLocker nodeLocker(node);

	// check the open mode and permissions
	if (S_ISDIR(node->Mode()) && (openMode & O_RWMASK) != O_RDONLY)
		return B_IS_A_DIRECTORY;

	if ((openMode & O_RWMASK) != O_RDONLY)
		return B_NOT_ALLOWED;

	status_t error = check_access(node, R_OK);
	if (error != B_OK)
		return error;

	// allocate the cookie
	FileCookie* cookie = new(std::nothrow) FileCookie(openMode);
	if (cookie == NULL)
		RETURN_ERROR(B_NO_MEMORY);

	*_cookie = cookie;

	return B_OK;
}
Пример #18
0
static Boolean_t
connection_parameters_get(iscsi_conn_t *c, char *targ_name)
{
	tgt_node_t	*targ, *alias;
	Boolean_t	rval	= False;

	if ((targ = find_target_node(targ_name)) != NULL) {

		if (check_access(targ, c->c_sess->s_i_name, False) == False)
			return (False);

		/*
		 * Have a valid node for our target. Start looking
		 * for connection oriented parameters.
		 */
		if ((c->c_tpgt = convert_to_tpgt(c, targ)) == 0)
			return (False);
		if ((alias = tgt_node_next(targ, XML_ELEMENT_ALIAS, NULL)) ==
		    NULL) {
			(void) tgt_find_value_str(targ, XML_ELEMENT_TARG,
			    &c->c_targ_alias);
		} else {
			(void) tgt_find_value_str(alias, XML_ELEMENT_ALIAS,
			    &c->c_targ_alias);
		}

		(void) tgt_find_value_int(targ, XML_ELEMENT_MAXCMDS,
		    &c->c_maxcmdsn);
		rval = True;
	}

	return (rval);
}
Пример #19
0
void listset_nametab(dbref player, NAMETAB * ntab, int flagword, char *prefix,
					 int list_if_none)
{
	char *buf, *bp, *cp;
	NAMETAB *nt;
	int got_one;

	buf = bp = alloc_lbuf("listset_nametab");
	for(cp = prefix; *cp; cp++)
		*bp++ = *cp;
	nt = ntab;
	got_one = 0;
	while (nt->name) {
		if(((flagword & nt->flag) != 0) && (God(player) ||
											check_access(player, nt->perm))) {
			*bp++ = ' ';
			for(cp = nt->name; *cp; cp++)
				*bp++ = *cp;
			got_one = 1;
		}
		nt++;
	}
	*bp = '\0';
	if(got_one || list_if_none)
		notify(player, buf);
	free_lbuf(buf);
}
Пример #20
0
status_t
packagefs_open_attr(fs_volume* fsVolume, fs_vnode* fsNode, const char* name,
	int openMode, void** _cookie)
{
	Volume* volume = (Volume*)fsVolume->private_volume;
	Node* node = (Node*)fsNode->private_node;

	FUNCTION("volume: %p, node: %p (%" B_PRId64 "), name: \"%s\", openMode "
			"%#x\n", volume, node, node->ID(), name, openMode);
	TOUCH(volume);

	NodeReadLocker nodeLocker(node);

	// check the open mode and permissions
	if ((openMode & O_RWMASK) != O_RDONLY)
		return B_NOT_ALLOWED;

	status_t error = check_access(node, R_OK);
	if (error != B_OK)
		return error;

	AttributeCookie* cookie;
	error = node->OpenAttribute(StringKey(name), openMode, cookie);
	if (error != B_OK)
		return error;

	*_cookie = cookie;
	return B_OK;
}
Пример #21
0
void interp_nametab(dbref player, NAMETAB * ntab, int flagword, char *prefix,
					char *true_text, char *false_text)
{
	char *buf, *bp, *cp;
	NAMETAB *nt;

	buf = alloc_lbuf("interp_nametab");
	bp = buf;
	for(cp = prefix; *cp; cp++)
		*bp++ = *cp;
	nt = ntab;
	while (nt->name) {
		if(God(player) || check_access(player, nt->perm)) {
			*bp++ = ' ';
			for(cp = nt->name; *cp; cp++)
				*bp++ = *cp;
			*bp++ = '.';
			*bp++ = '.';
			*bp++ = '.';
			if((flagword & nt->flag) != 0)
				cp = true_text;
			else
				cp = false_text;
			while (*cp)
				*bp++ = *cp++;
			if((++nt)->name)
				*bp++ = ';';
		}
	}
	*bp = '\0';
	notify(player, buf);
	free_lbuf(buf);
}
Пример #22
0
void decompile_flags(dbref player, dbref thing, UTF8 *thingname)
{
    // Report generic flags.
    //
    FLAGNAMEENT *fp;
    for (fp = gen_flag_names; fp->flagname; fp++)
    {
        FLAGBITENT *fbe = fp->fbe;

        // Only handle positive-sense entries.
        // Skip if we shouldn't decompile this flag.
        // Skip if this flag isn't set.
        // Skip if we can't see this flag.
        //
        if (  !fp->bPositive
           || (fbe->listperm & CA_NO_DECOMP)
           || (db[thing].fs.word[fbe->flagflag] & fbe->flagvalue) == 0
           || !check_access(player, fbe->listperm))
        {
            continue;
        }

        // Report this flag.
        //
        notify(player, tprintf(T("@set %s=%s"), thingname, fp->flagname));
    }
}
Пример #23
0
Файл: util.c Проект: imp/slist
/*
 * []----
 * | add_targets -- add TargetName and TargetAddress to text argument
 * |
 * | Add targets which this initiator is allowed to see based on
 * | the access_list associated with a target. If a target doesn't
 * | have an access list then let everyone see it.
 * []----
 */
static Boolean_t
add_targets(iscsi_conn_t *c, char **text, int *text_length)
{
	tgt_node_t	*targ		= NULL;
	Boolean_t	rval		= True;
	char		*targ_name	= NULL;

	while ((rval == True) && ((targ = tgt_node_next_child(targets_config,
	    XML_ELEMENT_TARG, targ)) != NULL)) {

		if (check_access(targ, c->c_sess->s_i_name, False) == True) {

			if (tgt_find_value_str(targ, XML_ELEMENT_INAME,
			    &targ_name) == False) {
				rval = False;
				break;
			}
			queue_prt(c->c_mgmtq, Q_CONN_LOGIN,
			    "CON%x    %24s = %s\n", c->c_num, "TargetName",
			    targ_name);

			(void) add_text(text, text_length, "TargetName",
			    targ_name);
			free(targ_name);
			add_target_address(c, text, text_length, targ);
		}
	}
	return (rval);
}
Пример #24
0
/*
 * null_login - Check if a username of "" and a password of "" are
 * acceptable, and iff so, set the list of acceptable IP addresses
 * and return 1.
 */
static int
null_login(int unit)
{
    char *filename;
    FILE *f;
    int i, ret;
    struct wordlist *addrs;
    char secret[MAXWORDLEN];

    /*
     * Open the file of pap secrets and scan for a suitable secret.
     * We don't accept a wildcard client.
     */
    filename = _PATH_UPAPFILE;
    addrs = NULL;
    f = fopen(filename, "r");
    if (f == NULL)
	return 0;
    check_access(f, filename);

    i = scan_authfile(f, "", our_name, (u_int32_t)0, secret, &addrs, filename);
    ret = i >= 0 && (i & NONWILD_CLIENT) != 0 && secret[0] == 0;
    BZERO(secret, sizeof(secret));

    if (ret)
	set_allowed_addrs(unit, addrs);
    else
	free_wordlist(addrs);

    fclose(f);
    return ret;
}
Пример #25
0
bool object_dir_impl_t::access_allowed( ACCESS_MASK required, ACCESS_MASK handle )
{
	return check_access( required, handle,
			 DIRECTORY_QUERY | DIRECTORY_TRAVERSE,
			 DIRECTORY_CREATE_OBJECT | DIRECTORY_CREATE_SUBDIRECTORY,
			 DIRECTORY_ALL_ACCESS );
}
Пример #26
0
int		exist(t_tab *tab, t_btree **tree)
{
  int		j;
  char		*ptr;
  char		*error;

  j = -1;
  if (((ptr = my_strdup((*tree)->right->stock[0])) == NULL) ||
      ((error = my_strdup((*tree)->right->stock[0])) == NULL))
    return (-1);
  if (tab->path && (*tree)->right->stock[0] != NULL
      && (*tree)->right->stock[0][0] != '/'
      && my_strncmp("./", (*tree)->right->stock[0], 2) != 0)
    {
      if (tab->path[++j] != NULL)
	(*tree)->right->stock[0] = my_strslashcat(tab->path[++j], ptr);
      while ((access((*tree)->right->stock[0], F_OK)) && (tab->path[++j]))
	{
	  if (access((*tree)->right->stock[0], F_OK) != 0)
	    free((*tree)->right->stock[0]);
	  (*tree)->right->stock[0] = my_strslashcat(tab->path[j], ptr);
	}
    }
  free(ptr);
  if (check_access(tree, error) == 0)
    return (0);
  return (-1);
}
Пример #27
0
/*
 * get_pap_passwd - get a password for authenticating ourselves with
 * our peer using PAP.  Returns 1 on success, 0 if no suitable password
 * could be found.
 */
static int
get_pap_passwd(char *passwd)
{
    char *filename;
    FILE *f;
    int ret;
    struct wordlist *addrs;
    char secret[MAXWORDLEN];

    filename = _PATH_UPAPFILE;
    addrs = NULL;
    f = fopen(filename, "r");
    if (f == NULL)
	return 0;
    check_access(f, filename);
    ret = scan_authfile(f, user,
			remote_name[0]? remote_name: NULL,
			(u_int32_t)0, secret, NULL, filename);
    fclose(f);
    if (ret < 0)
	return 0;
    if (passwd != NULL) {
	strncpy(passwd, secret, MAXSECRETLEN);
	passwd[MAXSECRETLEN-1] = 0;
    }
    BZERO(secret, sizeof(secret));
    return 1;
}
RC destroyPageFile (char *fileName)
{
RC Return_Code;
FILE *File_Pointer; 
int rval;

//Check for file existence
rval = check_access(fileName,'e');
//Check fo existence
if (rval != -1)
	{
	printf("\n File exists");
	// if exists ,try deleting
	if(remove(fileName) == 0)
	{
	printf("\nFile named %s deleted", fileName); 
	Return_Code = RC_OK;
	}
	else
	{
	// If error,
	printf("\nFile named %s cant be deleted", fileName); 	 
	Return_Code = RC_FILE_HANDLE_NOT_INIT;
	}
}
else
{
//The file does not exist 
printf("\n File doesnt exists");
Return_Code = RC_FILE_NOT_FOUND;
}
return Return_Code;
}
Пример #29
0
static int do_generic_cmd(const char *me, char *arg)
{
    cmd_type_t ct;
    char user[256];
    char cmd[1024];

    /*setup_path();*/
    if (!arg) die("bad argument: NULL");

    if (!(arg = sq_dequote(arg))) die("bad argument");
    if (prefixcmp(me, "git-")) die("bad command");
    if (*arg == '/') ++arg;
    switch ((ct = check_access(arg, user, sizeof(user)))) {
    case ct_gitshell:
	fprintf(stderr, "%s %s %s\n", GIT_COMMAND, me + 4, arg);
	return execl(GIT_COMMAND, GIT_COMMAND, me + 4, arg, NULL);
    case ct_gitolite:
	snprintf(cmd, sizeof(cmd), "git-%s '%s'", me + 4, arg);
	setenv("SSH_ORIGINAL_COMMAND", cmd, !0);
	setenv("GITOLITE_HTTP_HOME", GITOLITE_HTTP_HOME, !0);
	fprintf(stderr, "gitolite: user = [%s] cmd = [%s]\n", user, cmd);
	return execl(PERL_COMMAND, PERL_COMMAND, GL_AUTH_COMMAND, user, NULL);
    }
    die("Unknown command type: %u", ct);
    return -1;
}
RC createPageFile (char *fileName)//To create a page file
{
RC Return_Code;
FILE *File_Pointer; 
int rval,ctr; 
//Check the file for existence
rval = check_access(fileName,'e');
	if( rval != -1)
	{
	//If the file exists 
	printf("\n The file exists already");
	Return_Code = RC_OK;
	}
// Open the file
File_Pointer = fopen (fileName,"wb");
	// Check for return code when file creates
	if (File_Pointer == NULL)
	{
	printf("\n File creation error");
	Return_Code = RC_FILE_HANDLE_NOT_INIT;
	}
	else
	{
	// File opened
	printf("\nFile created and opened to write null characters");
	// Fill with null bytes for the first page (of PAGE_SIZE)
	for(ctr=0 ; ctr<PAGE_SIZE; ctr++)
	fprintf(File_Pointer,"%c",'\0');
	Return_Code = RC_OK;
	}
fclose(File_Pointer);
return Return_Code;
}