3

I've written a shell script that does stuff on Centos64

At the end of this script, I run a perl script.

It works fine as root (I have installed the perl modules), but when I run it as a system user

I get the message:

./UserActivityReport.sh Can't locate MIME/Lite.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /optreports/sendmailUAR.pl line 3. BEGIN failed--compilation aborted at /opt/reports/sendmailUAR.pl line 3.

As if the modules were not installed for the user...

I run the script with this command in my shell script:

/usr/bin/perl  /opt/reports/sendmailUAR.pl

Why is it not running?

NOTE: I cannot install the perl modules with the system user.

=== There you go:

perl -MMIME::Lite -MData::Dumper -e'print Dumper \%INC'
$VAR1 = {
          're.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/re.pm',
          'warnings/register.pm' => '/usr/lib/perl5/5.8.8/warnings/register.pm',
          'XSLoader.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/XSLoader.pm',
          'IO/Handle.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/IO/Handle.pm',
          'MIME/Types.pm' => '/usr/lib/perl5/site_perl/5.8.8/MIME/Types.pm',
          'SelectSaver.pm' => '/usr/lib/perl5/5.8.8/SelectSaver.pm',
          'IO/Seekable.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/IO/Seekable.pm',
          'warnings.pm' => '/usr/lib/perl5/5.8.8/warnings.pm',
          'File/Basename.pm' => '/usr/lib/perl5/5.8.8/File/Basename.pm',
          'Fcntl.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Fcntl.pm',
          'IO.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/IO.pm',
          'Symbol.pm' => '/usr/lib/perl5/5.8.8/Symbol.pm',
          'bytes.pm' => '/usr/lib/perl5/5.8.8/bytes.pm',
          'MIME/Type.pm' => '/usr/lib/perl5/site_perl/5.8.8/MIME/Type.pm',
          'Carp.pm' => '/usr/lib/perl5/5.8.8/Carp.pm',
          'MIME/Base64.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/MIME/Base64.pm',
          'Exporter/Heavy.pm' => '/usr/lib/perl5/5.8.8/Exporter/Heavy.pm',
          'File/Spec/Unix.pm' => '/usr/lib/perl5/5.8.8/File/Spec/Unix.pm',
          'FileHandle.pm' => '/usr/lib/perl5/5.8.8/FileHandle.pm',
          'strict.pm' => '/usr/lib/perl5/5.8.8/strict.pm',
          'Exporter.pm' => '/usr/lib/perl5/5.8.8/Exporter.pm',
          'vars.pm' => '/usr/lib/perl5/5.8.8/vars.pm',
          'MIME/Lite.pm' => '/usr/lib/perl5/site_perl/5.8.8/MIME/Lite.pm',
          'MIME/QuotedPrint.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/MIME/QuotedPrint.pm',
          'File/Spec.pm' => '/usr/lib/perl5/5.8.8/File/Spec.pm',
          'overload.pm' => '/usr/lib/perl5/5.8.8/overload.pm',
          'IO/File.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/IO/File.pm',
          'Mail/Address.pm' => '/usr/lib/perl5/site_perl/5.8.8/Mail/Address.pm',
          'Data/Dumper.pm' => '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Data/Dumper.pm'

};

9
  • run as root perl -MMIME::Lite -MData::Dumper -e'print Dumper \%INC' and post here the output. Commented Sep 15, 2011 at 11:16
  • The system user's @INC doesn't seem to have /usr/lib/perl5/site_perl/5.8.8/ in it. Take a look at: stackoverflow.com/questions/2526804/… Commented Sep 15, 2011 at 11:36
  • The file is there alright ... What are its permissions? Commented Sep 15, 2011 at 11:40
  • @Lin how so? It's included in \@INC according to the error message. Commented Sep 15, 2011 at 11:41
  • [root~]# ls -l /usr/lib/perl5/site_perl/5.8.8/ total 60 drwxr-x--- 3 root root 4096 Sep 14 13:09 Date drwxr-x--- 3 root root 4096 Sep 14 13:09 Email drwxr-x--- 4 root root 4096 Sep 14 13:10 Mail drwxr-x--- 2 root root 4096 Sep 14 13:10 MIME drwxr-x--- 2 root root 4096 Sep 15 06:30 OLE drwxr-x--- 2 root root 4096 Sep 15 06:30 Parse drwxr-x--- 2 root root 4096 Sep 14 13:10 Pod drwxr-x--- 3 root root 4096 Sep 15 06:30 Spreadsheet drwxr-x--- 2 root root 4096 Sep 14 13:09 Time -r--r--r-- 1 root root 6500 Aug 21 07:19 version.pm -r--r--r-- 1 root root 9887 Aug 21 07:12 version.pod Commented Sep 15, 2011 at 11:44

3 Answers 3

2

In one of the comments, you have posted a directory listing like this:

[root~]# ls -l /usr/lib/perl5/site_perl/5.8.8/
total 60
drwxr-x--- 3 root root 4096 Sep 14 13:09 Date
drwxr-x--- 3 root root 4096 Sep 14 13:09 Email
drwxr-x--- 4 root root 4096 Sep 14 13:10 Mail
drwxr-x--- 2 root root 4096 Sep 14 13:10 MIME
drwxr-x--- 2 root root 4096 Sep 15 06:30 OLE
drwxr-x--- 2 root root 4096 Sep 15 06:30 Parse
drwxr-x--- 2 root root 4096 Sep 14 13:10 Pod
drwxr-x--- 3 root root 4096 Sep 15 06:30 Spreadsheet
drwxr-x--- 2 root root 4096 Sep 14 13:09 Time
-r--r--r-- 1 root root 6500 Aug 21 07:19 version.pm
-r--r--r-- 1 root root 9887 Aug 21 07:12 version.pod

It should be fairly evident that users other than root do not have access to these files. You should probably do more thorough audit by looping over all of @INC and changing permissions as necessary, but for a start, find /usr/lib/perl5/site_perl/5.8.8 -type d -exec chmod a+rx {} \;

Sign up to request clarification or add additional context in comments.

Comments

1

I'm betting root's umask is such that files are not world readable by default.

find /usr/lib/perl5 -not -perm -o=r 

Anything files listed are not world readable (and probably should be). You can fix it this way

find /usr/lib/perl5 -not -perm -o=r -exec chmod o+r {} +

If you wish to make all files matched with the first command readable by everyone.

Comments

1

MIME::Lite is at /usr/lib/perl5/site_perl/5.8.8/MIME/Lite.pm and /usr/lib/perl5/site_perl/5.8.8 is in system's @INC path.

As user system check that you can read that file:

cat /usr/lib/perl5/site_perl/5.8.8/MIME/Lite.pm

If you get an error doing so check the permissions of the file and the parent directories.

Otherwise, run the script as system with strace and see why it is failing to find the module file.

1 Comment

Alright so I did a chmod 755 on /usr/lib/perl5/site_perl/5.8.8 and it solved the issue :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.