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

jacobgraf

Registered
Feb 12, 2014
1
1
3
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
 
  • Like
Reactions: reed1795

kevinquinnyo

Registered
Jun 28, 2013
2
0
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?
 

kevinquinnyo

Registered
Jun 28, 2013
2
0
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
 

ITGabs

Well-Known Member
Jul 30, 2013
81
0
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!
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,233
363
cPanel Access Level
DataCenter Provider
Twitter
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/ ?
This would be a good idea for a feature request:

Submit A Feature Request

Thank you.