info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Limiting access to certain files within the repository.


From: JacobRhoden
Subject: Re: Limiting access to certain files within the repository.
Date: Tue, 23 Sep 2003 10:50:29 +1000
User-agent: KMail/1.5

On Tue, 23 Sep 2003 07:16 am, Larry Jones wrote:
> Larry Lords writes:
> > In order to refactor the build we need to limit the access to the
> > build.xml file to a limited group.  I have looked through the
> > documentation, but still not sure what to do to limit the access?
>
> CVS cannot limit access to a single file, only to a directory.
>

Access to read it, or access to commit it? If you mean to commit, if you are 
willing to write a perl script you can (: I limit on a repository basis, but 
the following code could easily be modified to do such a thing. You would 
need to add something like if($repository eq x and $f eq  "build.xml") in the 
very last loop of the following script:

#!/usr/local/bin/perl
# $Id$ 
#
# Program: commitcheck.pl
#  Author: Jacob Rhoden
#   Email: address@hidden
#
# This script validates a file before checking. It does the following:
#  - Check you are allowed to commit to a project
#  - Check perl scripts compile properly (removed)
#
# Place this file in the CVSROOT directory as 'commitcheck.pl'.  To make it
# work, you need to add to the CVSROOT/commitinfo file something like:
#
#      ALL      $CVSROOT/CVSROOT/commitcheck.pl
#

  $origrepository = shift(@ARGV);
  @files = @ARGV;

  # Wori out the the repositiory directory
  $envcvsroot = $ENV{'CVSROOT'};
  open(REPO, "<CVS/Repository");
  $repository = <REPO>;
  chop($repository);
  close(REPO);
  $repository =~ s:^$envcvsroot/::;
  $project=$repository; $project=~s/^(.*?)\/.*/$1/;

  # Iterate over the body of the message collecting information.
  #

  $| = 1;

  print STDERR "\nCommit Check Validation 1.0\n";
  print STDERR "         files: @files\n";
  print STDERR "     dest path: $origrepository\n";
  print STDERR "    repository: $repository\n";
  print STDERR "       project: $project\n\n";

  # Work out the username
  if($username eq "") {
    $username = $ENV{"CVS_USER"} || getlogin || (getpwuid($<))[0] || "nobody";
    }

  # Check the user is allowed to checkin to this repository
  $ok = 0;
  # We should have a better method of adding
  # users than insertin if statments. Perhaps
  # a list/group file
  if($username eq "jrhoden") { $ok=1; }
  if($username eq "fawzi") { $ok=1; }
  if($username eq "melissa") { $ok=1; }
  if (!$ok) {
    print STDERR "Permission Denied\n";
    print STDERR "  $username is not allowed access to $project\n";
    print STDERR "  If you think you should be allowed to, send mail to\n";
    print STDERR "  address@hidden";
    exit 1;
    }

  # Do various file type speciffic checks
  foreach $f (@files) {
    }
exit 0;

_______________________________-
http://rhoden.id.au/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]