Esempio n. 1
0
static void populate_environment(const struct su_context *ctx)
{
    struct passwd *pw;
    char *val;

    if (ctx->to.keepenv)
        return;

    pw = getpwuid(ctx->to.uid);
    if (pw) {
        setenv("HOME", pw->pw_dir, 1);
        setenv("SHELL", ctx->to.shell, 1);
        if (ctx->to.login || ctx->to.uid) {
            setenv("USER", pw->pw_name, 1);
            setenv("LOGNAME", pw->pw_name, 1);
        }
    }

    if (ctx->sdk_version >= 14) {
        val = get_parent_env(&ctx->from, "LD_LIBRARY_PATH", sizeof("LD_LIBRARY_PATH") - 1);
        if (val)
            if (setenv("LD_LIBRARY_PATH", val, 1))
                PLOGE("setenv(LD_LIBRARY_PATH)");
    }
}
Esempio n. 2
0
    std::ostream& operator<<( std::ostream& os, const_environment_base_ptr const& env )
    {
        os << "DEBUG: environment" << std::endl;
        auto e = env;
        std::string indent = "^ ";

        if ( e ) {
            while( !e->is_root() ) {
                e->dump( os, indent );
                e = e->get_parent_env();
                indent += "  ";
            }
            return e->dump( os, indent );

        } else {
            os << indent << "nullptr." << std::endl;
            return os;
        }
    }