pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Using system call + wrapper?
7+ messages / 7 participants
[nested] [flat]

* Using system call + wrapper?
@ 2001-02-26 17:01 Richie <dugganr@student.cs.ucc.ie>
  2001-02-26 17:25 ` Re: Using system call + wrapper? David Olbersen <dave@slickness.org>
  2001-02-26 17:28 ` Re: Using system call + wrapper? Viktor Fougstedt <viktor@dtek.chalmers.se>
  2001-02-26 17:31 ` Re: Using system call + wrapper? Mitch Vincent <mitch@venux.net>
  2001-02-26 17:37 ` Re: Using system call + wrapper? Adam Lang <aalang@rutgersinsurance.com>
  2001-02-26 19:25 ` Re: Using system call + wrapper? Steve Bern <sabern@eshell.net>
  0 siblings, 5 replies; 7+ messages in thread

From: Richie @ 2001-02-26 17:01 UTC (permalink / raw)
  To: pgsql-php

Hi

I am trying to allow people to save images from their file system to a
directory on my machine called images, for example the path that I want to
save to is /usr/local/apache/htdocs/project/images/.

Obviously from above I am using an Apache web server, PHP and PostgreSQL.
My problem is that you need sudo access to save anything to this
directory so I get a "Permission denied..." error on the browser. I want
to save the image to the images directory and save the path to a table in
my database, however I can do neither in the current situation.

It was suggested to me to use a wrapper that invokes a system call such as
system('sudo upload.php -p password') that will run the program in sudo
but I really don't know where to start with this??

Can anyone please help me?

=========================================================
Richie Duggan 
Computer Science IV
University College Cork
Eamil : dugganr@student.cs.ucc.ie   richie_dug@yahoo.com
Homepage : http://student.cs.ucc.ie/01/dugganr/index.html




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Using system call + wrapper?
  2001-02-26 17:01 Using system call + wrapper? Richie <dugganr@student.cs.ucc.ie>
@ 2001-02-26 17:25 ` David Olbersen <dave@slickness.org>
  2001-02-26 17:37   ` Re: Using system call + wrapper? Dan Wilson <phpPgAdmin@acucore.com>
  4 siblings, 1 reply; 7+ messages in thread

From: David Olbersen @ 2001-02-26 17:25 UTC (permalink / raw)
  To: Richie <dugganr@student.cs.ucc.ie>; +Cc: pgsql-php

On Mon, 26 Feb 2001, Richie wrote:

-> /usr/local/apache/htdocs/project/images/.
->
->My problem is that you need sudo access to save anything to this
->directory

'chown <HTTP USER> /usr/local/apache/htdocs/project/images/'
'chmod 755 /usr/local/apache/htdocs/project/images/'

That should take care of the problem, shouldn't it?

-- Dave




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Using system call + wrapper?
  2001-02-26 17:01 Using system call + wrapper? Richie <dugganr@student.cs.ucc.ie>
  2001-02-26 17:25 ` Re: Using system call + wrapper? David Olbersen <dave@slickness.org>
@ 2001-02-26 17:37   ` Dan Wilson <phpPgAdmin@acucore.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Dan Wilson @ 2001-02-26 17:37 UTC (permalink / raw)
  To: David Olbersen <dave@slickness.org>; Richie <dugganr@student.cs.ucc.ie>; +Cc: pgsql-php

: On Mon, 26 Feb 2001, Richie wrote:
:
: -> /usr/local/apache/htdocs/project/images/.
: ->
: ->My problem is that you need sudo access to save anything to this
: ->directory
:
: 'chown <HTTP USER> /usr/local/apache/htdocs/project/images/'
: 'chmod 755 /usr/local/apache/htdocs/project/images/'
:
: That should take care of the problem, shouldn't it?
:
: -- Dave

That would take care of it, but then you just blocked any normal FTP access
into that directory.

I would:

'chgrp [HTTPD USER] /usr/local/apache/htdocs/project/images'
'chmod g+w /usr/local/apache/htdocs/project/images'

That way, the current user still has control, but the HTTPD user also has
write access.

-Dan




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Using system call + wrapper?
  2001-02-26 17:01 Using system call + wrapper? Richie <dugganr@student.cs.ucc.ie>
@ 2001-02-26 17:28 ` Viktor Fougstedt <viktor@dtek.chalmers.se>
  4 siblings, 0 replies; 7+ messages in thread

From: Viktor Fougstedt @ 2001-02-26 17:28 UTC (permalink / raw)
  To: Richie <dugganr@student.cs.ucc.ie>; +Cc: pgsql-php

On Mon, 26 Feb 2001, Richie wrote:

> It was suggested to me to use a wrapper that invokes a system call such as
> system('sudo upload.php -p password') that will run the program in sudo
> but I really don't know where to start with this??

You should never, ever, ever run CGI-/PHP-applications as root. And
running things as root is what sudo normally does. Is that what you're
contemplating?

If so, alter the owner of the directory instead so that your ordinary
CGI-/PHP-scripts may write to it. But be _very_ careful how you write your
code. Can anybody upload things? What happens when the filesystem gets
full? Also be very careful that you do not trust any data the user
supplies, especially not with the "system" call.


/Viktor...

--|     Viktor Fougstedt, system administrator at dtek.chalmers.se     |--
--|                http://www.dtek.chalmers.se/~viktor/                |--
--| ...soon we'll be sliding down the razor blade of life. /Tom Lehrer |--




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Using system call + wrapper?
  2001-02-26 17:01 Using system call + wrapper? Richie <dugganr@student.cs.ucc.ie>
@ 2001-02-26 17:31 ` Mitch Vincent <mitch@venux.net>
  4 siblings, 0 replies; 7+ messages in thread

From: Mitch Vincent @ 2001-02-26 17:31 UTC (permalink / raw)
  To: Richie <dugganr@student.cs.ucc.ie>; pgsql-php

> I am trying to allow people to save images from their file system to a
> directory on my machine called images, for example the path that I want to
> save to is /usr/local/apache/htdocs/project/images/.
>
> Obviously from above I am using an Apache web server, PHP and PostgreSQL.
> My problem is that you need sudo access to save anything to this
> directory so I get a "Permission denied..." error on the browser. I want
> to save the image to the images directory and save the path to a table in
> my database, however I can do neither in the current situation.
>
> It was suggested to me to use a wrapper that invokes a system call such as
> system('sudo upload.php -p password') that will run the program in sudo
> but I really don't know where to start with this??

The easiest thing to do is allow the web server write access to the upload
directory or perhaps some creative use of sym links would work.. This one is
a little out there but you could also save the files in a temporary
directory and have a cron job every minute or so go through and copy
everything in that directory over to the one you need the files in. If
you're using PHP as an apache module then I don't think you can run a single
script as a different user, though you might want to check on apache's
su-exec functionality for CGI scripts.. If you're running a CGI you could
always use the ever-so-insecure suid bit solution but I would suggest
against it..

Good luck!

-Mitch






^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Using system call + wrapper?
  2001-02-26 17:01 Using system call + wrapper? Richie <dugganr@student.cs.ucc.ie>
@ 2001-02-26 17:37 ` Adam Lang <aalang@rutgersinsurance.com>
  4 siblings, 0 replies; 7+ messages in thread

From: Adam Lang @ 2001-02-26 17:37 UTC (permalink / raw)
  To: pgsql-php

Any reason you don't have the images uploaded to somewhere that you don't
have such security issues?  Like a home directory or something?

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Richie" <dugganr@student.cs.ucc.ie>
To: <pgsql-php@postgresql.org>
Sent: Monday, February 26, 2001 12:01 PM
Subject: [PHP] Using system call + wrapper?


> Hi
>
> I am trying to allow people to save images from their file system to a
> directory on my machine called images, for example the path that I want to
> save to is /usr/local/apache/htdocs/project/images/.
>
> Obviously from above I am using an Apache web server, PHP and PostgreSQL.
> My problem is that you need sudo access to save anything to this
> directory so I get a "Permission denied..." error on the browser. I want
> to save the image to the images directory and save the path to a table in
> my database, however I can do neither in the current situation.
>
> It was suggested to me to use a wrapper that invokes a system call such as
> system('sudo upload.php -p password') that will run the program in sudo
> but I really don't know where to start with this??
>
> Can anyone please help me?
>
> =========================================================
> Richie Duggan
> Computer Science IV
> University College Cork
> Eamil : dugganr@student.cs.ucc.ie   richie_dug@yahoo.com
> Homepage : http://student.cs.ucc.ie/01/dugganr/index.html




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Using system call + wrapper?
  2001-02-26 17:01 Using system call + wrapper? Richie <dugganr@student.cs.ucc.ie>
@ 2001-02-26 19:25 ` Steve Bern <sabern@eshell.net>
  4 siblings, 0 replies; 7+ messages in thread

From: Steve Bern @ 2001-02-26 19:25 UTC (permalink / raw)
  To: Richie <dugganr@student.cs.ucc.ie>; +Cc: pgsql-php

I think you've got a lot of good suggestions on how to tackle this
specific issue.  One thing regarding overall design that was briefly
touched on...  You might want to consider having uploading be put into a
staging area that makes no assumptions regarding content, then have a
cron job transfer data over to your productive environment (or
productive directory)... (this was suggested by one of the posts, but
I'm just elaborating on it a bit).  This cron job will add a layer of
abstraction that will provide you with a good bit of flexibility if your
app grows or needs to change at all.  The cron job can then be easily
modified to do certain checks:  is the file valid?  Is it in some way
unreasonable?  Is there space for it in the productive area?  Does the
file already exist?  If so, should it be overwritte?  If I were building
this app, I'd make special effort to seperate content into at least two
camps in the production environment:  content you've written, that's
verified, and content that's in
some way dependant on the user uploading or whatever.  Generally, try to
keep these two as seperate as possible -- even a new directory tree
using symbolic links would be good -- make a /home/usersubmissions or
something to keep this second type of content in, then your /apache tree
is a lot cleaner.  Also, putting your usersubmissions on another
partition (if you've got /usr/local on its own) will prevent /usr/local,
or on Red Hat /var/www from running out of space... if /home runs out of
space, not as big a deal than if some other directories do.

Steve

On Mon, 26
Feb 2001, Richie wrote:

> Hi
>
> I am trying to allow people to save images from their file system to a
> directory on my machine called images, for example the path that I want to
> save to is /usr/local/apache/htdocs/project/images/.
>
> Obviously from above I am using an Apache web server, PHP and PostgreSQL.
> My problem is that you need sudo access to save anything to this
> directory so I get a "Permission denied..." error on the browser. I want
> to save the image to the images directory and save the path to a table in
> my database, however I can do neither in the current situation.
>
> It was suggested to me to use a wrapper that invokes a system call such as
> system('sudo upload.php -p password') that will run the program in sudo
> but I really don't know where to start with this??
>
> Can anyone please help me?
>
> =========================================================
> Richie Duggan
> Computer Science IV
> University College Cork
> Eamil : dugganr@student.cs.ucc.ie   richie_dug@yahoo.com
> Homepage : http://student.cs.ucc.ie/01/dugganr/index.html
>




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2001-02-26 19:25 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-26 17:01 Using system call + wrapper? Richie <dugganr@student.cs.ucc.ie>
2001-02-26 17:25 ` David Olbersen <dave@slickness.org>
2001-02-26 17:37   ` Dan Wilson <phpPgAdmin@acucore.com>
2001-02-26 17:28 ` Viktor Fougstedt <viktor@dtek.chalmers.se>
2001-02-26 17:31 ` Mitch Vincent <mitch@venux.net>
2001-02-26 17:37 ` Adam Lang <aalang@rutgersinsurance.com>
2001-02-26 19:25 ` Steve Bern <sabern@eshell.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox