[pmwiki-users] UserAuth2 - flock does not release lock? (was: UserAuth2 - missing permissions?)

ThomasP pmwikidev at sigproc.de
Mon May 28 05:04:14 CDT 2007


Hello again,

On Mon, May 28, 2007 00:47, Frank wrote:
> After entering the permision items in the box 'Permissions granted by' I
> get the following report
>
> "UserAuth II Administration
> Settings could not be saved. Please contact the system administrator.
> Back to UserAuth main page."
>
> The same happens if I add a user. There I get the error message
> "Settings could not be saved. Please contact the system administrator.".
> But the new user is nevertheless visible in the admin table afterwards.
> The files used for storing the data in the cookbook\userauth2\ are all
> empty.
>
> Any idea?
>
> My configuration: Win98/Apache2.2.4/php 5.2.1
> /pmWiki2.2.0-beta50/UserAuth2 2.0-stable5 (2007-05-26)
>

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.

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.





More information about the pmwiki-users mailing list