Mercurial > pkg
view defaults/hg-wrapper.cpp @ 9:a0c0ccd22ca5
progress on setuid wrapper script.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 09 Jan 2013 04:53:59 +0000 |
parents | |
children | bd465da5cd0f |
line wrap: on
line source
1 #include <stdio.h>2 //#include <stdlib.h>3 #include <cstdlib>4 #include <iostream>5 #include <vector>6 #include <string>8 #include <algorithm>10 #include <unistd.h>11 //#include <numeric>14 #include <boost/algorithm/string/join.hpp>16 // void print_element(std::string x){17 // std::cout << x << std::endl;18 // }21 main( int argc, char ** argv){23 // remove first element of argv, the program's name24 std::vector<std::string> input(argv, argv+argc);27 //std::cout << input.size() << std::endl;29 input[0] = std::string("hg");31 //input.insert(input.begin(),std::string("hg"));33 //std::cout << input.size() << std::endl;35 // for(unsigned i = 0; i < input.size(); i++){36 // std::cout << input[i] << std::endl;38 // }40 //for_each(input.begin(),input.end(), print_element);43 // std::string command =44 // accumulate(input.begin(), input.end(), std::string(" "));46 std::string command = boost::algorithm::join(input, " ");49 //.c_str();51 //std::cout << command << std::endl;53 setreuid( geteuid(), geteuid() );54 //envp = 0; /* blocks IFS attack on non-bash shells */55 //system( "/usr/bin/hg", argv, envp );56 return system(command.c_str());57 //perror( argv[0] );58 //return errno;59 }