Running a program as a specific user on startup
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix questions > Running a program as a specific user on startup




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-15-07 12:23 AM

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?






[ Post a follow-up to this message ]



    Re: Running a program as a specific user on startup  
jpd


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-15-07 12:23 AM

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.





[ Post a follow-up to this message ]



    Re: Running a program as a specific user on startup  
jpd


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-15-07 12:23 AM

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.





[ Post a follow-up to this message ]



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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-15-07 12:23 AM

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....






[ Post a follow-up to this message ]



    Re: Running a program as a specific user on startup  
Doug McIntyre


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-15-07 12:23 AM

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.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:09 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register