Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Aug 2001 23:02:24 -0600 (CST)
From:      Ryan Thompson <ryan@sasknow.com>
To:        01031149@3web.net
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Perl and permissions
Message-ID:  <Pine.BSF.4.21.0108182231480.64739-100000@ren.sasknow.com>
In-Reply-To: <20010818222127.A823751@mandy.rockingd.calgary.ab.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
01031149@3web.net wrote to Ryan Thompson:

> On Sat, Aug 18, 2001 at 06:31:29PM -0600, Ryan Thompson wrote:
> > Duke Normandin wrote to Freebsd Questions:
> > 
> > > I'm trying to get a Perl script (mbx2mbox.pl) running w/o choking. The
> > > script inhales 'Manip.pm' which in turn is suppose to read
> > > '~/.GlobalManip.cnf' if the full path was given in the appropriate
> > > variable in 'Manip.pm'. I can't get 'Manip.pm' to read that sucking
> > > '~/.GlobalManip.cnf' file --- perms maybe? Should config-type files such
> > > as the one mentioned have the same perms as the Perl module? Tia...
> > > 
> > 
> > In general, those files need to be readable by the user the script is
> > running as. If you are actually executing them (normally not the case),
> > they have to have the execute bit set as well, even for root. Also, the
> > same user needs read/search access to all of the directories along the
> > path. First, confirm that, as that user, you can read the file.  
> > (cat ~/.GlobalManip.cnf is a good indicator). You should verify the
> > permissions, but maybe that's not the culprit in this case:
> 
> Ryan....

Hey Duke,


> Do these perms look half-way OK?

I got a perm once, and it looked far from half-way OK... 
But that was a long time ago.


> mbx2mbox.pl 'use's Date::Manip
> Manip.pm contains a configurable var that points to .GlobalManip.cnf
> 
> The Manip.pm man pages say that it's OK to use '~'in the path to the
> above cnf file.

Either Manip.pm does its own globbing, or they take advantage of a feature
that I am not aware of. Have you tried fully qualifying the path to this
file? Does that help?

Consider this simple example:

Script started on Sat Aug 18 22:34:43 2001
ryan@ren $ cat test1.pl
#!/usr/bin/perl
require "~/readme.pl";
print "$TZ\n";

ryan@ren $ cat test2.pl
#!/usr/bin/perl
require sprintf "%s/readme.pl", $ENV{"HOME"};
print "$TZ\n";

ryan@ren $ cat /home/ryan/readme.pl
#!/usr/bin/perl
$TZ="CST -0600";

ryan@ren $ ./test1.pl
Can't locate ~/readme.pl in @INC (@INC contains: /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 .) at ./test1.pl line 3.
ryan@ren $ ./test2.pl
CST -0600
ryan@ren $ ^D
Script done on Sat Aug 18 22:35:05 2001

That's the default behaviour of perl 5.005_03 in this case. 
Does what you see match?

It is possible that Date::Manip actually simulates tilde expansion for
their own purposes. In that case, it may very well work, but it is
important to note that it will probably NOT be sharing the same tilde
expansion routines as modern shells, and, as such, may not expand to the
same directory.


> -rwxr-xr-x  1 dnormandin  dnormandin  4848 Aug 17 18:03 test/mbx2mbox.pl
> -rw-r--r--  1 root  wheel  3700 Aug 18 14:12 .GlobalManip.cnf

.GlobalManip.cnf is world readable in this case. What are the permissions 
on your home directory?


> odie[v0]:dnormandin@/root# ls -al /usr/libdata/perl/5.00503/Date
> total 435
> drwxr-xr-x   2 root  wheel     512 Aug 18 14:15 .
> drwxr-xr-x  28 root  wheel    2048 Aug 17 18:28 ..
> -r-xr-xr-x   1 root  wheel  209025 Aug 18 14:15 Manip.pm
> odie[v0]:dnormandin@/root#
> 
> My "real" problem is that Manip.pm needs to get a value for TZ. If set
> (which mine isn't for some reason) it will read $TZ; or get TZ from
> GlobalManip.cnf. If I manually set $TZ (as root), mbx2mbox.pl executes
>  no problem. If $TZ is not set, mbx2mbox.pl never get done, cuz manip.pm
> chokes. So I'm figuring that Manip.pm never sees the .cnf file, cuz TZ _is_
> set in there. Any ideas? Tia...

Well, without knowing a little bit more about the files in question, or if
you have received any useful error messages from the Perl output, I would
say the thing to do is put some debug statements in this cnf file... A big
warn() banner at the entry point saying ".GlobalManip.cnf was called!!"

Then, check your output. If the line does not print to standard error,
then the .cnf was not read. Keep backtracking. Go to Manip.pm. Make a
backup. Even though you didn't write it, and you should rightly think of
it as a black box, analyse the code a bit. Where does the .cnf get
included? Can you wrap some debug statements around it to output the name
of the file AFTER any expansions take place (in other words, what is
actually trying to be opened?) Make it barf in a way that is useful to
your debugging requirements? Keep going up the call chain until you find
the problem, or start from the bottom of the stack and work your way up
until it breaks. Just restore your backup when you're done mucking around!

There are a few too many unknowns here for me to tell you exactly what's
going wrong. If you're sure about the tilde expansion issue, and the files
are readable by whoever is running the Perl interpreter (looks OK, unless
access is denied to directories in the search path), then your error is
elsewhere. This might also be a known thing with Date::Manip.pm, in which
case you should review any documentation thoroughly.

You may also just decide to work around the problem by using a global
configuration file instead of the user one.

Debugging is sometimes a frustrating process, and it's not something
someone can easily tell you how to do, as I'm sure you know. ;-) If you
need a greater degree of help than I've been able to give you, here, then
you probably need to have someone like me look over the code in question
and offer advice/diffs.

- Ryan

-- 
  Ryan Thompson <ryan@sasknow.com>
  Network Administrator, Accounts

  SaskNow Technologies - http://www.sasknow.com
  #106-380 3120 8th St E - Saskatoon, SK - S7H 0W2

        Tel: 306-664-3600   Fax: 306-664-1161   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0108182231480.64739-100000>