file permissions with cgi script
file permissions with cgi script
am 20.09.2007 11:48:54 von 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 ?
Re: file permissions with cgi script
am 20.09.2007 16:55:27 von Paul Lalli
On Sep 20, 5:48 am, PTM 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
Re: file permissions with cgi script
am 20.09.2007 21:42:12 von PTM
Paul Lalli wrote:
> On Sep 20, 5:48 am, PTM 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 !
Re: file permissions with cgi script
am 21.09.2007 07:59:02 von 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 ?
Re: file permissions with cgi script
am 22.09.2007 01:09:40 von unknown
Post removed (X-No-Archive: yes)
Re: file permissions with cgi script
am 22.09.2007 16:16:03 von PTM
all mail refused wrote:
> On 2007-09-21, PTM 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 -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/
Re: file permissions with cgi script
am 22.09.2007 16:36:56 von unknown
Post removed (X-No-Archive: yes)
Re: file permissions with cgi script
am 22.09.2007 21:26:37 von Pasi Mustalaht
all mail refused wrote:
> On 2007-09-22, PTM 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.