[Cvsman-commits] jlbec commits r30 - in trunk: . aix debian
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Apr 9 21:05:16 CDT 2004
Author: jlbec
Date: 2004-04-09 20:05:13 -0500 (Fri, 09 Apr 2004)
New Revision: 30
Modified:
trunk/ChangeLog
trunk/aix/
trunk/configure.in
trunk/cvsman.in
trunk/debian/changelog
Log:
0.11.0 - perms and parent dirs
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2003-08-28 18:02:16 UTC (rev 29)
+++ trunk/ChangeLog 2004-04-10 01:05:13 UTC (rev 30)
@@ -1,3 +1,10 @@
+2004-04-09 Joel Becker <joel.becker at oracle.com>
+
+ * configure.in: 0.11.0
+ * cvsman.in: Add parent directory creation and associated
+ .cvsperms work.
+
+
2003-05-09 Joel Becker <joel.becker at oracle.com>
* configure.in: Bump to 0.1.1
Property changes on: trunk/aix
___________________________________________________________________
Name: svn:ignore
+ calpg.cvsman.rte.inventory
calpg.cvsman.rte.size
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2003-08-28 18:02:16 UTC (rev 29)
+++ trunk/configure.in 2004-04-10 01:05:13 UTC (rev 30)
@@ -2,7 +2,7 @@
AC_INIT(cvsman.in)
-VERSION=0.10.1
+VERSION=0.11.0
AC_SUBST(VERSION)
Modified: trunk/cvsman.in
===================================================================
--- trunk/cvsman.in 2003-08-28 18:02:16 UTC (rev 29)
+++ trunk/cvsman.in 2004-04-10 01:05:13 UTC (rev 30)
@@ -70,6 +70,9 @@
And so on.
+Parent directories will be created where they do not exist. Use the
+.cvsperms mechanism to ensure permissions where needed.
+
A config file in the root collection directory called 'config'
maintains the configuration for the cvsman application itself. The
format is a simple <key>:<value> specification. The 'host' variable
@@ -216,18 +219,21 @@
# User and group can be uid or logname.
# Mode is in octal and do not require the leading 0.
#
-# Currently guaranteed that all files are regular files.
-#
sub load_perms
{
my $files = shift;
+ my $perms = {};
my $dirs = {};
-FL: foreach my $file (keys %{$files})
+ my @traverse = keys %{$files};
+
+FL: while (scalar(@traverse))
{
+ my $file = shift @traverse;
my $dname = dirname($file);
next FL if exists($dirs->{$dname});
+ unshift @traverse, $dname;
$dirs->{$dname} = 1;
next FL unless open PERMHANDLE, "root$dname/.cvsperms";
@@ -242,7 +248,7 @@
my $gid = ($tgroup =~ /^\d+$/) ?
$tgroup : getgrnam($tgroup);
my $mode = sprintf("0%s", $rmode);
- @{$files->{"$dname/$entry"}}{"uid","gid","mode"} =
+ @{$perms->{"$dname/$entry"}}{"uid", "gid", "mode"} =
($uid, $gid, $mode);
#
@@ -251,12 +257,14 @@
# as well. This includes files marked exclude.
# This allows a script in the repository to be
# 0700 but never installed anywhere. We force
- # at least 0600 so that cvsman can still read/write
- # the file.
+ # at least 0600 (0700 for directories) so that
+ # cvsman can still read/write the file.
#
- chown $uid, $gid, "root/$dname/$entry";
+ chown $uid, $gid, "root$dname/$entry";
my $old_umask = umask 0000;
- chmod((oct($mode) | 0600),
+ my $basemode = (-d "root$dname/$entry") ?
+ 0700 : 0600;
+ chmod((oct($mode) | $basemode),
"root/$dname/$entry");
umask $old_umask;
};
@@ -264,7 +272,7 @@
close PERMHANDLE;
}
- return 1;
+ return $perms;
} # load_perms()
@@ -528,14 +536,40 @@
#
-# $rc install_file($file, $uid, $gid, $mode, $verbose)
+# $rc install_file($file, $perms, $verbose)
#
# Installs the file, creating a backup. If the install fails, the
# backup will be recovered.
#
sub install_file
{
- my ($file, $uid, $gid, $mode, $verbose) = @_;
+ my ($file, $perms, $verbose) = @_;
+
+ my $permdir = dirname($file);
+ my @permtree;
+ while ($permdir ne "/")
+ {
+ # Yes, I could use split, but I prefer dirname to DTRT.
+ unshift @permtree, $permdir;
+ $permdir = dirname($permdir);
+ }
+
+PD: foreach my $permdir (@permtree)
+ {
+ next PD if -d $permdir;
+ if (-e $permdir)
+ {
+ printf STDERR "cvsman: Error: Path $permdir is not a directory!\n";
+ return 0;
+ }
+ my $rc = mkdir $permdir, 0755;
+ if (!$rc)
+ {
+ printf STDERR "cvsman: Error: Unable to create path $permdir: $!\n";
+ return 0;
+ }
+ }
+
if (-e "$file.cvsmansave")
{
if (-d "$file.cvsmansave")
@@ -585,13 +619,18 @@
return 0;
}
- if (defined($uid))
+ foreach my $permfile ($file, @permtree)
{
- chown $uid, $gid, $file;
+ my ($uid, $gid, $mode) =
+ @{$perms->{$permfile}}{"uid", "gid", "mode"};
+ if (defined($uid))
+ {
+ chown $uid, $gid, $permfile;
- my $old_umask = umask 0000;
- chmod oct($mode), $file;
- umask $old_umask;
+ my $old_umask = umask 0000;
+ chmod oct($mode), $permfile;
+ umask $old_umask;
+ }
}
if ($verbose)
@@ -635,7 +674,7 @@
my ($files, $cmds) = load_files($config);
(defined($files) && defined($cmds)) or exit(1);
-load_perms($files);
+my $perms = load_perms($files);
# Install files
foreach my $file (keys %{$files})
@@ -653,9 +692,7 @@
else
{
install_file($file,
- $files->{$file}{uid},
- $files->{$file}{gid},
- $files->{$file}{mode},
+ $perms,
$verbose);
}
}
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2003-08-28 18:02:16 UTC (rev 29)
+++ trunk/debian/changelog 2004-04-10 01:05:13 UTC (rev 30)
@@ -1,3 +1,10 @@
+cvsman (0.11.0-1) unstable; urgency=low
+
+ * Create parent directories for files
+ * Add parent directory searching for .cvsperms
+
+ -- Joel Becker <jlbec at evilplan.org> Fri, 09 Apr 2004 18:02:35 -0800
+
cvsman (0.9.0-1) unstable; urgency=low
* 'import' keyword
More information about the Cvsman-commits
mailing list