On Tuesday 19 September 2006 22:22, Rahul S. Johari wrote: > Ok, my code follows. Basically I'm printing ... > my Owner/Group, the existing Owner/Group of the file, the Owner/Group of > the file After trying to change it. Does apache have write access to write to yer file, that goes for either o+r or that group or user is apache. > > The most interesting thing is... I get absolutely no errors, no warnings, > and everything prints out as if everything worked... Except that its' not > actually changing anything at all!! > > The fact that it's not changing anything is a secondary issue... What > surprises me is that chown,chgrp or chmod doesn't give any error or warning > for the fact that it's not doing anything. Except the is_writeable() which > actually prints "Is not writeable".... The if(chown) etcetera continue > printing as if they changed the Owner/Group/Perms.... Even though they > didn't. > > code: > > if (!is_writable("/home/folder/documents/path/osmd.dbf")) { > echo "Is not writeable<BR><BR>"; > } > > $fileowneruidb=fileowner("/home/folder/documents/path/osmd.dbf"); > echo $fileowneruidb; > $fileownerarrayb=posix_getpwuid($fileowneruidb); > $fileownerb=$fileownerarrayb['name']; > echo "<BR>Owner is $fileownerb<BR><BR>"; > > echo "My owner :".getmyuid()."<BR>"; > if(chown("/home/folder/documents/path/osmd.dbf", getmyuid())) { > $fileowneruida=fileowner("/home/folder/documents/path/osmd.dbf"); > echo $fileowneruida; > $fileownerarraya=posix_getpwuid($fileowneruida); > $fileownera=$fileownerarraya['name']; > echo "<BR>Owner changed to $fileownera<BR><BR>"; > } > > $filegrpb=filegroup("/home/folder/documents/path/osmd.dbf"); > echo $filegrpb; > $filegrparrayb=posix_getgrgid($filegrpb); > $filegrpb=$filegrparrayb['name']; > echo "<BR>Group is $filegrpb<BR><BR>"; > > echo "My owner :".getmygid()."<BR>"; > if(chgrp("/home/folder/documents/path/osmd.dbf", getmygid())) { > $filegrpa=filegroup("/home/folder/documents/path/osmd.dbf"); > echo $filegrpa; > $filegrparraya=posix_getgrgid($filegrpa); > $filegrpa=$filegrparraya['name']; > echo "<BR>Group changed to $filegrpa<BR><BR>"; > } > > if (chmod("/home/folder/documents/path/osmd.dbf", 0755)) { > echo "Mode changed to 0755<BR><BR>"; > } > > On 9/19/06 12:09 PM, "Steve Edberg" <sbedberg@xxxxxxxxxxx> wrote: > > fileperms() perhaps? > > > > http://php.he.net/manual/en/function.fileperms.php > > > > You'd have to compare the return value against the uid/gid the > > webserver runs as, which can be obtained via getmyuid()/getmygid(): > > > > http://php.he.net/manual/en/function.getmyuid.php > > > > Alternatively, you could check if the file exists, then attempt to > > chown/chgrp it. If the chown()/chgrp() returns false, you probably > > don't have permission. > > > > steve -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php