Subversion Repositories DevTools

Rev

Rev 4011 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4011 dpurdie 1
#! /usr/bin/perl
2
########################################################################
3
# Copyright (C) 1998-2013 Vix Technology, All rights reserved
4
#
5
# Module name   : faclscan.pl
6
# Module type   : Makefile system
7
# Compiler(s)   : Perl
8
# Environment(s):
9
#
10
# Description   : Scan dpkg_archive for users with special access
11
#
12
# Usage:
13
#
14
#......................................................................#
15
 
16
require 5.008_002;
17
use strict;
18
use warnings;
19
 
20
use Pod::Usage;
21
use Getopt::Long;
22
 
23
my $dpkg_archive;
24
my $dpkg_archive_len;
25
my $file;
26
my $owner;
27
my $group;
28
my @users;
29
my $user;
30
 
31
#
32
#   Find dpkg_archive
33
#
34
$dpkg_archive = $ENV{GBE_DPKG} || die ("EnvVar GBE_DPKG not defined\n");
35
$dpkg_archive =~ s~/+$~~;
36
$dpkg_archive_len = length ($dpkg_archive) + 1;
37
 
38
#
39
#   Ensure its a directory
40
#
41
die ("GBE_DPKG ($dpkg_archive) is not a directory\n") unless ( -d $dpkg_archive );
42
 
43
#
44
# Scan package archive
45
#
46
open (DIR ,"getfacl -p $dpkg_archive/* |") || die ("getfacl failed: $!\n");
47
while ( <DIR> )
48
{
49
    $_ =~ s~\s*$~~;
50
#print "$_\n";
51
    if ( m~^#\s+file:\s+(.*)~ ) {
52
        displayUsers();
53
        $file = substr($1, $dpkg_archive_len);
54
    }
55
    $owner = $1
56
        if ( m~^#\s+owner:\s+(.*)~ );
57
    $group = $1
58
        if ( m~^#\s+group:\s+(.*)~ );
59
     if ( m~^user:(.*?):(.*)~  ) {
60
        $user = $1;
7367 dpurdie 61
        if ( $user ne '' && $user ne 'pkgadm' ) {
4011 dpurdie 62
            push @users, $user;
63
        }
64
    }
65
}
66
close DIR;
67
displayUsers();
68
 
69
#-------------------------------------------------------------------------------
70
# Function        : Display a user entry if it is not as expected
71
#
72
# Description     : 
73
#
74
# Inputs          : 
75
#
76
# Returns         : 
77
#
78
 
79
sub displayUsers
80
{
81
    return unless ( defined $file );
82
    if ( @users ) {
83
        printf("%-30s:%s\n", $file , join(' ', sort @users));
84
    }
7367 dpurdie 85
    if ( $owner ne 'pkgadm' ) {
4011 dpurdie 86
        print "$file : OWNER: $owner\n";
87
    }
88
    if ( $group ne 'ccperdev' ) {
89
        print "$file : GROUP: $group\n";
90
    }
91
 
92
 
93
    $file = undef;
94
    $owner = undef;
95
    $group = undef;
96
    @users = ();
97
}
98