diff --git a/ServidorTFG.pro.user b/ServidorTFG.pro.user index bb9222d..b796cf9 100644 --- a/ServidorTFG.pro.user +++ b/ServidorTFG.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/session_manager.cpp b/session_manager.cpp index 44c38a0..0a75192 100644 --- a/session_manager.cpp +++ b/session_manager.cpp @@ -20,7 +20,6 @@ bool session_manager::validate_pass(){ std::string user=buffer; this->read_data(buffer, 256); std::string pass=std::string(data_acces::get_hash(buffer)); - delete[] (buffer); if(this->data->get_passwd(user)==pass){ this->write_data("pass"); if(this->data->get_admin(user)){ @@ -30,7 +29,15 @@ bool session_manager::validate_pass(){ this->write_data("norma"); this->admin=false; } + this->read_data(buffer, 256); + std::string env=std::string(buffer); + if(env=="no"){ + this->env=""; + }else{ + this->env=env+"-"; + } this->user=user; + delete[] (buffer); return true; }else{ this->write_data("fail"); @@ -103,12 +110,13 @@ int session_manager::remove(){ } std::string session_manager::appli_command(char comand[], char* n_package){ - char** args=new char*[5]; + char** args=new char*[6]; args[0]="sudo"; - args[1]="emerge"; - args[2]=comand; - args[3]=n_package; - args[4]=nullptr; + args[1]=strcat(&this->env[0],"emerge"); + args[2]="--buildpkg"; + args[3]=comand; + args[4]=n_package; + args[5]=nullptr; int pid = fork(); int status=-2; std::string ret; diff --git a/session_manager.h b/session_manager.h index 36b3e2f..d44e77d 100644 --- a/session_manager.h +++ b/session_manager.h @@ -79,26 +79,11 @@ public: * @return Number of bytes writed */ virtual int write_data(std::string output); - /** - * @brief fd - * Socket file desccriptor - */ int fd; - /** - * @brief data - * Object that contain media used to store and read information - */ data_acces* data; - /** - * @brief user - * Name of the session owner - */ std::string user; - /** - * @brief admin - * Privileges abut the user - */ bool admin; + std::string env; }; #endif // LAUNCHER_H