Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: file permissions with cgi script

Posted on 2007-09-20 11:48:54 by PTM

PTM: I wrote a script to handle my picture archives and show the
pictures thru web pages.
THe script is with permissions:
-r-xr-xr-x 1 root root 5572 2007-09-20 10:36 album.pl

My perl script creates a file to be included in a html page. It gets
permissions like this:
-rw-r--r-- 1 nobody nobody 113 2007-09-20 08:21 index.txt

Now I would like the script to give write access to group 'users' so
that the file could be edited by for example VI or JOE.
I have tried
$mode = 0666; chmod $mode, '$txt_file';

It doesn't change the permissions.

The same problem is with the directories. I don't find how to change
permissons of directories in perl running as CGI.

Do you have suggestions ?

Report this message

#2: Re: file permissions with cgi script

Posted on 2007-09-20 16:55:27 by Paul Lalli

On Sep 20, 5:48 am, PTM <ptmu...@utu.fi> wrote:
> PTM: I wrote a script to handle my picture archives and show the
> pictures thru web pages.
> THe script is with permissions:
> -r-xr-xr-x 1 root root 5572 2007-09-20 10:36 album.pl
>
> My perl script creates a file to be included in a html page. It gets
> permissions like this:
> -rw-r--r-- 1 nobody nobody 113 2007-09-20 08:21 index.txt
>
> Now I would like the script to give write access to group 'users' so
> that the file could be edited by for example VI or JOE.
> I have tried
> $mode = 0666; chmod $mode, '$txt_file';
>
> It doesn't change the permissions.

First, always ask Perl why it's not changing permissions:

chmod $mode, '$txt_file' or die "Cannot change permissions: $!\n";

And when that error message tells you that there's "no such file or
directory", hopefully you'll realize that you asked it to change the
permissions of
'$txt_file'
rather than
$txt_file

That is, you asked it to change the permissions of a file named
dollarsign, t, x, t, underscore, f, i, l, e. What you meant to do was
specify the file whose name is contained in the variable $txt_file.

Single quotes do not interpolate. See the difference between:
print "My file is: $txt_file\n";
vs
print 'My file is $txt_file\n';

See also:
perldoc -q quoting

Paul Lalli

Report this message

#3: Re: file permissions with cgi script

Posted on 2007-09-20 21:42:12 by PTM

Paul Lalli wrote:

> On Sep 20, 5:48 am, PTM <ptmu...@utu.fi> wrote:
>
>>PTM: I wrote a script to handle my picture archives and show the
>>pictures thru web pages.
>>Now I would like the script to give write access to group 'users' so
>>that the file could be edited by for example VI or JOE.
>>I have tried
>> $mode = 0666; chmod $mode, '$txt_file';
>>It doesn't change the permissions.
>
> First, always ask Perl why it's not changing permissions:
> chmod $mode, '$txt_file' or die "Cannot change permissions: $!\n";
> ...Single quotes do not interpolate. See the difference between:
> print "My file is: $txt_file\n";
> vs
> print 'My file is $txt_file\n';
>
> See also:
> perldoc -q quoting
>
> Paul Lalli
>
PTM: Oh my. I have been stupid. Thank you !
I'll go behind the corner and whip me all over.
I have copied the line of script from the net believing somebody had
tested it. My fault. Now there is only some honing left to make the
system work.
I have tried the line above in two systems with comparable results. Now
I can make them both work as they should.
Thank you !

Report this message

#4: Re: file permissions with cgi script

Posted on 2007-09-21 07:59:02 by PTM

>>Now I would like the script to give write access to group 'users' so
>>that the file could be edited by for example VI or JOE.

PTM: OK, now the system works. Still there is another problem with this.
The script changes the permissions of those files, which it has created
itself. Still it has no permissions to change the permissions of
directories created by someone else.
Is there a way ?

Report this message

#5: Re: file permissions with cgi script

Posted on 2007-09-22 01:09:40 by unknown

Post removed (X-No-Archive: yes)

Report this message

#6: Re: file permissions with cgi script

Posted on 2007-09-22 16:16:03 by PTM

all mail refused wrote:

> On 2007-09-21, PTM <ptmusta@utu.fi> wrote:
>
>
>>PTM: OK, now the system works. Still there is another problem with this.
>>The script changes the permissions of those files, which it has created
>>itself. Still it has no permissions to change the permissions of
>>directories created by someone else.
>>Is there a way ?
>
> Not just like that there isn't - and it's an OS issue rather than a Perl issue.
>
> Maybe you can explain better what you want and why it matters. There's a very
> good reason why any old process isn't allowed to go round changing anything
> it gets an idea about.
> Normally the webserver process and the people maintaining the web content will
> have different accounts. CGI scripts normally produce output that gets sent
> over the web and will only write to disk in carefully controlled circumstances
> if at all.

PTM: All this is clear.
I have pictures in a tree of subdirectories. The new pictures are saved
to new directories either thru Samba or SFTP. Now the user got to change
the permissions for this directory to allow what comes next.
My index.shtml calls for album.pl, which copies index.shtml to new
directory as a symbolic link, makes thumbs of the pictures and creates a
file index.pic containing <img src> -tags for the thumbs.

All is fine and works as Buick, but this changing the permissions is
annoying.
Is there a way to tell the system, that THIS directory and all which are
created under THIS will have preset permissions no matter who creates
the directory ?
Or is there any other way around this ?

Here is one of my picture collections where I'm using one of my
album-programs:
http://ptm2.cc.utu.fi/~ptmusta/kuvat/

Report this message

#7: Re: file permissions with cgi script

Posted on 2007-09-22 16:36:56 by unknown

Post removed (X-No-Archive: yes)

Report this message

#8: Re: file permissions with cgi script

Posted on 2007-09-22 21:26:37 by Pasi Mustalaht

all mail refused wrote:
> On 2007-09-22, PTM <ptmusta@utu.fi> wrote:
>
> I'm still not sure I've fully grasped what you are aiming for, and
> none of this has much to do with Perl.

PTM: Thank you. This discussion gave me enough information to see it
that the problem lies elsewhere an it is hard to solve it thru Perl CGI.
I'll try to find some other solution.

Report this message