Mercurial > pkg
changeset 7:ab4011ea1463
using C wrapper instead of perl wrapper.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 08 Jan 2013 18:10:15 +0000 |
parents | 941970bc92e3 |
children | 7b9d471fc1d3 |
files | defaults/bashrc defaults/create-skeleton.sh defaults/hg-wrapper.pl defaults/suid-wrapper.c src/pkg.pl |
diffstat | 5 files changed, 46 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/defaults/bashrc Tue Jan 08 16:03:31 2013 +0000 1.2 +++ b/defaults/bashrc Tue Jan 08 18:10:15 2013 +0000 1.3 @@ -29,3 +29,5 @@ 1.4 export HGEDITOR="emacs" 1.5 1.6 alias hg="~/.hg-wrapper" 1.7 + 1.8 +PS1="\[$(tput setaf 3)\][\u \w] # \[$(tput sgr0)\]"
2.1 --- a/defaults/create-skeleton.sh Tue Jan 08 16:03:31 2013 +0000 2.2 +++ b/defaults/create-skeleton.sh Tue Jan 08 18:10:15 2013 +0000 2.3 @@ -1,4 +1,4 @@ 2.4 mkdir -pv /pkg/defaults 2.5 -ln -sfv ./bashrc /pkg/defaults/.bashrc 2.6 -ln -sfv ./hg-wrapper.pl /pkg/defaults/.hg-wrapper 2.7 +ln -sfv $(pwd)/bashrc /pkg/defaults/.bashrc 2.8 +ln -sfv $(pwd)/hg-wrapper.pl /pkg/defaults/.hg-wrapper 2.9
3.1 --- a/defaults/hg-wrapper.pl Tue Jan 08 16:03:31 2013 +0000 3.2 +++ b/defaults/hg-wrapper.pl Tue Jan 08 18:10:15 2013 +0000 3.3 @@ -1,3 +1,9 @@ 3.4 -!#/usr/bin/env perl 3.5 +#!/usr/bin/perl -wT 3.6 3.7 -system("hg", @_); 3.8 +$ENV{"PATH"} = "/usr/bin"; 3.9 +delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)}; 3.10 + 3.11 +exec("whoami"); 3.12 + 3.13 +#unshift(@ARGV, "hg"); 3.14 +#exec(@ARGV);
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/defaults/suid-wrapper.c Tue Jan 08 18:10:15 2013 +0000 4.3 @@ -0,0 +1,12 @@ 4.4 +#include <unistd.h> 4.5 +#include <errno.h> 4.6 + 4.7 +main( int argc, char ** argv, char ** envp ) 4.8 +{ 4.9 + if( setgid(getegid()) ) perror( "setgid" ); 4.10 + if( setuid(geteuid()) ) perror( "setuid" ); 4.11 + envp = 0; /* blocks IFS attack on non-bash shells */ 4.12 + system( "/usr/bin/hg", argv, envp ); 4.13 + perror( argv[0] ); 4.14 + return errno; 4.15 +}
5.1 --- a/src/pkg.pl Tue Jan 08 16:03:31 2013 +0000 5.2 +++ b/src/pkg.pl Tue Jan 08 18:10:15 2013 +0000 5.3 @@ -68,10 +68,23 @@ 5.4 ("groupadd", "--force", $pkg_name); 5.5 5.6 @pkg_create_home_cmd = 5.7 - ("install", "-d", "-g", $pkg_name, "-o", $pkg_name, "-m", "700", $pkg_home); 5.8 + ("install", "-d", "-g", $pkg_name, "-o", $pkg_name, 5.9 + "-m", "700", $pkg_home); 5.10 + 5.11 +@pkg_add_install_cmd = 5.12 + ("gpasswd", "--add", $pkg_name, "install"); 5.13 5.14 sub execute{print "\t@_\n"; system(@_) and die $!;} 5.15 5.16 + 5.17 +@pkg_link_bashrc_cmd = 5.18 + ("install", "-g", $pkg_name, "-o", $pkg_name, 5.19 + "/pkg/defaults/.bashrc", "$pkg_home/.profile"); 5.20 + 5.21 +@pkg_copy_hg_wrapper_cmd = 5.22 + (install, "-g", "root", "-o", "root", 5.23 + "-m", "4777", "/pkg/defaults/.hg-wrapper", $pkg_home); 5.24 + 5.25 #determine if the user already exists: 5.26 `id $pkg_name 2>/dev/null`; 5.27 if (!$?){ 5.28 @@ -87,6 +100,13 @@ 5.29 print "Create home directory for $pkg_name.\n"; 5.30 execute(@pkg_create_home_cmd); 5.31 5.32 +print "Add $pkg_name to install group.\n"; 5.33 +execute(@pkg_add_install_cmd); 5.34 + 5.35 +print "Copy Default Files.\n"; 5.36 +execute(@pkg_link_bashrc_cmd); 5.37 +execute(@pkg_copy_hg_wrapper_cmd); 5.38 + 5.39 print "Change user.\n"; 5.40 execute(@pkg_switch_cmd); 5.41 5.42 @@ -96,3 +116,4 @@ 5.43 5.44 5.45 5.46 +