Ejemplo n.º 1
0
      static std::string format(const std::string &t_why, const File_Position &t_where, const std::string &t_fname)
      {
        std::stringstream ss;

        ss << format_why(t_why);
        ss << " ";

        ss << format_filename(t_fname);
        ss << " ";

        ss << format_location(t_where);

        return ss.str();
      }
Ejemplo n.º 2
0
static authn_status pam_authenticate_with_login_password(request_rec * r, const char * pam_service,
	const char * login, const char * password, int steps) {
	pam_handle_t * pamh = NULL;
	struct pam_conv pam_conversation = { &pam_authenticate_conv, (void *) password };
	const char * stage = "PAM transaction failed for service";
	const char * param = pam_service;
	int ret;
	ret = pam_start(pam_service, login, &pam_conversation, &pamh);
	if (ret == PAM_SUCCESS) {
		const char * remote_host_or_ip = ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL);
		if (remote_host_or_ip) {
			stage = "PAM pam_set_item PAM_RHOST failed for service";
			ret = pam_set_item(pamh, PAM_RHOST, remote_host_or_ip);
		}
	}
	if (ret == PAM_SUCCESS) {
		if (steps & _PAM_STEP_AUTH) {
			param = login;
			stage = "PAM authentication failed for user";
			ret = pam_authenticate(pamh, PAM_SILENT | PAM_DISALLOW_NULL_AUTHTOK);
		}
		if ((ret == PAM_SUCCESS) && (steps & _PAM_STEP_ACCOUNT)) {
			param = login;
			stage = "PAM account validation failed for user";
			ret = pam_acct_mgmt(pamh, PAM_SILENT | PAM_DISALLOW_NULL_AUTHTOK);
			if (ret == PAM_NEW_AUTHTOK_REQD) {
				authnz_pam_config_rec * conf = ap_get_module_config(r->per_dir_config, &authnz_pam_module);
				if (conf && conf->expired_redirect_url) {
					ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
						"mod_authnz_pam: PAM_NEW_AUTHTOK_REQD: redirect to [%s]",
						conf->expired_redirect_url);
					apr_table_addn(r->headers_out, "Location", format_location(r, conf->expired_redirect_url, login));
					return HTTP_TEMPORARY_REDIRECT;
				}
			}
		}
	}
	if (ret != PAM_SUCCESS) {
		const char * strerr = pam_strerror(pamh, ret);
		ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server, "mod_authnz_pam: %s %s: %s", stage, param, strerr);
		apr_table_setn(r->subprocess_env, _EXTERNAL_AUTH_ERROR_ENV_NAME, apr_pstrdup(r->pool, strerr));
		pam_end(pamh, ret);
		return AUTH_DENIED;
	}
	apr_table_setn(r->subprocess_env, _REMOTE_USER_ENV_NAME, login);
	r->user = apr_pstrdup(r->pool, login);
	ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, r->server, "mod_authnz_pam: PAM authentication passed for user %s", login);
	pam_end(pamh, ret);
	return AUTH_GRANTED;
}
Ejemplo n.º 3
0
      static std::string format(const std::string &t_why, const File_Position &t_where, const std::string &t_fname,
          const std::vector<Boxed_Value> &t_parameters, bool t_dot_notation, const chaiscript::detail::Dispatch_Engine &t_ss)
      {
        std::stringstream ss;

        ss << format_why(t_why);
        ss << " ";

        ss << "With parameters: " << format_parameters(t_parameters, t_dot_notation, t_ss);
        ss << " ";

        ss << format_filename(t_fname);
        ss << " ";

        ss << format_location(t_where);

        return ss.str();
      }
Ejemplo n.º 4
0
      static std::string format_types(const Const_Proxy_Function &t_func,
          bool t_dot_notation,
          const chaiscript::detail::Dispatch_Engine &t_ss)
      {
        int arity = t_func->get_arity();
        std::vector<Type_Info> types = t_func->get_param_types();

        std::string retval;
        if (arity == -1)
        {
          retval = "(...)";
          if (t_dot_notation)
          {
            retval = "(Object)." + retval;
          }
        } else if (types.size() <= 1) {
          retval = "()";
        } else {
          std::stringstream ss;
          ss << "(";

          std::string paramstr;

          for (size_t index = 1;
               index != types.size();
               ++index)
          {
            paramstr += (types[index].is_const()?"const ":"");
            paramstr += t_ss.get_type_name(types[index]);

            if (index == 1 && t_dot_notation)
            {
              paramstr += ").(";
              if (types.size() == 2)
              {
                paramstr += ", ";
              }
            } else {
              paramstr += ", ";
            }
          }

          ss << paramstr.substr(0, paramstr.size() - 2);

          ss << ")";
          retval = ss.str();
        }


        std::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynfun 
          = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_func);

        if (dynfun)
        {
          Proxy_Function f = dynfun->get_guard();

          if (f)
          {
            std::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynfunguard 
              = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(f);
            if (dynfunguard)
            {
              retval += " : " + format_guard(dynfunguard->get_parse_tree());
            }
          }

          retval += "\n          Defined at " + format_location(dynfun->get_parse_tree());        
        }

        return retval;
      }