Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

CHMOD script
is there such a thing as a perl / cgi
script that will do a CHMOD on a
specified file - in a specified directory.....


siggy





Report this thread to moderator Post Follow-up to this message
Old Post
siggy
10-10-04 02:59 AM


Re: CHMOD script
siggy wrote:
> is there such a thing as a perl / cgi
> script that will do a CHMOD on a
> specified file - in a specified directory.....

Don't know, but there is a Perl function that does just that.

perldoc -f chmod

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
10-10-04 02:59 AM


Re: CHMOD script
"siggy" <this_is_me_sigma@accesscomm.com> wrote in message
news:41685d72$1@news.accesscomm.ca...
> is there such a thing as a perl / cgi
> script that will do a CHMOD on a
> specified file - in a specified directory.....

Congratulations!!  You've earned an entry in the Perl SAQ.

http://www.ginini.com/perlsaq.html




Report this thread to moderator Post Follow-up to this message
Old Post
Peter Sundstrom
10-10-04 02:59 AM


Re: CHMOD script
In message <2sra42F1mlv59U1@uni-berlin.de>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
 

> Don't know, but there is a Perl function that does just that.
>      perldoc -f chmod

It doesn't, you know.

I wrote a Perl script to create a directory and install a file in it which
another user could access. I was carefull to chmod appropriately. Both
directory and file are now sitting in my cgi-bin: the user can't access
them, I can't delete them.

The problem, apparently, is that I am not the "owner" of the file/directory.

If anyone has a solution to the problem, I'm eager to hear from them.

Ken Down

--
================ ARCHAEOLOGICAL DIGGINGS ===============
|    Australia's premiere archaeological magazine      |
|             http://www.diggingsonline.com            |
 ========================================
================

Report this thread to moderator Post Follow-up to this message
Old Post
Kendall K. Down
10-10-04 08:56 PM


Re: CHMOD script
"Kendall K. Down" <webmaster@diggingsonline.com> wrote in message
news:758092fb4c.diggings@diggingsonline.com...
> In message <2sra42F1mlv59U1@uni-berlin.de>
>          Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> 
> 
>
> It doesn't, you know.
>

It does. You seem to have the common problem of not understanding how
permissions work in the CGI environment, though. Just because a script was
written by you does not mean it will be run as you by the server. You need
to change the way you set the permissions accordingly.

Matt



Report this thread to moderator Post Follow-up to this message
Old Post
Matt Garrish
10-11-04 01:55 AM


Re: CHMOD script
Kendall K. Down wrote:
> I wrote a Perl script to create a directory and install a file in
> it which another user could access. I was carefull to chmod
> appropriately. Both directory and file are now sitting in my
> cgi-bin: the user can't access them, I can't delete them.

Then you did apparently *not* chmod them carefully.

> The problem, apparently, is that I am not the "owner" of the
> file/directory.

In that case, your Perl script is a CGI script, and CGI is run as some
other user but you.

> If anyone has a solution to the problem, I'm eager to hear from
> them.

Read up about the Unix/Linux file permissions system. You can't change
permissions of that directory and file e.g. via your FTP client, but
you can have your CGI script do it using the Perl chmod() function. If
you e.g. want anybody being able to read the file, you can set the
directory permission 755 and file permission 644. You can also have
the CGI script delete the file, since the user CGI is run as owns the
directory. The directory itself can well be deleted via your FTP
client, since *you* (I assume) own the directory in which the script
generated directory is located.

HTH

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
10-11-04 01:55 AM


Re: CHMOD script
In article <2srd1vF1iiooeU1@uni-berlin.de>, Peter Sundstrom wrote:

snipped to save someones embarassment

> Congratulations!!  You've earned an entry in the Perl SAQ.
>
> http://www.ginini.com/perlsaq.html

I've had to bookmark that it's so much fun. Damn glad I didn't make the
list 'cos I know I've asked some damned dum questions!

Though the Llama is a great teacher it doesn't go far enough, it doesn't
teach us the value of perldoc - or it doesn't go far enough in showing
the path!

Maybe Randal and Tom can rectify this in the next version?!


Justin.

--
Justin C, by the sea.

Report this thread to moderator Post Follow-up to this message
Old Post
Justin C
10-11-04 08:55 AM


Re: CHMOD script
In message <CJgad.10308$3C6.248852@news20.bellglobal.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote:

> It does. You seem to have the common problem of not understanding how
> permissions work in the CGI environment, though. Just because a script was
> written by you does not mean it will be run as you by the server. You need
> to change the way you set the permissions accordingly.

That is entirely possible; I am a Perl newbie. So *please*, tell me what to
do!

Ken Down

--
================ ARCHAEOLOGICAL DIGGINGS ===============
|    Australia's premiere archaeological magazine      |
|             http://www.diggingsonline.com            |
 ========================================
================

Report this thread to moderator Post Follow-up to this message
Old Post
Kendall K. Down
10-11-04 08:55 PM


Re: CHMOD script
In message <2stmfmF1p25fcU1@uni-berlin.de>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

> In that case, your Perl script is a CGI script, and CGI is run as some
> other user but you.

Yes, it is and yes, I have already identified that as the problem.

> Read up about the Unix/Linux file permissions system. You can't change
> permissions of that directory and file e.g. via your FTP client, but
> you can have your CGI script do it using the Perl chmod() function.

I used chmod() immediately after creating the file.

> If
> you e.g. want anybody being able to read the file, you can set the
> directory permission 755 and file permission 644.

Hmmmm. I set both to 766 (if I recall correctly - it was a couple of months
ago). I'll check up though and write another script to try and change the
permissions as you suggest.

> You can also have
> the CGI script delete the file, since the user CGI is run as owns the
> directory. The directory itself can well be deleted via your FTP
> client, since *you* (I assume) own the directory in which the script
> generated directory is located.

Yes, it is my private cgi-bin.

Thanks for your help.

Ken Down

--
================ ARCHAEOLOGICAL DIGGINGS ===============
|    Australia's premiere archaeological magazine      |
|             http://www.diggingsonline.com            |
 ========================================
================

Report this thread to moderator Post Follow-up to this message
Old Post
Kendall K. Down
10-11-04 08:55 PM


Re: CHMOD script
Kendall K. Down wrote:
 
>
> Hmmmm. I set both to 766 (if I recall correctly - it was a couple of month
s
> ago). I'll check up though and write another script to try and change the
> permissions as you suggest.

Keep in mind that 755 and 644 (as decimal numbers) do not work:
chmod 644,$filename;		# Wrong
You need 0755 or 0644:
chmod 0644,$filename or warn "Can't chmod $filename: $!";

The leading zero tells perl that the literal that follows is a
number in octal notation, which is what is needed for chmod().

-Joe

Report this thread to moderator Post Follow-up to this message
Old Post
Joe Smith
10-11-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

PERL Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:51 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.