changeset 12:e056798af879

fixing problem with shell interpretation.
author Robert McIntyre <rlm@mit.edu>
date Wed, 09 Jan 2013 07:09:37 +0000
parents 389f8678f1d8
children dcdeabe9e903
files defaults/Makefile defaults/hg-wrapper.c defaults/hg-wrapper.cpp defaults/hg-wrapper.pl defaults/profile org/pkg.org src/pkg.pl src/set-repository-perms.sh
diffstat 8 files changed, 67 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/defaults/Makefile	Wed Jan 09 05:11:10 2013 +0000
     1.2 +++ b/defaults/Makefile	Wed Jan 09 07:09:37 2013 +0000
     1.3 @@ -1,5 +1,7 @@
     1.4 +#all:
     1.5 +#	g++ -I/usr/include hg-wrapper.cpp -o hg-wrapper
     1.6 +
     1.7  all:
     1.8 -	g++ -I/usr/include hg-wrapper.cpp -o hg-wrapper
     1.9 -	chmod +s hg-wrapper
    1.10 +	gcc -I/usr/include -lpipeline hg-wrapper.c -o hg-wrapper
    1.11  clean:
    1.12  	rm hg-wrapper
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/defaults/hg-wrapper.c	Wed Jan 09 07:09:37 2013 +0000
     2.3 @@ -0,0 +1,14 @@
     2.4 +#include <pipeline.h>
     2.5 +
     2.6 +
     2.7 +main( int argc, char ** argv){
     2.8 +  pipecmd* p = pipecmd_new("hg");
     2.9 +  
    2.10 +  int i;
    2.11 +  for(i = 1; i < argc; i++){
    2.12 +    pipecmd_arg(p, argv[i]);
    2.13 +  }
    2.14 +
    2.15 +  pipecmd_exec(p);
    2.16 +
    2.17 +}
     3.1 --- a/defaults/hg-wrapper.cpp	Wed Jan 09 05:11:10 2013 +0000
     3.2 +++ b/defaults/hg-wrapper.cpp	Wed Jan 09 07:09:37 2013 +0000
     3.3 @@ -12,5 +12,6 @@
     3.4    input[0] = std::string("hg");
     3.5    std::string command = boost::algorithm::join(input, " ");
     3.6    setreuid(geteuid(), geteuid());
     3.7 +  setregid(getegid(), getegid());
     3.8    return system(command.c_str());
     3.9  }
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/defaults/hg-wrapper.pl	Wed Jan 09 07:09:37 2013 +0000
     4.3 @@ -0,0 +1,7 @@
     4.4 +#!/usr/bin/perl -wT
     4.5 +
     4.6 +$ENV{"PATH"} = "/usr/bin";
     4.7 +delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)};
     4.8 +
     4.9 +unshift(@ARGV, "hg");
    4.10 +exec(@ARGV);
     5.1 --- a/defaults/profile	Wed Jan 09 05:11:10 2013 +0000
     5.2 +++ b/defaults/profile	Wed Jan 09 07:09:37 2013 +0000
     5.3 @@ -28,6 +28,6 @@
     5.4  
     5.5  export HGEDITOR="emacs"
     5.6  
     5.7 -alias hg="~/.hg-wrapper"
     5.8 +alias hg="~/.hg-wrapper --config ui.username=`whoami`"
     5.9  
    5.10 -PS1="\[$(tput setaf 3)\][\u \w] # \[$(tput sgr0)\]"
    5.11 +PS1="\[$(tput setaf 3)\][\u \w] % \[$(tput sgr0)\]"
     6.1 --- a/org/pkg.org	Wed Jan 09 05:11:10 2013 +0000
     6.2 +++ b/org/pkg.org	Wed Jan 09 07:09:37 2013 +0000
     6.3 @@ -51,6 +51,13 @@
     6.4    > removed
     6.5    > <list of files>
     6.6   
     6.7 +the root-level mercurial repository is owned by
     6.8 +hg-commiter:hg-wheel, where hg-committer is the
     6.9 +user for which the "hg" alise for each package
    6.10 +user is setuid. 
    6.11  
    6.12 +high level users can be added to hg-heel to
    6.13 +administer the root-level mercurial repsitory,
    6.14 +which will allow them to do things like hg log, hg
    6.15 +purge, etc.
    6.16  
    6.17 -
     7.1 --- a/src/pkg.pl	Wed Jan 09 05:11:10 2013 +0000
     7.2 +++ b/src/pkg.pl	Wed Jan 09 07:09:37 2013 +0000
     7.3 @@ -74,16 +74,27 @@
     7.4  @pkg_add_install_cmd = 
     7.5    ("gpasswd", "--add", $pkg_name, "install");
     7.6  
     7.7 -sub execute{print "\t@_\n"; system(@_) and die $!;}
     7.8 -
     7.9 -
    7.10  @pkg_link_bashrc_cmd =
    7.11    ("install", "-g", $pkg_name, "-o", $pkg_name,
    7.12     "/pkg/defaults/.profile", "$pkg_home/.profile");
    7.13  
    7.14  @pkg_copy_hg_wrapper_cmd =
    7.15 -  (install, "-g", "users", "-o", "r",
    7.16 -   "-m", "4777", "/pkg/defaults/.hg-wrapper", $pkg_home);
    7.17 +  (install, "-g", "hg-wheel", "-o", "hg-committer",
    7.18 +   "-m", "6111", "/pkg/defaults/.hg-wrapper", $pkg_home);
    7.19 +
    7.20 +$pkg_hgrc = "[ui]\n\
    7.21 +username = $pkg_name\n\
    7.22 +[extensions]\n\
    7.23 +hgext.purge =\n";
    7.24 +
    7.25 +$pkg_hgrc_filename = "$pkg_home/.hgrc";
    7.26 +
    7.27 +@pkg_set_hgrc_user_cmd = 
    7.28 +  ("chown", "$pkg_name:$pkg_name", $pkg_hgrc_filename);
    7.29 +
    7.30 +
    7.31 +sub execute{print "\t@_\n"; system(@_) and die $!;}
    7.32 +
    7.33  
    7.34  #determine if the user already exists:
    7.35  `id $pkg_name 2>/dev/null`;
    7.36 @@ -107,13 +118,15 @@
    7.37  execute(@pkg_link_bashrc_cmd);
    7.38  execute(@pkg_copy_hg_wrapper_cmd);
    7.39  
    7.40 +# print "Create ~/.hgrc\n";
    7.41 +# open(HGRC, ">$pkg_hgrc_filename") or die $!;
    7.42 +# select HGRC;
    7.43 +# print $pkg_hgrc;
    7.44 +# close(HGRC);
    7.45 +
    7.46 +# select(STDOUT);
    7.47 +# print "Set permissions on ~/.hgrc.\n";
    7.48 +# execute(@pkg_set_hgrc_user_cmd);
    7.49 +
    7.50  print "Change user.\n";
    7.51  execute(@pkg_switch_cmd);
    7.52 -
    7.53 -
    7.54 -
    7.55 -
    7.56 -
    7.57 -
    7.58 -
    7.59 -
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/set-repository-perms.sh	Wed Jan 09 07:09:37 2013 +0000
     8.3 @@ -0,0 +1,5 @@
     8.4 +groupadd --force hg-wheel
     8.5 +gpasswd --add hg-committer hg-wheel
     8.6 +gpasswd --add r            hg-wheel
     8.7 +chown -Rv hg-committer:hg-wheel /.hg
     8.8 +chmod -Rv g+wrx /.hg