Skip to content
Permalink
0708053cdf
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 56 lines (50 sloc) 1.03 KB
#! /usr/bin/perl
use strict;
sub scandir {
my ($dirname)=@_;
opendir my $dir,$dirname or die "$dirname: $!\n";
return sort grep !/^\./,readdir $dir;
}
my $sts=0;
my @DIRS=scandir('/project/FlowCytometryLab/');
for my $name (sort @DIRS) {
$name eq 'home' and next;
my $d="/project/FlowCytometryLab/$name";
lstat $d or die "$d: $!\n";
-d _ or next;
if (my $uid=getpwnam($name)) {
my @f1=lstat _;
unless (chdir($d)) {
warn "$d: $!\n";
$sts=1;
next;
}
my @f2=lstat '.';
unless ($f1[0] == $f2[0] && $f1[1]==$f2[1]) {
warn "$d: won't work on replaced directory\n";
$sts=1;
next;
}
system 'find','.',
'-type','d',
'-not','-user',$uid,
'-ls',
'-exec','chown',$uid,'{}',';',
and $sts=1;
system 'find','.',
'-type','f',
'-links','1',
'-not','-user',$uid,
'-ls',
'-exec','chown',$uid,'{}',';',
and $sts=1;
if ( ($f2[2] & 07777) != 02770) {
system 'chmod','02770','.' and $sts=1;
}
} else {
getpwnam("O$name") and next;
warn "$name: no such user\n";
$sts=1;
}
}
exit $sts;