Merge remote branch 'davrieb/autotag' into autotag
[ikiwiki.git] / doc / tips / inside_dot_ikiwiki / discussion.mdwn
1 My database appears corrupted:
2
3     $ perl -le 'use Storable; my $index=Storable::retrieve("indexdb"); use Data::Dumper; print Dumper $index'
4     Out of memory!
5
6 No idea how this happened.  I've blown it away and recreated it but, for future reference, is there any less violent way to recover from this situation?  I miss having the correct created and last edited times.  --[[sabr]]
7 > update: fixed ctimes and mtimes using [these instructions](http://u32.net/Mediawiki_Conversion/Git_Import/#Correct%20Creation%20and%20Last%20Edited%20time) --[[sabr]]
8
9 > That's overly complex. Just run `ikiwiki -setup your.setup -gettime`. 
10 > BTW, I'd be interested in examining such a corrupt storable file to try
11 > to see what happened to it. --[[Joey]]
12
13 >> --gettime appears to only set the last edited date.  It's not supposed to set the creation date, is it?  The only place that info is stored is in the git repo.
14
15 >>> Pulling the page creation date out of the git history is exactly what
16 >>> --gettime does. (It used to be called --getctime, and only do that; now
17 >>> it also pulls out the last modified date). --[[Joey]]
18
19 >> Alas, I seem to have lost the bad index file to periodic /tmp wiping; I'll send it to you if it happens again.  --[[sabr]]
20
21 <!-- Add by Blanko -->
22
23 ## Lost password for an user
24
25 This morning, a person has lost its password. I was able to do something to make another password. This is the way I take : 
26
27 > You can certianly do that, but do note that ikiwiki will offer to mail a
28 > user a password reset link if they lost their password. --[[Joey]]
29
30 ### Locate the user database
31
32 As tips show us, the user database is in the source file, for an example : 
33
34     src/.ikiwiki/userdb
35
36 ### See which user to modify
37
38 Because I don't know the real login of the user, I have to read all the database : 
39
40     perl -le 'use Storable; my $index=Storable::retrieve("userdb"); use Data::Dumper; print Dumper $index'
41
42 Then I was able to find this : 
43
44     'Utilisateur' => {
45                  'email' => 'user@pl.fr',
46                  'cryptresettoken' => '$2a$10$cfVeOoVbFw9VzMlgEbPMsu34pwHIFP84mWlkrs2RCKknZYPZkPffm',
47                  'password' => '',
48                  'resettoken' => '',
49                  'cryptpassword' => '$2a$10$H8bYq.dlb68wpnfJgVZQhOdsF9JQ06cteRfhPQPB5eHKnD5Y3u7au',
50                  'regdate' => '1226574052'
51                },
52
53 Let's have a look to modify lines.
54
55 ### Modify the line
56
57 When you have found the line to modify, take the user name, and change its password to **sc** (for an example) :
58
59     perl -le 'use Storable; my $userinfo=Storable::retrieve("userdb"); $userinfo->{"Utilisateur"}->{cryptpassword}=q{$2a$10$7viOHCrUkdAVL135Kr6one1mpZQ/FWYC773G1yZ0EtQciI11sSDRS}; Storable::lock_nstore($userinfo, "userdb")'
60     perl -le 'use Storable; my $userinfo=Storable::retrieve("userdb"); $userinfo->{"Utilisateur"}->{cryptresettoken}=q{}; Storable::lock_nstore($userinfo, "userdb")'
61
62 Because I don't know how suppress cryptresettoken and resettoken fields, I change their content with *null*.
63
64 After all these modifications, the user *Utilisateur* could connect to its account with the password **sc**, and go to Preferences, then change its password.
65
66 <!-- End of Blanko's modifications -->