umask and CPAN installs

J

JVarsoke

The root account on my system has a very strict umask for security
reasons. Normally when I install programs this is not a problem. But
when I use perl -MCPAN to install modules they are always installed
with the umask, and thus nobody can use them except root. Is there a
way to tell CPAN to open the permissions on modules at installation
time? Otherwise I need to hunt around for all the files (.pm and .so)
and chmod 644 them -- which is error prone and annoying.

Any suggestions?

-jason
 
J

James Willmore

The root account on my system has a very strict umask for security
reasons. Normally when I install programs this is not a problem. But
when I use perl -MCPAN to install modules they are always installed
with the umask, and thus nobody can use them except root. Is there a
way to tell CPAN to open the permissions on modules at installation
time? Otherwise I need to hunt around for all the files (.pm and .so)
and chmod 644 them -- which is error prone and annoying.

Any suggestions?

I'm not sure this will work, but I'll toss it out there and see if anyone
says yea or nay :)

You could fashion a script to set your umask to something less
restrictive, run the CPAN shell, then unset the umask.

So, you could have ....

#!/bin/bash
unmask 0022
perl -MCPAN -e 'shell'
unset umask

My thinking is this ...
since you start another invocation of a shell (I use bash, but it could
be any), you can (un)set the umask as needed and it will be available
*only* for that invocation of the shell. The one issue I see right off
is if the CPAN shell will inherit the umask you set in this new
invocation or start yet another invocation of the shell, getting the
unask from somewhere like your .bashrc or .profile of somewhere else. If
it does, you're in business. If not, then you'll need another way.

Another option is to use 'look' instead of 'install'. Here, you start
another invocation of your shell within the CPAN shell. Set your umask.
Then do your install (perl Makefile.PL, make, make test, make install ).
This defeats the whole idea of using the shell, but I'm pretty certain it
will work.

Yet another option is to fashion your own install script using the CPAN
module (`perldoc CPAN` for more info). This isn't as nice as using the
CPAN shell, but would solve the issue, maybe. I'm not 100% sure how you
would set the umask in this way that would stick. Using 'system' won't
work, AFAIK, and I'm not sure if setting it with the %ENV hash
($ENV{'umask'}) will work; although it's worth a shot.

Others may have other options.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
You can learn many things from children. How much patience you
<have, for instance. -- Franklin P. Jones
 
T

Todd de Gruyl

JVarsoke said:
The root account on my system has a very strict umask for security
reasons. Normally when I install programs this is not a problem. But
when I use perl -MCPAN to install modules they are always installed
with the umask, and thus nobody can use them except root. Is there a
way to tell CPAN to open the permissions on modules at installation
time? Otherwise I need to hunt around for all the files (.pm and .so)
and chmod 644 them -- which is error prone and annoying.

Any suggestions?

This is not really a perl answer, since I don't know if there is a way
to do this in CPAN. My answer is also dependant upon what shell you
use, but you should be able to use the umask command (after you su or
login to root) before beginning your install.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top