mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 11:26:51 +01:00
「✨」 feat: Added security to redirection fd
This commit is contained in:
28
src/main.c
28
src/main.c
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/07/09 16:08:08 by adjoly ### ########.fr */
|
/* Updated: 2024/07/09 16:41:08 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -56,39 +56,29 @@ int main(int ac, char **av, char **env)
|
|||||||
free(prompt);
|
free(prompt);
|
||||||
if (!rl)
|
if (!rl)
|
||||||
break ;
|
break ;
|
||||||
if (!*rl)
|
if (run_checks(rl))
|
||||||
{
|
{
|
||||||
|
free(rl);
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
if (run_checks(rl))
|
|
||||||
continue ;
|
|
||||||
piped = tokenizer(rl);
|
piped = tokenizer(rl);
|
||||||
if (check_argv(piped))
|
if (check_argv(piped))
|
||||||
continue ;
|
continue ;
|
||||||
add_history(rl);
|
add_history(rl);
|
||||||
cmd_list = get_cmd_list(piped, env_l);
|
cmd_list = get_cmd_list(piped, env_l);
|
||||||
|
free(rl);
|
||||||
ft_lstclear(&piped, &free_token);
|
ft_lstclear(&piped, &free_token);
|
||||||
format_quotes(cmd_list);
|
format_quotes(cmd_list);
|
||||||
|
if (check_redir(cmd_list))
|
||||||
|
{
|
||||||
|
ft_lstclear(&cmd_list, &free_cmd);
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
exec_split_cmd(cmd_list, env_l);
|
exec_split_cmd(cmd_list, env_l);
|
||||||
ft_lstclear(&cmd_list, &free_cmd);
|
ft_lstclear(&cmd_list, &free_cmd);
|
||||||
free(rl);
|
|
||||||
}
|
}
|
||||||
free(rl);
|
free(rl);
|
||||||
rl_clear_history();
|
rl_clear_history();
|
||||||
//ft_lstclear(&piped, &free_token);
|
|
||||||
//ft_lstclear(&cmd_list, &free_cmd);
|
|
||||||
ft_envclear(&env_l, free);
|
ft_envclear(&env_l, free);
|
||||||
return (727);
|
return (727);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*int main(int ac, char **av, char **e)
|
|
||||||
{
|
|
||||||
t_env *env;
|
|
||||||
|
|
||||||
(void) ac;
|
|
||||||
(void) av;
|
|
||||||
env = env_init(e);
|
|
||||||
ft_envprint(env);
|
|
||||||
ft_envclear(&env, free);
|
|
||||||
}*/
|
|
||||||
|
30
src/parsing/check_error/check_redir.c
Normal file
30
src/parsing/check_error/check_redir.c
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* check_redir.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/07/09 16:32:21 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/07/09 16:39:44 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "parsing.h"
|
||||||
|
#include "error_msg.h"
|
||||||
|
|
||||||
|
bool check_redir(t_list *list)
|
||||||
|
{
|
||||||
|
t_list *tmp;
|
||||||
|
t_cmd *cmd;
|
||||||
|
|
||||||
|
tmp = list;
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
cmd = (t_cmd *)tmp->content;
|
||||||
|
if (cmd->infile == -1 || cmd->outfile == -1)
|
||||||
|
return (send_error_parsing(ERROR_NO_FILE));
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
}
|
Reference in New Issue
Block a user