[pmwiki-users] UserAuth2 - flock does not release lock?

Frank fralewank at temporaryforwarding.com
Mon May 28 16:42:33 CDT 2007


Hi,

ThomasP wrote:
> If you say the "files are all empty" that indeed means that they exist at
> least (i.e. for each user added one file?). As UserAuth2 determines
> existence of the user from existence of the permission record file, that
> would be at least an explanation for the puzzle.

Yes they exists, but size is 0 bytes. After I added uer1 and group1 the
directory listing loos as follows:
/cookbook/userauth2
-rw-r--r--   1 500   18291 May 26 19:01 UserSessionVars.php
drwxr-xr-x   2 500       0 May 28 23:10 groupperms
drwxr-xr-x   2 500       0 May 28 23:10 ipranges
-rw-r--r--   1 500      10 May 28 23:10 lastPermUpdateTimestamp
drwxr-xr-x   2 500       0 May 28 23:10 profiles
drwxr-xr-x   2 500       0 May 28 23:10 session_data
-rw-r--r--   1 500   44577 May 26 19:01 userauth2-admintool.php
-rw-r--r--   1 500    5801 May 26 18:58 userauth2-pwchange.php
drwxr-xr-x   2 500       0 May 28 23:10 userperms

/cookbook/userauth2/groupperms:
-rw-r--r--   1 500       0 May 28 23:10 GuestUsers
-rw-r--r--   1 500       0 May 28 23:10 group1

/cookbook/userauth2/ipranges:

/cookbook/userauth2/profiles:
-rw-r--r--   1 500      29 May 28 23:10 admin

/cookbook/userauth2/session_data:
-rw-r--r--   1 500     898 May 28 23:10 sess_gboh8t6bh9chv45qpe8rss1as6

/cookbook/userauth2/userperms:
-rw-r--r--   1 500          0 May 28 23:10 user1

> New idea from the follwoing code piece:
> 
> function savePermRecord_($file, $record) {
>   $fp = @fopen($file, "w");
>   if ($fp && flock($fp, LOCK_EX)) {
>     fputs($fp, serialize($record) . "\n");
>     flock($fp, LOCK_UN);
>     fclose($fp);
>     return true;
>   }
>   return false;
> }
> 
> It might be that the pmwiki lock (another independent mechnism from the
> one mentioned before) cannot be obtained (would exactly leave an empty
> file). Try to remove the two flock(..) statements (in the if condition and
> the if statement block) (might be necessary also for loadPermRecord_(..))
> and let's see what happens. (This is not yet a final solution - better
> would be to find out why the flocks block.)
> 
> Thomas
> 
> See also:
> 
> http://www.php.net/manual/en/function.flock.php
> 
> saying that flock is mandatory (i.e. locks are enforced) under Windows.

YEAH, that's it
Now the user1 file contains the below things
a:3:{s:6:"parent";s:5:"admin";s:16:"loginFromIpsOnly";a:0:{}s:5:"perms";a:1:{s:5:"admin";a:0:{}}}

The error message is gone when adding a user. But if I call the
Edit-field in the admin dialog, it is empty.
I had a look to the error.log of Apache, that says:
-> PHP Warning:  join() [<a href='function.join'>function.join</a>]: Bad
arguments. in ApachePath\\cookbook\\userauth2\\userauth2-admintool.php
on line 892, referer: http://index.php/Main/Homepage?action=admin
-> PHP Warning:  Invalid argument supplied for foreach() in
ApachePath\\cookbook\\userauth2\\userauth2-admintool.php on line 893,
referer: http://index.php/Main/Homepage?action=admin
-> PHP Warning:  array_keys() [<a
href='function.array-keys'>function.array-keys</a>]: The first argument
should be an array in
ApachePath\\cookbook\\userauth2\\userauth2-admintool.php on line 819,
referer: http://index.php/Main/Homepage?action=admin
-> PHP Warning:  implode() [<a
href='function.implode'>function.implode</a>]: Bad arguments. in
ApachePath\\cookbook\\userauth2\\userauth2-admintool.php on line 819,
referer: http://index.php/Main/Homepage?action=admin

I also removed the flock() in loadPermRecord_, now also the stored data
are shown in the admin tool after clicking on Edit.

Thats it so far, hope it helps to find the bugs

Frank


btw I also tried to change the slashes, I changed the slashes into \ and
\\. The first version showed some funny behaviour, the second worked the
same wrong way as before.
I think people familiar to PHP on windows can explain, I've not
knowledge of PHP.
I also moved the directory from cookbook to wiki.d, where definitely
files can be written, but that had no effect.



More information about the pmwiki-users mailing list