ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have a personal website written in PHP whose content I control through a MySQL database. On each page I call a function to connect to the database. This function contains my database username and password in plain text, in order to connect. I didn't realize it, but anyone else with a user account on the server could easily browse into my public_html directory and take a look at the file containing this function, which would reveal my username and password.
Changing permissions won't work because the file with the function needs to be readable by all in order to include it in public files. I've thought there might be a way to leave the function public while hiding the username and password in a global variable defined elsewhere, hidden.
I've been doing this for a while but didn't realize the possible security breach until recently and haven't found a solution yet although I'm sure one must exist. Any help would be greatly appreciated.
But even in this case (reading from a separate file), the password file still needs to be readable by the webserver, which puts it right back into the same situation as if the info were directly in the PHP file itself. (And using a PHP include statement, it technically is.)
The reason this kind of information isn't exposed is because any PHP file getting sent out by the web server gets processed before it is sent out. Hence, your password can't be seen unless it is downloaded using an alternative (e.g. FTP) method. Of course, any sensitive data of this nature should not be publicly accessible by any method other than HTTP or HTTPS.
I'm confident that in order to access this file, you need to have a valid login to the server, not just anonymous. The appropriate user name is indeed www-data, but I don't have the permission to change the file's owner. Putting the information in a separate file then including it or using fopen simply, as taylor stated, puts me in the same situation as if the info was in the same file.
How is this usually done on websites where security is a big issue? I realize a big problem here is that there are many users that I don't know who could access the file instead of being able to control the users on the server.