473,581 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what the heck does "permission s 33279" mean?

I want to give users the power to edit files from an easy interface, so
I create a form and a PHP script called "fileUpdate ". It does a
reasonable about of error checking and prints out some errors. It uses
fileperms() to get the permissions of the file, and it includes that
info in any error message. Today I'm getting the following error
message. I've used SmartFtp to go in and set the test file's
permissions to 777, but in this error message I'm being told that
permissions are really 33279. What the heck does that mean?

=============== =============== ======
Error: In fileUpdate(), we wanted to open the file
'ppArrangements Admin/editimageInfoFo rm.php' so we could edit it, but we
were not able to open it. It's permissions were set to '33279'

Jul 17 '05 #1
15 6866
lk******@geocit ies.com wrote:
... It uses
fileperms() to get the permissions of the file, and it includes that
info in any error message...
... I'm being told that
permissions are really 33279. What the heck does that mean?


33279 (decimal) = 100777 (octal)

I have no idea what that 1 is doing there.
Maybe you would be better off using one of the examples at

http://www.php.net/fileperms

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #2
>> ... It uses
fileperms() to get the permissions of the file, and it includes that
info in any error message...
... I'm being told that
permissions are really 33279. What the heck does that mean?


33279 (decimal) = 100777 (octal)

I have no idea what that 1 is doing there.


The upper bits of the file permissions, which you cannot change
with chmod, typically indicate the type of the file (regular file,
directory, socket, symlink, named pipe, etc. ).

Gordon L. Burditt
Jul 17 '05 #3
How do I ask a RedHat Linux box what the hell its permissions mean? No
wait, maybe that is not the problem. Is fileperms ever wrong? My FTP
client says the permissions are simply 777. But PHP cannot change the
file.

Jul 17 '05 #4
lk******@geocit ies.com wrote:
How do I ask a RedHat Linux box what the hell its permissions mean? No
wait, maybe that is not the problem. Is fileperms ever wrong? My FTP
client says the permissions are simply 777. But PHP cannot change the
file.

You can't change it if you don't have permission to modify data held
about it in the directory. So, if that's set to 555 ( ignoring
ownerships for the sake of example ), then you can't change the file.

Steve
Jul 17 '05 #5
I'm not sure I understand you. The permissions seem to be set to 777.
Why would PHP lack, as you say, "permission to modify data held about
it in the directory". What kind of data are you referring to? Is there
another layer of permisions in Linux that has nothing to do with the
numbers?

Let me ask this question more generally. How do I troubleshoot this
problem? My PHP code is not being allowed to change a file. My FTP
client says permissions on the file (and also the directory that it is
in) is set to 777. How do I track down what the problem is? What
questions do I ask? My code has a fair amount of error checking, but
none of it quite reveals the problem. The permissions were, I thought,
set to 33279 which I thought was funny, but it now it seems, based on
what Graca and Burditt said, that that resolves itself to 777. So how
do I find out what the problem is?
<?php

function fileUpdate() {
// 12-08-04 - we want to make it easy for people to customize their
own installations of
// the software, so want to make it easy for them to edit those
arrangements that make up
// the control panel.
$controllerForA ll = & getController() ;
$resultsObject = & $controllerForA ll->getObject("McR esults", " in the
function fileUpdate().") ;

// 12-08-04 - since PHP will cache file info, we need to clear the
cache if we are doing multiple
// things which might cause a "true" result to become "false" or vice
versa.
clearstatcache( );

$formInputs = $GLOBALS["formInputs "];

if (is_array($form Inputs)) {
extract($formIn puts);

// 04-05-04 - we need to trim white space off the ends of these, and
neutralize any dangerous code
// that hackers have tried to slip in.
$fileName = trim($fileName) ;
$fileContent = trim($fileConte nt);
$fileNameOld = trim($fileNameO ld);
$fileContentOld = trim($fileConte ntOld);
$fileName = htmlspecialchar s($fileName);
$fileNameOld = htmlspecialchar s($fileNameOld) ;
// 04-05-04 - an easy hacker attack would be to overwrite much needed
files, outside the correct directory.
// Therefore we need to take control of what directory is being
written to.
$fileNameRecord = $fileName;
$len = strlen($fileNam e);
$char = "";
$count = 0;
// 12-08-04 - this next bit is too clever. Basically, we expect the
file name at this point to look
// like this:
//
// ppArrangementsA dmin/editweblogPages Form.php
//
// We want to strip off the "ppArrangements Admin/" part. So we walk
through till we get to
// the first "/". Then we take the rest of the filename and proceed.
If there is still a "/"
// in the filename after this, we can assume some hacker was trying
to make some kind of
// attack, and so we'll throw an error.
while ($count < $len && $char != "/") {
$char = substr($fileNam e, 0, 1);
$fileName = substr($fileNam e, 1);
$count++;
}
$location = strpos($fileNam e, "/");
if (is_numeric($lo cation)) {
$resultsObject->addToResults(" We were unable to update this file.
The file name is invalid. It should not contain more than one '/'
(forward slash). This is what we got: $fileNameRecord . Problem in
fileUpdate()", "fileUpdate ");
} else {
$config = getConfig();
$pathToNeededFi les = $config["pathToNeededFi les"];

$formData = $GLOBALS["formData"];
$fileType = $formData["fileType"];
if ($fileType == "public") {
$fileName = "ppArrangements Public/".$fileName ;
} else {
$fileName = "ppArrangements Admin/".$fileName ;
}

$fileName = $pathToNeededFi les.$fileName;
if (file_exists($f ileName)) {
$perm = fileperms($file Name);

$fileNameBackup = str_replace("/", "/backup_", $fileNameOld);
$fp = @ fopen($fileName Backup, "w+");

if ($fp) {
$fileContentOld = stripslashes($f ileContentOld);
$success = @ fwrite($fp, $fileContentOld );
$isClosed = @ fclose($fp);

if ($success) {
$resultsObject->addToResults(" We created a back up of your file
and gave it the name $fileNameBackup . If you need to restore the old
version, go back to that file.");

$fp = @fopen($fileNam e, "w+");
$fileContent = stripslashes($f ileContent);
$success2 = @fwrite($fp, $fileContent);
@fclose($fp);

if ($success2) {
$resultsObject->addToResults(" We successfully saved the
$fileName document.");
} else {
$fileContent = htmlspecialchar s($fileContent) ;
$resultsObject->addToResults(" In fileUpdate, something went
wrong and we were unable to save the document called ' $fileName '. The
file permissions were set to '$perm'. You'd written: $fileContent ");
}
} else {
$fileContent = stripslashes($f ileContent);
$fileContent = htmlspecialchar s($fileContent) ;
$resultsObject->addToResults(" In fileUpdate(), we tried to create
a back up of your file and give it the name $fileNameBackup , but we
failed. The file permissions were set to '$perm'. Because of the risk
of overwriting your only copy, we have not tried to update the file.
Here is what you'd written: $fileContent");
}
} else {
$resultsObject->error("In fileUpdate(), we wanted to open the file
'$fileName' so we could edit it, but we were not able to open it. It's
permissions were set to '$perm'", "fileUpdate ");
}
} else {
$resultsObject->error("In fileUpdate(), we wanted to open the file
'$fileName' but it does not exist.", "fileUpdate ");
}
}
} else {
$resultsObject->error("In fileUpdate, we assumed we were going to be
given a set of data called formInputs, but for some reason we got no
such thing.", "fileUpdate ");
}
}


?>

Jul 17 '05 #6
On 9 Dec 2004 11:26:43 -0800, lk******@geocit ies.com wrote:
I'm not sure I understand you. The permissions seem to be set to 777.
Why would PHP lack, as you say, "permission to modify data held about
it in the directory". What kind of data are you referring to? Is there
another layer of permisions in Linux that has nothing to do with the
numbers?
As posted by others, fileperms returns not only the file permissions, but also
the bits representing the type of the file. This is all bunched together within
the filesystem. To see permissions, you should only look at specific bits, and
convert to octal for the usual convention of 777 = wide open permissions.

The manual has an example function to convert fileperms bits into readable
form, and this also gives some idea how to isolate the permissions bits.

http://uk2.php.net/manual/en/function.fileperms.php
Let me ask this question more generally. How do I troubleshoot this
problem? My PHP code is not being allowed to change a file. My FTP
client says permissions on the file (and also the directory that it is
in) is set to 777. How do I track down what the problem is? What
questions do I ask? My code has a fair amount of error checking, but
none of it quite reveals the problem. The permissions were, I thought,
set to 33279 which I thought was funny, but it now it seems, based on
what Graca and Burditt said, that that resolves itself to 777. So how
do I find out what the problem is? $fp = @ fopen($fileName Backup, "w+");


Wouldn't it be a good idea to remove the @ error-suppression operator? Since
you don't know why the open is failing, and you've only printed out a generic
message of your own invention in response, it would be valuable to see the
actual error message that PHP raises.

Disk full, quota exceeded, locked by another process (possibly depending on
filesystem there) are all potential reasons why a 777-permission file couldn't
be opened for writing.

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #7
--------------------------
Wouldn't it be a good idea to remove the @ error-suppression operator?
Since
you don't know why the open is failing, and you've only printed out a
generic
message of your own invention in response, it would be valuable to see
the
actual error message that PHP raises.
--------------------------

That is a good idea. I removed all the error suppressors and got this:

Warning: fopen("", "w+") - Success in
/home/httpd/vhosts/yoganinjaallian ce.org/httpdocs/ppExtras/fileUpdate.php
on line 71

I can not imagine what this means and I'm confused why the warning has
the word "Success" in it. I'm also uncertain why the fopen is showing
double double-quotes for the first parameter, as if no file name was
given to it. My code first checks that the file exists, so it's not
possible that I'm passing an empty string to fopen:
$fileName = $pathToNeededFi les.$fileName;
if (file_exists($f ileName)) {
$perm = fileperms($file Name);

$fileNameBackup = str_replace("/", "/backup_", $fileNameOld);
$fp = fopen($fileName Backup, "w+");

if ($fp) {
$fileContentOld = stripslashes($f ileContentOld);
$success = fwrite($fp, $fileContentOld );
$isClosed = fclose($fp);

if ($success) {
$resultsObject->addToResults(" We created a back up of your file
and gave it the name $fileNameBackup . If you need to restore the old
version, go back to that file.");

$fp = fopen($fileName , "w+");
$fileContent = stripslashes($f ileContent);
$success2 = fwrite($fp, $fileContent);
fclose($fp);

Jul 17 '05 #8
lk******@geocit ies.com wrote:
Warning: fopen("", "w+") - Success in
/home/httpd/vhosts/yoganinjaallian ce.org/httpdocs/ppExtras/fileUpdate.php
on line 71
<snip>
$fileName = $pathToNeededFi les.$fileName;
if (file_exists($f ileName)) {
$perm = fileperms($file Name);

$fileNameBackup = str_replace("/", "/backup_", $fileNameOld); ^^^^^^^^^^^^
Where did this variable come from?
$fp = fopen($fileName Backup, "w+");

<snip>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #9
The variable you are pointing to is simply the old name of the file,
with "backup" appended. I make a backup to protect people from making a
stupid mistake.

I should add that we had a server on Interland and this code worked
without a hitch, on servers running Free BSD. We've recently switched
to a new server on Rackspace running RedHat Linux. I'm not sure, but
I'd guess that is when the problem started. But, as I say, my test file
and test folder have permissions set to 777, so it is hard to imagine
why the code isn't working.

<?php

function fileUpdate() {
// 12-08-04 - we want to make it easy for people to customize their
own installations of
// the software, so want to make it easy for them to edit those
arrangements that make up
// the control panel.
$controllerForA ll = & getController() ;
$resultsObject = & $controllerForA ll->getObject("McR esults", " in the
function fileUpdate().") ;

// 12-08-04 - since PHP will cache file info, we need to clear the
cache if we are doing multiple
// things which might cause a "true" result to become "false" or vice
versa.
clearstatcache( );

$formInputs = $GLOBALS["formInputs "];

if (is_array($form Inputs)) {
extract($formIn puts);

// 04-05-04 - we need to trim white space off the ends of these, and
neutralize any dangerous code
// that hackers have tried to slip in.
$fileName = trim($fileName) ;
$fileContent = trim($fileConte nt);
$fileNameOld = trim($fileNameO ld);
$fileContentOld = trim($fileConte ntOld);
$fileName = htmlspecialchar s($fileName);
$fileNameOld = htmlspecialchar s($fileNameOld) ;
// 04-05-04 - an easy hacker attack would be to overwrite much needed
files, outside the correct directory.
// Therefore we need to take control of what directory is being
written to.
$fileNameRecord = $fileName;
$len = strlen($fileNam e);
$char = "";
$count = 0;
// 12-08-04 - this next bit is too clever. Basically, we expect the
file name at this point to look
// like this:
//
// ppArrangementsA dmin/editweblogPages Form.php
//
// We want to strip off the "ppArrangements Admin/" part. So we walk
through till we get to
// the first "/". Then we take the rest of the filename and proceed.
If there is still a "/"
// in the filename after this, we can assume some hacker was trying
to make some kind of
// attack, and so we'll throw an error.
while ($count < $len && $char != "/") {
$char = substr($fileNam e, 0, 1);
$fileName = substr($fileNam e, 1);
$count++;
}
$location = strpos($fileNam e, "/");
if (is_numeric($lo cation)) {
$resultsObject->addToResults(" We were unable to update this file.
The file name is invalid. It should not contain more than one '/'
(forward slash). This is what we got: $fileNameRecord . Problem in
fileUpdate()", "fileUpdate ");
} else {
$config = getConfig();
$pathToNeededFi les = $config["pathToNeededFi les"];

$formData = $GLOBALS["formData"];
$fileType = $formData["fileType"];
if ($fileType == "public") {
$fileName = "ppArrangements Public/".$fileName ;
} else {
$fileName = "ppArrangements Admin/".$fileName ;
}

$fileName = $pathToNeededFi les.$fileName;
if (file_exists($f ileName)) {
$perm = fileperms($file Name);

$fileNameBackup = str_replace("/", "/backup_", $fileNameOld);
$fp = fopen($fileName Backup, "w+");

if ($fp) {
$fileContentOld = stripslashes($f ileContentOld);
$success = fwrite($fp, $fileContentOld );
$isClosed = fclose($fp);

if ($success) {
$resultsObject->addToResults(" We created a back up of your file
and gave it the name $fileNameBackup . If you need to restore the old
version, go back to that file.");

$fp = fopen($fileName , "w+");
$fileContent = stripslashes($f ileContent);
$success2 = fwrite($fp, $fileContent);
fclose($fp);

if ($success2) {
$resultsObject->addToResults(" We successfully saved the
$fileName document.");
} else {
$fileContent = htmlspecialchar s($fileContent) ;
$resultsObject->addToResults(" In fileUpdate, something went
wrong and we were unable to save the document called ' $fileName '. The
file permissions were set to '$perm'. You'd written: $fileContent ");
}
} else {
$fileContent = stripslashes($f ileContent);
$fileContent = htmlspecialchar s($fileContent) ;
$resultsObject->addToResults(" In fileUpdate(), we tried to create
a back up of your file and give it the name $fileNameBackup , but we
failed. The file permissions were set to '$perm'. Because of the risk
of overwriting your only copy, we have not tried to update the file.
Here is what you'd written: $fileContent");
}
} else {
$resultsObject->error("In fileUpdate(), we wanted to open the file
'$fileName' so we could edit it, but we were not able to open it. It's
permissions were set to '$perm'", "fileUpdate ");
}
} else {
$resultsObject->error("In fileUpdate(), we wanted to open the file
'$fileName' but it does not exist.", "fileUpdate ");
}
}
} else {
$resultsObject->error("In fileUpdate, we assumed we were going to be
given a set of data called formInputs, but for some reason we got no
such thing.", "fileUpdate ");
}
}


?>

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
24129
by: Bill | last post by:
I used to be able to run the following ASP code on our corp machine (W2K Server Edition and IIS-5) and successfully send a net-msg to anyone on our intranet. Last week it stopped working... and I'm not sure what changed. (I had applied ALL the W2K update patches... but... I'm not sure if the problem started before or after that.) Did any...
12
2858
by: Jean-Marc Blaise | last post by:
Hi Folks, I'm getting this message with the XML tutorial: getstart_exportXML.cmd file: SQL0444N Routine "DB2XML.CONTENT" (specific name "DB2XMLCONTENTVF") is implemented with code in library or path "\db2xmlfn", function "dxxContent_varchar2file" which cannot be accessed. Reason code: "4". SQLSTATE=42724 DB20000I The TERMINATE command...
23
5076
by: deathtospam | last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using Visual Studio .NET 2005 -- it worked, I saved it and closed the project. Today, I came back to the project, reopened the solution, and was greeted with the following error: ======================================================================== It is an error to use a...
9
6241
by: =?Utf-8?B?QW1tZXI=?= | last post by:
I've read many incomplete opinions about the "Best Practice" for securely accessing SQL but what I really need to find the "Best Practice" that fits my applications needs. Currently (alpha stage) I am Using a .Net DSN-Less SQLConnection method in my client program (vb.net) and sending uid/pwd across the network. The client only calls upon...
16
9206
by: lawrence k | last post by:
I've never before written a PHP script to run on my home Ubuntu machine (though I've written dozens of PHP cron jobs for my web server), so I thought I'd start off with a very simple test: #!/usr/share/php5 <?php echo "hello"; ?>
0
7882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1410
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.