Setting Permissions with Package Manager Fails (2.0 b4)

Started by Popsikle, September 09, 2008, 09:10:48 PM

Previous topic - Next topic

Popsikle

* Version(s) of SMF : 2.0 b4

* Your Setup:
          o List any Modifications you have installed : none
          o List any Themes you have installed : none
          o List any non-English Language packs you have installed : none
          o Are you using UTF-8? : on a few
          o Any other related information?
* Server Software:
          o Apache/IIS version?: 2.2.3
          o PHP version?: 5.1.6
          o Database type and version: mysql 5
* Additional Information:

I just updated a few of my installs to 2.0b4 and started seeing permission errors while dealing with packages and such.  I ran some logging on my ftp daemon (vsftpd on all of them) and found that SMF was trying to chmod files that dont exist (note the leading / in the code comment below) and would not CWD properly, so I made a quick modification to the Class-Package.php chmod function (line 759).  I would imagine the bug is somewhere outside of this function but haven't  had anytime recently to find out where, and this works pretty well ;)

FTPD logs pre-fix:

Wed Sep 10 00:33:58 2008 [pid 7788] [popsikle] OK LOGIN: Client "127.0.0.1"
Wed Sep 10 00:33:58 2008 [pid 7790] [popsikle] FTP response: Client "127.0.0.1", "230 Login successful."
Wed Sep 10 00:33:58 2008 [pid 7790] [popsikle] FTP command: Client "127.0.0.1", "SITE CHMOD 755 /changelog.txt"
Wed Sep 10 00:33:58 2008 [pid 7790] [popsikle] FTP response: Client "127.0.0.1", "550 SITE CHMOD command failed."
Wed Sep 10 00:33:58 2008 [pid 7790] [popsikle] FAIL CHMOD: Client "127.0.0.1", "/changelog.txt 755"


FTPD logs post-fix (* added by me in place of domain name):

Wed Sep 10 00:46:27 2008 [pid 7973] [popsikle] OK LOGIN: Client "127.0.0.1"
Wed Sep 10 00:46:27 2008 [pid 7975] [popsikle] FTP response: Client "127.0.0.1", "230 Login successful."
Wed Sep 10 00:46:27 2008 [pid 7975] [popsikle] FTP command: Client "127.0.0.1", "SITE CHMOD 755 /***.****.com/forum/changelog.txt"
Wed Sep 10 00:46:27 2008 [pid 7975] [popsikle] OK CHMOD: Client "127.0.0.1", "/***.****.com/forum/changelog.txt 755"
Wed Sep 10 00:46:27 2008 [pid 7975] [popsikle] FTP response: Client "127.0.0.1", "200 SITE CHMOD command ok."



Buggy function:

public function chmod($ftp_file, $chmod)
{
if (!is_resource($this->connection))
return false;

if ($ftp_file == '')
$ftp_file = '.';

// Convert the chmod value from octal (0777) to text ("777").
fwrite($this->connection, 'SITE CHMOD ' . decoct($chmod) . ' ' . $ftp_file . "\r\n");
if (!$this->check_response(200))
{
$this->error = 'bad_file';
return false;
}

return true;
}


My Ghetto Fix:

public function chmod($ftp_file, $chmod)
{
if (!is_resource($this->connection))
return false;

if ($ftp_file == '')
$ftp_file = '.';
if (strpos($ftp_file,'/')==1)
$ftp_file = substr($ftp_file,1);
// Convert the chmod value from octal (0777) to text ("777").
fwrite($this->connection, 'SITE CHMOD ' . decoct($chmod) . ' ' . $ftp_file . "\r\n");
if (!$this->check_response(200))
{
$this->error = 'bad_file';
return false;
}

return true;
}

Fustrate

+1 more for this error... but I didn't bother to look for a workaround. Any word from the devs on this?
Steven Hoffman
Former Team Member, 2009-2012

SleePy

Thanks,

I haven't dug into it. But I think this is due to the default setup of mass changing file permissions assuming certain files exist when they don't.
I just quoted you since it was very detailed with those logs and all, I couldn't of done a better job  :P

Bug #2521: Package Manager trying to chmod non existing files
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Advertisement: