Gossamer Forum
Home : Products : Links 2.0 : Installation -- Unix :

Permission denied.

Quote Reply
Permission denied.
I know, know... Smile I've read every post out here on this problem but mine just want go away. Here's what the script is returning.

Links Manager: Building Pages
Building Pages
Pages built on 5-Apr-1999 at 18:47:16
--------------------------------------------------------

Backing up database . . .
Backing up links, category and email database (File::Copy) ...

CGI ERROR
==========================================
Error Message : Unable to copy links backup. Reason: Permission denied
Script Location : /data1/hypermart.net/lilgrnwing/cgi-bin/links/admin/nph-build.cgi
Perl Version : 5.00404

Form Variables
-------------------------------------------

Environment Variables
-------------------------------------------
DOCUMENT_ROOT : /data1/hypermart.net/lilgrnwing


Any suggestions would be greatly appreciated.
Thanks
Ken
Quote Reply
Re: Permission denied. In reply to
What have you tried in trying to fix the problem? On the surface, it looks like you admin/backup directory is not chmod 777, which it needs to be.
Quote Reply
Re: Permission denied. In reply to
I've chmoded the admin/backup directory to 777 until I'm blue in the face. At this point I'm not sure. I manually uploaded everything using cuteFTP as ASCII. It actually built the files one time. Then I went back and added some more categories through the build in interface and when I went to build them again it bombed. I have to admitt that as irrating as this is I'm having the time of my life Smile (I've been programming in other languages for the last 10 years and perl's a blast)
Quote Reply
Re: Permission denied. In reply to
This sounds peculiar to me too. Are there any files in the admin/backup directory currently? Are you using the final release of Links v2.0 and not one of the betas? Did you upgrade from a beta but may have not uploaded the new nph-build.cgi? Can you build okay via telnet but not from the web?

I know, all dumb questions, but I have found that sometimes asking the dumb questions will point to a problem not thought about previously.
Quote Reply
Re: Permission denied. In reply to
ken,

i'm having the same exact problem right now, have you found a fix yet? my site is also hosted at hypermart, do you think this could be it?

bobsie, you are right about debugging scripts.... it often seems to be the dumb things that cause the problems, especially when installing a script written by someone else.

i just wanted to make a post to this topic, as i am not having links working correctly right now... i am sure i am overlooking something.. but i also have checked and double checked my permissions...

hope to get some positive answers from someone on this, i really want to play with links and try it out some more Smile

Nate

ps- Ken, did you have to rename your data directory and edit all instances of 'data' in links.cfg? i think this may be a hypermart specific problem. i thought i would ask as i see you are hosting links at hypermart.

------------------
Nate -
email ->nx1@hotmail.com
icq --->26364237
Quote Reply
Re: Permission denied. In reply to
I'm getting the same problem as described above:

CGI ERROR
==========================================
Error Message : Unable to copy links backup. Reason: Permission denied
Script Location : /var/lib/httpd/cgi-bin/admin/nph-build.cgi
Perl Version : 5.00403

This has me stumped. No amount of chmodding, chowning and digging around with the original code makes a blind bit of difference.

Anyone know a way around this yet?

Regards, Phil.
Quote Reply
Re: Permission denied. In reply to
Alex (and everyone else too),

I have noted that on some systems, the links.db seems to have its permissions changed to 644 after executing the script. I am not sure why but have my suspicions.

I have a feeling that when Links creates the links.db.bak file (it is created when Links is updating the hits, ratings, votes, and isNew/isPop) it is being created with 644 permissions because that is the default permissions on most systems. After all changes are written into links.db.bak. it is then renamed from links.db.bak to links.db, effectively overwriting links.db and giving links.db the permissions assigned to links.db.bak (644).

If the rename fails for some reason, the contents of links.db.bak are copied to links.db (overwriting the old contents), which preserves the permissions on links.db.

The soulution to this is to execute a chmod command after each successful rename of links.db.bak to links.db as follows:

In nph-build.cgi, in both sub build_update_ratings and sub build_update_newpop, change the following:

Code:
if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or
&cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or
&cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB> ) { print DBTMP; }
close DB;
close DBTMP;
}
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}

To read:

Code:
if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or
&cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or
&cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB> ) { print DBTMP; }
close DB;
close DBTMP;
}
else { chmod 0666, $db_links_name; }
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}

That should clear up the problems with accessing links.db.

I hope this helps.

[This message has been edited by Bobsie (edited April 14, 1999).]
Quote Reply
Re: Permission denied. In reply to
Sorry, Bobsie, didn't work for me )-:

Have tried everything from changing the umask (default 022) to which user runs the HTTP daemon. And I still get:

Backing up database . . .
Backing up links, category and email database (File::Copy) ...

CGI ERROR
==========================================
Error Message : Unable to copy links backup. Reason: Permission denied
Quote Reply
Re: Permission denied. In reply to
Me again,

If I run nph-build.cgi from the command shell, it works fine -- no errors.

Don't know if this sheds any light...

Regards, Phil.
Quote Reply
Re: Permission denied. In reply to
Permissions on both the admin/data directory and the admin/backup directory must be 777. Permissions on all files in the data directory must be 666. If that is how your directory/file permissions are set, then it should make no difference whether you run from the web or from telnet. Apply my mod above to ensure the that links.db always has 666 permissions when building the pages.
Quote Reply
Re: Permission denied. In reply to
Hi Bobsie,

Thanks for all your time. It's now up and running.

To tell you the truth, I changed so much and messed around with so many permissions, I don't know exactly what was wrong or what I had to change to kick-start it.

Anyway. I followed your advice to the letter in your last message and... we're there!

Regards, Phil.
Quote Reply
Re: Permission denied. In reply to
I have the same, exact problem and error message (@ Hypermart account) but still couldn't fix it setting permissions as above and changing nph-build file Frown
Who can help?

Thanks Smile
Quote Reply
Re: Permission denied. In reply to
Sorry for the double posting. I have inserted the codes in this Item that Bobsie has supplied. The problem is that the links.db.bak file disappears every time I rebuild my site via my web browser. I have a cron job set-up for the nph-build.cgi script and I keep getting a permission denied for the links.db.bak file (because it is not there, I assume).

Anyone run accross this and how do I fix it?

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Permission denied. In reply to
The links.db.bak file will always be gone after nph-build.cgi completes its functions. It is nph-build.cgi that creates that file to begin with. It is used to update the hits and ratings, which are written to links.db.bak instead of links.db (in case anything goes wrong). When the updating is done, links.db.bak is renamed to links.db (if it can't be renamed, then the contents of links.db.bak are read in and written to links.db instead).

The code I posted earlier in this thread takes into account that the links.db.bak file has 644 permissions on it (the OS does that, not Links) and corrects the permissions on links.db which inherits those erroeneous permissions when links.db.bak overwrites it (only if the rename was successful).

It sounds more like you have a directory permissions problem to me. Make your admin/data directory chmod 777 and see if it makes a difference.

I hope this helps.