The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Prevent cgi-bin directory from being automatically created when connecting via sFTP

Discussion in 'General Discussion' started by jacobgraf, Feb 12, 2014.

  1. jacobgraf

    jacobgraf Registered

    Joined:
    Feb 12, 2014
    Messages:
    1
    Likes Received:
    1
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    This is simply a tutorial on how to prevent cgi-bin directories from automatically being created in the web root directory of your sites when connecting via sFTP. There are no real reasons to do this other than the fact that it's annoying when those directories keep re-appearing! :)

    It appears the bashrc file is creating these cgi-bin directories automatically. To stop this from happening, comment out the following lines in /etc/bashrc

    Code:
    if [ ! -e ~/public_html/cgi-bin ]; then
      mkdir -p ~/public_html/cgi-bin
    fi
    Hope that helps other OCD administrators like myself! :D
     
    reed1795 likes this.
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. kevinquinnyo

    kevinquinnyo Registered

    Joined:
    Jun 28, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I think this section is added by cPanel, based on where it is in the /etc/bashrc. So I'm assuming it will be recreated when cPanel updates?

    cPanel what's the reasoning behind forcing the creation of this directory each time a bash session is spawned?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. kevinquinnyo

    kevinquinnyo Registered

    Joined:
    Jun 28, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks cPanelMichael. It makes sense that a cPanel update would not overwrite /etc/bashrc, and that's a great policy.

    However, I wonder why is it there in the first place? The initial cPanel installation *seems* to add this to /etc/bashrc (I might be wrong on that). But if so, perhaps it's a legacy thing that should be removed on the next release?

    I just don't see a reason for automatic, forceful creation of $HOME/public_html/cgi_bin on every login. It even does it for root (because it's in the global bashrc). Why would I ever want a /root/public_html/cgi_bin/ nonetheless, a /root/public_html/ ?

    It's not a critical issue, but I'm just passing it along in case it needs to be suggested to the devs (maybe you're a part of that team?) . It really seems like a bug at this point.

    Thanks again for the followup
     
  6. ITGabs

    ITGabs Well-Known Member

    Joined:
    Jul 30, 2013
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Good tip!

    I saw an issue about some empty domains, probably it is related to the creation of public_html from a cpanel login when public_html it's empty or with the default content.

    what I see is the change of the group of the folder public_html for user:user when in the creation it is user:nobody note that I am using fcgid_mod but after there is some content that never happen again, another thing is about the user is under root, no reseller just the default.

    clean empty cgi-bin folders
    Code:
    find /home/ -name cgi-bin -type d -empty -exec rmdir {} \;
    check the no empty ones
    Code:
    find /home/ -name cgi-bin -exec echo {} \;
    this will work for .svn and .cvs folders... take care with rm commands!
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    This would be a good idea for a feature request:

    Submit A Feature Request

    Thank you.
     
Loading...

Share This Page