changeset 8:7b9d471fc1d3

create C wrapper and move bashrc to profile.
author Robert McIntyre <rlm@mit.edu>
date Tue, 08 Jan 2013 18:13:48 +0000
parents ab4011ea1463
children a0c0ccd22ca5
files defaults/Makefile defaults/bashrc defaults/create-skeleton.sh defaults/hg-wrapper defaults/hg-wrapper.c defaults/hg-wrapper.pl defaults/profile defaults/suid-wrapper.c src/pkg.pl
diffstat 9 files changed, 52 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/defaults/Makefile	Tue Jan 08 18:13:48 2013 +0000
     1.3 @@ -0,0 +1,2 @@
     1.4 +all:
     1.5 +	gcc hg-wrapper.c -o hg-wrapper
     2.1 --- a/defaults/bashrc	Tue Jan 08 18:10:15 2013 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,33 +0,0 @@
     2.4 -#!/bin/bash
     2.5 -set +h
     2.6 -
     2.7 -export PATH=\
     2.8 -"/home/r/system/usr/bin:\
     2.9 -/sbin/:\
    2.10 -/bin:\
    2.11 -/usr/sbin:\
    2.12 -/usr/bin:\
    2.13 -/tools/bin"
    2.14 -
    2.15 -alias ls="/usr/bin/env ls --color=auto "
    2.16 -export ls
    2.17 -alias la="ls -la"
    2.18 -export la
    2.19 -
    2.20 -# some personal shortcuts
    2.21 -alias r="reset"
    2.22 -export r
    2.23 -alias sl=ls
    2.24 -export sl
    2.25 -alias l=ls
    2.26 -export l
    2.27 -
    2.28 -colors="/etc/dircolors"
    2.29 -eval $(dircolors -b $colors)
    2.30 -unset colors
    2.31 -
    2.32 -export HGEDITOR="emacs"
    2.33 -
    2.34 -alias hg="~/.hg-wrapper"
    2.35 -
    2.36 -PS1="\[$(tput setaf 3)\][\u \w] # \[$(tput sgr0)\]"
     3.1 --- a/defaults/create-skeleton.sh	Tue Jan 08 18:10:15 2013 +0000
     3.2 +++ b/defaults/create-skeleton.sh	Tue Jan 08 18:13:48 2013 +0000
     3.3 @@ -1,4 +1,4 @@
     3.4  mkdir -pv /pkg/defaults
     3.5 -ln -sfv $(pwd)/bashrc /pkg/defaults/.bashrc
     3.6 -ln -sfv $(pwd)/hg-wrapper.pl /pkg/defaults/.hg-wrapper
     3.7 +ln -sfv $(pwd)ls/profile /pkg/defaults/.profile
     3.8 +ln -sfv $(pwd)/hg-wrapper /pkg/defaults/.hg-wrapper
     3.9  
     4.1 Binary file defaults/hg-wrapper has changed
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/defaults/hg-wrapper.c	Tue Jan 08 18:13:48 2013 +0000
     5.3 @@ -0,0 +1,12 @@
     5.4 +#include <unistd.h>
     5.5 +#include <errno.h>
     5.6 +
     5.7 +main( int argc, char ** argv, char ** envp )
     5.8 +{
     5.9 +              if( setgid(getegid()) ) perror( "setgid" );
    5.10 +              if( setuid(geteuid()) ) perror( "setuid" );
    5.11 +              envp = 0; /* blocks IFS attack on non-bash shells */
    5.12 +              system( "/usr/bin/hg", argv, envp );
    5.13 +              perror( argv[0] );
    5.14 +              return errno;
    5.15 +}
     6.1 --- a/defaults/hg-wrapper.pl	Tue Jan 08 18:10:15 2013 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,9 +0,0 @@
     6.4 -#!/usr/bin/perl -wT
     6.5 -
     6.6 -$ENV{"PATH"} = "/usr/bin";
     6.7 -delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)};
     6.8 -
     6.9 -exec("whoami");
    6.10 -
    6.11 -#unshift(@ARGV, "hg");
    6.12 -#exec(@ARGV);
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/defaults/profile	Tue Jan 08 18:13:48 2013 +0000
     7.3 @@ -0,0 +1,33 @@
     7.4 +#!/bin/bash
     7.5 +set +h
     7.6 +
     7.7 +export PATH=\
     7.8 +"/home/r/system/usr/bin:\
     7.9 +/sbin/:\
    7.10 +/bin:\
    7.11 +/usr/sbin:\
    7.12 +/usr/bin:\
    7.13 +/tools/bin"
    7.14 +
    7.15 +alias ls="/usr/bin/env ls --color=auto "
    7.16 +export ls
    7.17 +alias la="ls -la"
    7.18 +export la
    7.19 +
    7.20 +# some personal shortcuts
    7.21 +alias r="reset"
    7.22 +export r
    7.23 +alias sl=ls
    7.24 +export sl
    7.25 +alias l=ls
    7.26 +export l
    7.27 +
    7.28 +colors="/etc/dircolors"
    7.29 +eval $(dircolors -b $colors)
    7.30 +unset colors
    7.31 +
    7.32 +export HGEDITOR="emacs"
    7.33 +
    7.34 +alias hg="~/.hg-wrapper"
    7.35 +
    7.36 +PS1="\[$(tput setaf 3)\][\u \w] # \[$(tput sgr0)\]"
     8.1 --- a/defaults/suid-wrapper.c	Tue Jan 08 18:10:15 2013 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,12 +0,0 @@
     8.4 -#include <unistd.h>
     8.5 -#include <errno.h>
     8.6 -
     8.7 -main( int argc, char ** argv, char ** envp )
     8.8 -{
     8.9 -              if( setgid(getegid()) ) perror( "setgid" );
    8.10 -              if( setuid(geteuid()) ) perror( "setuid" );
    8.11 -              envp = 0; /* blocks IFS attack on non-bash shells */
    8.12 -              system( "/usr/bin/hg", argv, envp );
    8.13 -              perror( argv[0] );
    8.14 -              return errno;
    8.15 -}
     9.1 --- a/src/pkg.pl	Tue Jan 08 18:10:15 2013 +0000
     9.2 +++ b/src/pkg.pl	Tue Jan 08 18:13:48 2013 +0000
     9.3 @@ -79,11 +79,11 @@
     9.4  
     9.5  @pkg_link_bashrc_cmd =
     9.6    ("install", "-g", $pkg_name, "-o", $pkg_name,
     9.7 -   "/pkg/defaults/.bashrc", "$pkg_home/.profile");
     9.8 +   "/pkg/defaults/.profile", "$pkg_home/.profile");
     9.9  
    9.10  @pkg_copy_hg_wrapper_cmd =
    9.11 -  (install, "-g", "root", "-o", "root",
    9.12 -   "-m", "4777", "/pkg/defaults/.hg-wrapper", $pkg_home);
    9.13 +  (install, "-g", "hg-commit", "-o", "hg-commit",
    9.14 +   "-m", "4711", "/pkg/defaults/.hg-wrapper", $pkg_home);
    9.15  
    9.16  #determine if the user already exists:
    9.17  `id $pkg_name 2>/dev/null`;