void lttng::Session::enable_event(const std::string& event) { auto cp = core::posix::exec( "/usr/bin/lttng", {"enable-event", event, "--" + boost::lexical_cast<std::string>(domain_), "-s", name_}, copy_env(), core::posix::StandardStream::empty); throw_if_error(cp.wait_for(core::posix::wait::Flags::untraced)); }
int exec_env(t_struc *s, char **env2) { int i; int j; int option_i; char **new_env; i = 1; j = 1; option_i = 0; new_env = env2 ? copy_env(env2) : (char **)malloc(sizeof(char *) * 1); if (s->argc == 1) print_env(new_env); else { if (get_env_options(s, &i, &option_i) == -1) return (-1); if (option_i) new_env = (char **)malloc(sizeof(char *) * 1); s->cmd = NULL; new_env = exec_env2(s, i, j, new_env); if (s->cmd) !is_builtin(s) ? exec_cmd(s, new_env) : exec_builtin(s, new_env); else print_env(new_env); } return (0); }
Env * copy_env(Env * xs) { if (xs -> Nil) { return nil_env(); } else { return cons_env(copy_string(xs -> key), copy_string(xs -> val), copy_env(xs -> Cons)); } }
void lttng::Session::stop() { auto cp = core::posix::exec( "/usr/bin/lttng", {"stop", name_}, copy_env(), core::posix::StandardStream::stdout); throw_if_error(cp.wait_for(core::posix::wait::Flags::untraced)); }
void lttng::Session::add_context(lttng::Context context) { auto cp = core::posix::exec( "/usr/bin/lttng", {"add-context", "-t", boost::lexical_cast<std::string>(context), "--" + boost::lexical_cast<std::string>(domain_), "-s", name_}, copy_env(), core::posix::StandardStream::empty); throw_if_error(cp.wait_for(core::posix::wait::Flags::untraced)); }
lttng::Session::~Session() { auto cp = core::posix::exec( "/usr/bin/lttng", {"destroy", name_}, copy_env(), core::posix::StandardStream::empty); throw_if_error(cp.wait_for(core::posix::wait::Flags::untraced)); }
set_env_(const Range &envs) { std::size_t s = std::accumulate(envs.begin(), envs.end(), std::size_t(0), &set_env_::get_size); env_.resize(s + 1); std::for_each(envs.begin(), envs.end(), copy_env(env_.data())); env_[env_.size() - 1] = 0; }
void addnode(t_list **s, char **name) { if (*s == NULL) { *s = (t_list *)malloc(sizeof(t_list)); (*s)->content = copy_env((*s)->content, name); (*s)->next = NULL; } else addnode(&((*s)->next), name); }
int main(int ac, char **av, char **ae) { char **env; int x; env = copy_env(ae, env); x = 0; while (x == 0) env = prompt_loop(env); return (0); }
lttng::Session::Session(lttng::Domain domain, const std::string& name, const std::shared_ptr<lttng::Consumer>& consumer) : domain_(domain), name_(name), consumer_(consumer) { auto cp = core::posix::exec( "/usr/bin/lttng", {"create", name_, "--set-url", consumer->to_url()}, copy_env(), core::posix::StandardStream::empty); throw_if_error(cp.wait_for(core::posix::wait::Flags::untraced)); }
int main(UNUSED int ac, UNUSED char **av, char **env) { t_data data; data.user = NULL; data.old_pwd = NULL; signal(SIGINT, SIG_IGN); init_builtins(&data); copy_env(env, &data); if (start_shell(&data) == -2) { free_all(&data); return (my_getnbr(data.cmd[1])); } free_all(&data); return (0); }
int main(int ac, char **av, char **env) { t_shell *shell; t_check check[4]; int return_value; if ((shell = malloc(sizeof(t_shell))) == NULL) return (1); if (env[0] != NULL) copy_env(shell, env); shell->status = 0; init_check(check); return_value = my_core(shell, check); (void)ac; (void)av; my_putstr("exit\n"); free_all_on_exit(shell); return (return_value); }
int main(int argc, char **argv, char **env) { t_struc s; ft_poubelle(argc, argv); gestion_signaux(); if (env[0]) s.env = copy_env(env); else s.env = creat_minimalist_env(); increment_shlvl(&s); s.line = ft_strnew(0); while (42) { ft_putstr("[\033[32mMinishell\033[33;0m] > "); run_minishell(&s); } free(s.line); return (0); }
t_colour refract(t_env *e, int depth, t_colour colour) { t_env *refract_env; if (depth > e->maxdepth) return (colour); refract_env = copy_env(e); if (e->hit_type == FACE) { set_refract_ray_object(e, refract_env); intersect_scene(refract_env); colour = find_colour_struct(refract_env, depth); } else if (e->hit_type == PRIMITIVE) { set_refract_ray_prim(e, refract_env); intersect_scene(refract_env); colour = find_colour_struct(refract_env, depth); } free(refract_env); return (colour); }
struct global_state *copy_global_state(struct global_state *gstate) /* Returns: A copy of global state gstate, which includes copying global variable and module state */ { struct global_state *newp; value tmp; GCPRO1(gstate); newp = (struct global_state *)allocate_record(type_vector, 8); GCPRO1(newp); tmp = copy_table(gstate->modules); newp->modules = tmp; tmp = copy_vector(gstate->mvars); newp->mvars = tmp; tmp = copy_vector(gstate->types); newp->types = tmp; tmp = copy_vector(gstate->names); newp->names = tmp; tmp = copy_table(gstate->global); newp->global = tmp; tmp = copy_table(gstate->gsymbols); newp->gsymbols = tmp; tmp = copy_env(gstate->environment); newp->environment = tmp; newp->machine = gstate->machine; GCPOP(2); return newp; }
int main(int argc, char **argv) { int max_tries = 5; int try; char username[32]; int optidx = 0; int ask = 1; struct sigaction sa; setprogname(argv[0]); #ifdef KRB5 { krb5_error_code ret; ret = krb5_init_context(&context); if (ret) errx (1, "krb5_init_context failed: %d", ret); } #endif openlog("login", LOG_ODELAY | LOG_PID, LOG_AUTH); if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx)) usage (1); argc -= optidx; argv += optidx; if(help_flag) usage(0); if (version_flag) { print_version (NULL); return 0; } if (geteuid() != 0) errx(1, "only root may use login, use su"); /* Default tty settings. */ stty_default(); if(p_flag) copy_env(); else { /* this set of variables is always preserved by BSD login */ if(getenv("TERM")) add_env("TERM", getenv("TERM")); if(getenv("TZ")) add_env("TZ", getenv("TZ")); } if(*argv){ if(strchr(*argv, '=') == NULL && strcmp(*argv, "-") != 0){ strlcpy (username, *argv, sizeof(username)); ask = 0; } } #if defined(DCE) && defined(AIX) esetenv("AUTHSTATE", "DCE", 1); #endif /* XXX should we care about environment on the command line? */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGALRM, &sa, NULL); alarm(login_timeout); for(try = 0; try < max_tries; try++){ struct passwd *pwd; char password[128]; int ret; char ttname[32]; char *tty, *ttyn; char prompt[128]; #ifdef OTP char otp_str[256]; #endif if(ask){ f_flag = 0; #if 0 r_flag = 0; #endif ret = read_string("login: "******""); } else #endif { #ifdef OTP if(auth_level && strcmp(auth_level, "otp") == 0 && otp_challenge(&otp_ctx, username, otp_str, sizeof(otp_str)) == 0) snprintf (prompt, sizeof(prompt), "%s's %s Password: "******"Password: "******"Login incorrect.\n"); ask = 1; continue; } if(f_flag == 0 && check_password(pwd, password)){ fprintf(stderr, "Login incorrect.\n"); ask = 1; continue; } ttyn = ttyname(STDIN_FILENO); if(ttyn == NULL){ snprintf(ttname, sizeof(ttname), "%s??", _PATH_TTY); ttyn = ttname; } if (strncmp (ttyn, _PATH_DEV, strlen(_PATH_DEV)) == 0) tty = ttyn + strlen(_PATH_DEV); else tty = ttyn; if (login_access (pwd, remote_host ? remote_host : tty) == 0) { fprintf(stderr, "Permission denied\n"); if (remote_host) syslog(LOG_NOTICE, "%s LOGIN REFUSED FROM %s", pwd->pw_name, remote_host); else syslog(LOG_NOTICE, "%s LOGIN REFUSED ON %s", pwd->pw_name, tty); exit (1); } else { if (remote_host) syslog(LOG_NOTICE, "%s LOGIN ACCEPTED FROM %s ppid=%d", pwd->pw_name, remote_host, (int) getppid()); else syslog(LOG_NOTICE, "%s LOGIN ACCEPTED ON %s ppid=%d", pwd->pw_name, tty, (int) getppid()); } alarm(0); do_login(pwd, tty, ttyn); } exit(1); }