#!/usr/bin/env perl # # user-or-group-in-package-scripts # # $Id$ # lists which of the given users or groups # appear to be manipulated by scripts of which installed RPMs # quick and dirty use strict; use warnings; my @users = @ARGV; sub chomped { map { s/[\r\n]*$//; $_ } @_; } my @installed_packages = chomped(`rpm -qa`); foreach my $pkg (@installed_packages) { #my @scripts = chomped(`rpm -q --scripts $pkg`); # need to join continuation lines my $scripts = `rpm -q --scripts $pkg`; $scripts =~ s#\s*\\$/\s*# #g; my @scripts = split( $/, $scripts ); foreach my $user (@users) { foreach my $line (@scripts) { if ( my ($cmd) = $line =~ /\b((user|group)\w*)\b.*\s$user\b/ ) { $line =~ s/^\s*//; $line =~ s/\s*$//; print "$user,$pkg,$cmd,$line\n"; } } } }