MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //scripts.20110531.215904.25158/fixinterchangeperm
#!/usr/bin/perl
# cpanel - fixinterchangeperm                     Copyright(c) 2010 cPanel, Inc.
#                                                           All Rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

BEGIN { unshift @INC, '/usr/local/cpanel'; }

use Cpanel::AccessIds  ();
use Cpanel::SafetyBits ();

Cpanel::SafetyBits::set_hide_warnings(1); # Don't throw warnings

my $user = $ARGV[0];
if ( !$user ) {
    print "What user should I fix interchange permissions for? ";
    chomp( $user = <STDIN> );
}

if ( !$user || !getpwnam($user) ) {
    die "No such user\n";
}

my $homedir = ( getpwnam($user) )[7];

if ( !-e $homedir . '/catalogs' ) {
    print "Interchange is not installed for this account.\n";
    exit 1;
}

if ( -l $homedir . '/public_html/cgi-bin/cart.cgi' ) {
    die "cart.cgi is a symlink!!";
}
elsif ( !-f _ ) {
    die "cart.cgi is not a normal file";
}

Cpanel::SafetyBits::safe_userrecchown( $user, 'cpanel', $homedir . '/catalogs' );    #safe

my @catalog_chmod_files = qw(
  products.txt
  area.txt
  cat.txt
  merchandising.txt
  options.txt
  pricing.txt
  inventory.txt
  affiliate.txt
  orderline.txt
  transactions.txt
  userdb.txt
  variants.txt
);

if ( my $pid = fork() ) {
    waitpid( $pid, 0 );
}
else {
    Cpanel::AccessIds::setuids( $user, 'cpanel' );
    my $uid = ( getpwnam($login) )[2];
    my $gid = ( getpwnam('cpanel') )[3];

    for my $dir (qw(products session backup logs orders upload etc)) {
        next if !-e $homedir . '/catalogs/' . $user . '/' . $dir;
        chmod 02770, $homedir . '/catalogs/' . $user . '/' . $dir;
    }
    foreach my $file (@catalog_chmod_files) {
        next if !-e $homedir . '/catalogs/' . $user . '/products/' . $file;
        chmod 0664, $homedir . '/catalogs/' . $user . '/products/' . $file;
    }
    exit 0;
}

if ( -e $homedir . '/public_html/cart/' . $user . '/images/items' ) {
    Cpanel::SafetyBits::safe_chmod( 02775, $user, $homedir . '/public_html/cart/images/items' );
    Cpanel::SafetyBits::safe_chmod( 02775, $user, $homedir . '/public_html/cart/images/thumb' );
}