13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

14.9 Setting Up PostgreSQL for BudgetPro32314.9.2 Creating a postgres UserMore than likely, installing a PostgreSQL package will create a new <strong>Linux</strong> usercalled postgres <strong>on</strong> your system. This is not a login account; it will be used bythe database server process daem<strong>on</strong> 11 (called “postmaster,” lest you think thatit might be an e-mail server or something). Furthermore, <strong>on</strong>ly the postgresuser is able to create additi<strong>on</strong>al database users or any databases.Obviously, we w<strong>on</strong>’t want it to be like this forever. It has the same problemas the root user <strong>on</strong> the OS itself: There’s <strong>on</strong>e magic user with all thepower. You’ll need to create additi<strong>on</strong>al users and you’ll want to limit what theycan do. How to do it?First off, you can’t log in as postgres, so you will have to become rootand then su to the postgres user:[mschwarz@cassidy mschwarz]$ su -Password:[root@cassidy root]# su - postgres-bash-2.05b$Note that postgres didn’t have any profile or rc script to set up promptsor anything.All PostgreSQL databases have owning users, in much the same way thatall <strong>Linux</strong> files have owning users. But PostgreSQL users are not necessarily thesame as <strong>Linux</strong> users. 12 The <strong>on</strong>ly PostgreSQL user that exists “out of the box”is postgres. You must use the createuser command-line utility (or theequivalent SQL) to create a user. Here’s an example:11. Historically, daem<strong>on</strong> processes <strong>on</strong> UNIX systems used to be run as root. But a programerror in a daem<strong>on</strong> would allow a malicious user to execute code as the owner of the process. Ifthat owner is root, <strong>on</strong>e programming mistake in a server process could give an attacker totalc<strong>on</strong>trol of the system. Beware of any daem<strong>on</strong> process that runs as root. Nowadays, these runas either a totally n<strong>on</strong>priviledged user such as nobody, or, if they really need to write files orsome such thing, as a catch-all user like daem<strong>on</strong>. The database is an important process and itneeds its own security, so it runs as its own user, postgres.12. For most PostgreSQL command-line utilities, if no PostgreSQL username is specified, thecurrent <strong>Linux</strong> username will be used. This is often a c<strong>on</strong>venient choice, but you might havecompelling reas<strong>on</strong>s not to do this.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!