Unix questions - Running a program as a specific user on startup

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > January 2007 > Running a program as a specific user on startup





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Running a program as a specific user on startup
Danny.Willium@gmail.com

2007-01-14, 7:23 pm

Hi, im new with unix and I cant figure this out. Im running Freebsd 6
I installed pgsql and I need it to run on startup.
my /etc/rc.local file contains

echo " ";
echo "Proftpd Loading...";
/usr/local/sbin/proftpd -c /usr/local/etc/proftpd.conf
echo "Proftpd Running...";
echo " ";
echo "...";
/usr/local/apache/bin/apachectl start;
/etc/psqlrun;

and has the properties -rw-r--r-- 1 root wheel 198


/etc/psqlrun file contains

echo "Pgsql Loading...";
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
>/usr/local/pgsql/logfile 2>&1 &

echo "Pgsql Running...";


and has the properties -rwxr-xr-x 1 web wheel 142


how can i get pgsql postmaster to run as user web on startup?

jpd

2007-01-14, 7:23 pm

Begin <1168810605.680881.238930@s34g2000cwa.googlegroups.com>
On 2007-01-14, Danny.Willium@gmail.com <Danny.Willium@gmail.com> wrote:
> Hi, im new with unix and I cant figure this out. Im running Freebsd 6
> I installed pgsql and I need it to run on startup.
> my /etc/rc.local file contains

[snip!]
> how can i get pgsql postmaster to run as user web on startup?


You're reinventing the wheel. By default the provided startup script
uses the pgsql user, added by the port on installation. Configuring
startup actions can be done with a couple of lines like

postgresql_enable="YES"
postgresql_data="/var/pgsql/data"

in /etc/rc.conf. Such settings enable the apropriate scripts in
/etc/rc.d and /usr/local/etc/rc.d in the case of ports to Do The Right
Thing. How to do this is documented in the FreeBSD handbook.

You can find the handbook at www.freebsd.org, on the ftp sites in many
formats, and in the `doc' distribution set for easy installation on your
local system, as well.


--
j p d (at) d s b (dot) t u d e l f t (dot) n l .
This message was originally posted on Usenet in plain text.
Any other representation, additions, or changes do not have my
consent and may be a violation of international copyright law.
jpd

2007-01-14, 7:23 pm

Begin <1168810605.680881.238930@s34g2000cwa.googlegroups.com>
On 2007-01-14, Danny.Willium@gmail.com <Danny.Willium@gmail.com> wrote:
[snip!]
> how can i get pgsql postmaster to run as user web on startup?


In addition to my other followup: As a rule, you don't run PostgreSQL
as user web, because there is no need and good reasons not to. Instead,
you make a user web in the PostgreSQL database --such users are
different from and not necessairily related to system users-- then have
whatever web related things connect to the database as user web with the
appropriate password, if any.


--
j p d (at) d s b (dot) t u d e l f t (dot) n l .
This message was originally posted on Usenet in plain text.
Any other representation, additions, or changes do not have my
consent and may be a violation of international copyright law.
Danny.Willium@gmail.com

2007-01-14, 7:23 pm

i didnt install it using ports i compiled it myself.
the reason why i want it to run under web is because thats the user
that made the database on pgsql.

postgresql_enable= "yes"
postgresql_data="/usr/local/pgsql/data"
i already tried that, it doesnt work.

could you please tell me how to run a script as a different user. i
know this may not be the most secure / best method but i already made
the mistake of configuring everything....

Doug McIntyre

2007-01-14, 7:23 pm

Danny.Willium@gmail.com writes:
>i didnt install it using ports i compiled it myself.
>the reason why i want it to run under web is because thats the user
>that made the database on pgsql.


>postgresql_enable= "yes"
>postgresql_data="/usr/local/pgsql/data"
>i already tried that, it doesnt work.


Thats because it depends on the startup scripts the ports area use, to
make match the rest of the BSD system. It seems to me, that you'd be
better off using ports, configured by somebody that knows how to do
it, rather than opening up security holes on your own to blame the OS later..

>could you please tell me how to run a script as a different user. i
>know this may not be the most secure / best method but i already made
>the mistake of configuring everything....


The same way you do it interactively, with 'su' (ie. the man page for
su will give you the proper options).
For example, see the ports startup script for pgsql.

As the previous poster posted, what you are trying to do is open a
huge security hole for yourself. Don't run pgsql as the web user,
nobody does it that way, its not designed to run that way, the
security model is designed not to run that way, but yet you want to
fight an uphill battle to make yourself a security hole.

IMHO, it'll be *much less* work for you to figure out how the ports
system is setup to do it, and move your existing data over to its
setup (which will be standard on other FreeBSD systems as well if you
run across them in the future), rather than to continue to forge your
own path without knowledge of how its designed to run.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com