Is it possible to redirect the use of the .local directory to cpan?

I have a setuid program that then calls cpan as root as a user. This works for commands like yum, but doesn't work for cpan. My problem is that users home directories are NFS mounted shares and use the root-squash option, so root has no access to the user's home directory.

Cpan is trying to create a .local directory in the user's home home which fails due to root squash.

Is there a way to set up cpan so that it uses a different path as the basis for building the package? Or, is there a way to configure root as a userid of the entry so that cpan will try to create a .local file there?

Output example:

./cloudSoftware cpan foobar mkdir / home / auto / ts00086 / .local: permission denied on / usr / share / perl 5 / CPAN / HandleConfig.pm line 589.

+3


source to share


1 answer


cpan_home_dir_candidates

generates a directory listing.

  • The first directory in the list containing the CPAN/MyConfig.pm

    .
  • Otherwise, the first directory in the list that exists is used.
  • Otherwise, the first directory in the list is used.

So how is the list created?



if ($CPAN::META->has_usable('File::HomeDir')) {
    if ($^O ne 'darwin') {
        push @dirs, File::HomeDir->my_data;
        # my_data is ~/Library/Application Support on darwin,
        # which causes issues in the toolchain.
    }
    push @dirs, File::HomeDir->my_home;
}
# Windows might not have HOME, so check it first
push @dirs, $ENV{HOME} if $ENV{HOME};
...

      

Options include:

  • Change HOME

    env var (if file :: HomeDir is not installed).
  • Editing cpan_home_dir_candidates

    in CPAN/HandleConfig.pm

    to addpush @dirs, "/alt/dir";

  • ...
+3


source







All Articles