0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20 /*.** Copyright
0010: 28 63 29 20 32 30 30 36 20 44 2e 20 52 69 63 68 (c) 2006 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54 ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66 his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75 u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20 te it and/or.**
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20 modify it under
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65 the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76 lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65 ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 tributed in the
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20 l be useful,.**
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 but WITHOUT ANY
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20 RPOSE. See the
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50 GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20 d have received
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72 g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69 ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65 te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20 ation, Inc., 59
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53 Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73 uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31 ton, MA 02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20 307, USA..**.**
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69 Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20 nformation:.**
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68 * http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0360: 0a 2a 2a 0a 2a 2a 20 43 6f 6d 6d 61 6e 64 73 20 .**.** Commands
0370: 61 6e 64 20 70 72 6f 63 65 64 75 72 65 73 20 75 and procedures u
0380: 73 65 64 20 66 6f 72 20 63 72 65 61 74 69 6e 67 sed for creating
0390: 2c 20 70 72 6f 63 65 73 73 69 6e 67 2c 20 65 64 , processing, ed
03a0: 69 74 69 6e 67 2c 20 61 6e 64 0a 2a 2a 20 71 75 iting, and.** qu
03b0: 65 72 79 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 erying informati
03c0: 6f 6e 20 61 62 6f 75 74 20 75 73 65 72 73 2e 0a on about users..
03d0: 2a 2f 0a 23 69 6e 63 6c 75 64 65 20 22 63 6f 6e */.#include "con
03e0: 66 69 67 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 fig.h".#include
03f0: 22 75 73 65 72 2e 68 22 0a 0a 0a 2f 2a 0a 2a 2a "user.h".../*.**
0400: 20 53 74 72 69 70 20 6c 65 61 64 69 6e 67 20 61 Strip leading a
0410: 6e 64 20 74 72 61 69 6c 69 6e 67 20 73 70 61 63 nd trailing spac
0420: 65 20 66 72 6f 6d 20 61 20 73 74 72 69 6e 67 20 e from a string
0430: 61 6e 64 20 61 64 64 20 74 68 65 20 73 74 72 69 and add the stri
0440: 6e 67 0a 2a 2a 20 6f 6e 74 6f 20 74 68 65 20 65 ng.** onto the e
0450: 6e 64 20 6f 66 20 61 20 62 6c 6f 62 2e 0a 2a 2f nd of a blob..*/
0460: 0a 73 74 61 74 69 63 20 76 6f 69 64 20 73 74 72 .static void str
0470: 69 70 5f 73 74 72 69 6e 67 28 42 6c 6f 62 20 2a ip_string(Blob *
0480: 70 42 6c 6f 62 2c 20 63 68 61 72 20 2a 7a 29 7b pBlob, char *z){
0490: 0a 20 20 69 6e 74 20 69 3b 0a 20 20 62 6c 6f 62 . int i;. blob
04a0: 5f 72 65 73 65 74 28 70 42 6c 6f 62 29 3b 0a 20 _reset(pBlob);.
04b0: 20 77 68 69 6c 65 28 20 69 73 73 70 61 63 65 28 while( isspace(
04c0: 2a 7a 29 20 29 7b 20 7a 2b 2b 3b 20 7d 0a 20 20 *z) ){ z++; }.
04d0: 66 6f 72 28 69 3d 30 3b 20 7a 5b 69 5d 3b 20 69 for(i=0; z[i]; i
04e0: 2b 2b 29 7b 0a 20 20 20 20 69 66 28 20 7a 5b 69 ++){. if( z[i
04f0: 5d 3d 3d 27 5c 72 27 20 7c 7c 20 7a 5b 69 5d 3d ]=='\r' || z[i]=
0500: 3d 27 5c 6e 27 20 29 7b 0a 20 20 20 20 20 20 20 ='\n' ){.
0510: 77 68 69 6c 65 28 20 69 3e 30 20 26 26 20 69 73 while( i>0 && is
0520: 73 70 61 63 65 28 7a 5b 69 2d 31 5d 29 20 29 7b space(z[i-1]) ){
0530: 20 69 2d 2d 3b 20 7d 0a 20 20 20 20 20 20 20 7a i--; }. z
0540: 5b 69 5d 20 3d 20 30 3b 0a 20 20 20 20 20 20 20 [i] = 0;.
0550: 62 72 65 61 6b 3b 0a 20 20 20 20 7d 0a 20 20 20 break;. }.
0560: 20 69 66 28 20 7a 5b 69 5d 3c 27 20 27 20 29 20 if( z[i]<' ' )
0570: 7a 5b 69 5d 20 3d 20 27 20 27 3b 0a 20 20 7d 0a z[i] = ' ';. }.
0580: 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 28 70 42 blob_append(pB
0590: 6c 6f 62 2c 20 7a 2c 20 2d 31 29 3b 0a 7d 0a 0a lob, z, -1);.}..
05a0: 2f 2a 0a 2a 2a 20 44 6f 20 61 20 73 69 6e 67 6c /*.** Do a singl
05b0: 65 20 70 72 6f 6d 70 74 20 66 6f 72 20 61 20 70 e prompt for a p
05c0: 61 73 73 70 68 72 61 73 65 2e 20 20 53 74 6f 72 assphrase. Stor
05d0: 65 20 74 68 65 20 72 65 73 75 6c 74 73 20 69 6e e the results in
05e0: 20 74 68 65 20 62 6c 6f 62 2e 0a 2a 2f 0a 73 74 the blob..*/.st
05f0: 61 74 69 63 20 76 6f 69 64 20 70 72 6f 6d 70 74 atic void prompt
0600: 5f 66 6f 72 5f 70 61 73 73 70 68 72 61 73 65 28 _for_passphrase(
0610: 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 50 72 6f const char *zPro
0620: 6d 70 74 2c 20 42 6c 6f 62 20 2a 70 50 61 73 73 mpt, Blob *pPass
0630: 70 68 72 61 73 65 29 7b 0a 20 20 63 68 61 72 20 phrase){. char
0640: 2a 7a 20 3d 20 67 65 74 70 61 73 73 28 7a 50 72 *z = getpass(zPr
0650: 6f 6d 70 74 29 3b 0a 20 20 73 74 72 69 70 5f 73 ompt);. strip_s
0660: 74 72 69 6e 67 28 70 50 61 73 73 70 68 72 61 73 tring(pPassphras
0670: 65 2c 20 7a 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 e, z);.}../*.**
0680: 50 72 6f 6d 70 74 20 74 68 65 20 75 73 65 72 20 Prompt the user
0690: 66 6f 72 20 61 20 70 61 73 73 77 6f 72 64 2e 20 for a password.
06a0: 20 53 74 6f 72 65 20 74 68 65 20 72 65 73 75 6c Store the resul
06b0: 74 20 69 6e 20 74 68 65 20 70 50 61 73 73 70 68 t in the pPassph
06c0: 72 61 73 65 0a 2a 2a 20 62 6c 6f 62 2e 0a 2a 2a rase.** blob..**
06d0: 0a 2a 2a 20 42 65 68 61 76 69 6f 72 20 69 73 20 .** Behavior is
06e0: 63 6f 6e 74 72 6f 6c 6c 65 64 20 62 79 20 74 68 controlled by th
06f0: 65 20 76 65 72 69 66 79 20 70 61 72 61 6d 65 74 e verify paramet
0700: 65 72 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 20 30 20 er:.**.** 0
0710: 20 20 20 20 4a 75 73 74 20 61 73 6b 20 6f 6e 63 Just ask onc
0720: 65 2e 0a 2a 2a 0a 2a 2a 20 20 20 20 20 31 20 20 e..**.** 1
0730: 20 20 20 49 66 20 74 68 65 20 66 69 72 73 74 20 If the first
0740: 61 6e 73 77 65 72 20 69 73 20 61 20 6e 6f 6e 2d answer is a non-
0750: 65 6d 70 74 79 20 73 74 72 69 6e 67 2c 20 61 73 empty string, as
0760: 6b 20 66 6f 72 0a 2a 2a 20 20 20 20 20 20 20 20 k for.**
0770: 20 20 20 76 65 72 69 66 69 63 61 74 69 6f 6e 2e verification.
0780: 20 20 52 65 70 65 61 74 20 69 66 20 74 68 65 20 Repeat if the
0790: 74 77 6f 20 73 74 72 69 6e 67 73 20 64 6f 20 6e two strings do n
07a0: 6f 74 20 6d 61 74 63 68 2e 0a 2a 2a 0a 2a 2a 20 ot match..**.**
07b0: 20 20 20 20 32 20 20 20 20 20 41 73 6b 20 74 77 2 Ask tw
07c0: 69 63 65 2c 20 72 65 70 65 61 74 20 69 66 20 74 ice, repeat if t
07d0: 68 65 20 73 74 72 69 6e 67 73 20 64 6f 20 6e 6f he strings do no
07e0: 74 20 6d 61 74 63 68 2e 0a 2a 2f 0a 76 6f 69 64 t match..*/.void
07f0: 20 70 72 6f 6d 70 74 5f 66 6f 72 5f 70 61 73 73 prompt_for_pass
0800: 77 6f 72 64 28 0a 20 20 63 6f 6e 73 74 20 63 68 word(. const ch
0810: 61 72 20 2a 7a 50 72 6f 6d 70 74 2c 0a 20 20 42 ar *zPrompt,. B
0820: 6c 6f 62 20 2a 70 50 61 73 73 70 68 72 61 73 65 lob *pPassphrase
0830: 2c 0a 20 20 69 6e 74 20 76 65 72 69 66 79 0a 29 ,. int verify.)
0840: 7b 0a 20 20 42 6c 6f 62 20 73 65 63 6f 6e 64 54 {. Blob secondT
0850: 72 79 3b 0a 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 ry;. blob_zero(
0860: 70 50 61 73 73 70 68 72 61 73 65 29 3b 0a 20 20 pPassphrase);.
0870: 62 6c 6f 62 5f 7a 65 72 6f 28 26 73 65 63 6f 6e blob_zero(&secon
0880: 64 54 72 79 29 3b 0a 20 20 77 68 69 6c 65 28 31 dTry);. while(1
0890: 29 7b 0a 20 20 20 20 70 72 6f 6d 70 74 5f 66 6f ){. prompt_fo
08a0: 72 5f 70 61 73 73 70 68 72 61 73 65 28 7a 50 72 r_passphrase(zPr
08b0: 6f 6d 70 74 2c 20 70 50 61 73 73 70 68 72 61 73 ompt, pPassphras
08c0: 65 29 3b 0a 20 20 20 20 69 66 28 20 76 65 72 69 e);. if( veri
08d0: 66 79 3d 3d 30 20 29 20 62 72 65 61 6b 3b 0a 20 fy==0 ) break;.
08e0: 20 20 20 69 66 28 20 76 65 72 69 66 79 3d 3d 31 if( verify==1
08f0: 20 26 26 20 62 6c 6f 62 5f 73 69 7a 65 28 70 50 && blob_size(pP
0900: 61 73 73 70 68 72 61 73 65 29 3d 3d 30 20 29 20 assphrase)==0 )
0910: 62 72 65 61 6b 3b 0a 20 20 20 20 70 72 6f 6d 70 break;. promp
0920: 74 5f 66 6f 72 5f 70 61 73 73 70 68 72 61 73 65 t_for_passphrase
0930: 28 22 41 67 61 69 6e 3a 20 22 2c 20 26 73 65 63 ("Again: ", &sec
0940: 6f 6e 64 54 72 79 29 3b 0a 20 20 20 20 69 66 28 ondTry);. if(
0950: 20 62 6c 6f 62 5f 63 6f 6d 70 61 72 65 28 70 50 blob_compare(pP
0960: 61 73 73 70 68 72 61 73 65 2c 20 26 73 65 63 6f assphrase, &seco
0970: 6e 64 54 72 79 29 20 29 7b 0a 20 20 20 20 20 20 ndTry) ){.
0980: 70 72 69 6e 74 66 28 22 50 61 73 73 70 68 72 61 printf("Passphra
0990: 73 65 73 20 64 6f 20 6e 6f 74 20 6d 61 74 63 68 ses do not match
09a0: 2e 20 20 54 72 79 20 61 67 61 69 6e 2e 2e 2e 5c . Try again...\
09b0: 6e 22 29 3b 0a 20 20 20 20 7d 65 6c 73 65 7b 0a n");. }else{.
09c0: 20 20 20 20 20 20 62 72 65 61 6b 3b 0a 20 20 20 break;.
09d0: 20 7d 0a 20 20 7d 0a 20 20 62 6c 6f 62 5f 72 65 }. }. blob_re
09e0: 73 65 74 28 26 73 65 63 6f 6e 64 54 72 79 29 3b set(&secondTry);
09f0: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 50 72 6f 6d 70 74 .}../*.** Prompt
0a00: 20 74 68 65 20 75 73 65 72 20 74 6f 20 65 6e 74 the user to ent
0a10: 65 72 20 61 20 73 69 6e 67 6c 65 20 6c 69 6e 65 er a single line
0a20: 20 6f 66 20 74 65 78 74 2e 0a 2a 2f 0a 76 6f 69 of text..*/.voi
0a30: 64 20 70 72 6f 6d 70 74 5f 75 73 65 72 28 63 6f d prompt_user(co
0a40: 6e 73 74 20 63 68 61 72 20 2a 7a 50 72 6f 6d 70 nst char *zPromp
0a50: 74 2c 20 42 6c 6f 62 20 2a 70 49 6e 29 7b 0a 20 t, Blob *pIn){.
0a60: 20 63 68 61 72 20 2a 7a 3b 0a 20 20 63 68 61 72 char *z;. char
0a70: 20 7a 4c 69 6e 65 5b 31 30 30 30 5d 3b 0a 20 20 zLine[1000];.
0a80: 62 6c 6f 62 5f 7a 65 72 6f 28 70 49 6e 29 3b 0a blob_zero(pIn);.
0a90: 20 20 70 72 69 6e 74 66 28 22 25 73 22 2c 20 7a printf("%s", z
0aa0: 50 72 6f 6d 70 74 29 3b 0a 20 20 66 66 6c 75 73 Prompt);. fflus
0ab0: 68 28 73 74 64 6f 75 74 29 3b 0a 20 20 7a 20 3d h(stdout);. z =
0ac0: 20 66 67 65 74 73 28 7a 4c 69 6e 65 2c 20 73 69 fgets(zLine, si
0ad0: 7a 65 6f 66 28 7a 4c 69 6e 65 29 2c 20 73 74 64 zeof(zLine), std
0ae0: 69 6e 29 3b 0a 20 20 69 66 28 20 7a 20 29 7b 0a in);. if( z ){.
0af0: 20 20 20 20 73 74 72 69 70 5f 73 74 72 69 6e 67 strip_string
0b00: 28 70 49 6e 2c 20 7a 29 3b 0a 20 20 7d 0a 7d 0a (pIn, z);. }.}.
0b10: 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 3a ../*.** COMMAND:
0b20: 20 20 75 73 65 72 0a 2a 2a 0a 2a 2a 20 44 69 73 user.**.** Dis
0b30: 70 61 74 63 68 65 72 20 66 6f 72 20 76 61 72 69 patcher for vari
0b40: 6f 75 73 20 75 73 65 72 20 73 75 62 63 6f 6d 6d ous user subcomm
0b50: 61 6e 64 73 2e 0a 2a 2f 0a 76 6f 69 64 20 75 73 ands..*/.void us
0b60: 65 72 5f 63 6d 64 28 76 6f 69 64 29 7b 0a 20 20 er_cmd(void){.
0b70: 69 6e 74 20 6e 3b 0a 20 20 64 62 5f 66 69 6e 64 int n;. db_find
0b80: 5f 61 6e 64 5f 6f 70 65 6e 5f 72 65 70 6f 73 69 _and_open_reposi
0b90: 74 6f 72 79 28 29 3b 0a 20 20 69 66 28 20 67 2e tory();. if( g.
0ba0: 61 72 67 63 3c 33 20 29 7b 0a 20 20 20 20 75 73 argc<3 ){. us
0bb0: 61 67 65 28 22 63 61 70 61 62 69 6c 69 74 69 65 age("capabilitie
0bc0: 73 7c 64 65 66 61 75 6c 74 7c 6c 69 73 74 7c 6e s|default|list|n
0bd0: 65 77 7c 70 61 73 73 77 6f 72 64 20 2e 2e 2e 22 ew|password ..."
0be0: 29 3b 0a 20 20 7d 0a 20 20 6e 20 3d 20 73 74 72 );. }. n = str
0bf0: 6c 65 6e 28 67 2e 61 72 67 76 5b 32 5d 29 3b 0a len(g.argv[2]);.
0c00: 20 20 69 66 28 20 6e 3e 3d 32 20 26 26 20 73 74 if( n>=2 && st
0c10: 72 6e 63 6d 70 28 67 2e 61 72 67 76 5b 32 5d 2c rncmp(g.argv[2],
0c20: 22 6e 65 77 22 2c 6e 29 3d 3d 30 20 29 7b 0a 20 "new",n)==0 ){.
0c30: 20 20 20 42 6c 6f 62 20 70 61 73 73 77 64 2c 20 Blob passwd,
0c40: 6c 6f 67 69 6e 2c 20 63 6f 6e 74 61 63 74 3b 0a login, contact;.
0c50: 0a 20 20 20 20 70 72 6f 6d 70 74 5f 75 73 65 72 . prompt_user
0c60: 28 22 6c 6f 67 69 6e 3a 20 22 2c 20 26 6c 6f 67 ("login: ", &log
0c70: 69 6e 29 3b 0a 20 20 20 20 70 72 6f 6d 70 74 5f in);. prompt_
0c80: 75 73 65 72 28 22 63 6f 6e 74 61 63 74 2d 69 6e user("contact-in
0c90: 66 6f 3a 20 22 2c 20 26 63 6f 6e 74 61 63 74 29 fo: ", &contact)
0ca0: 3b 0a 20 20 20 20 70 72 6f 6d 70 74 5f 66 6f 72 ;. prompt_for
0cb0: 5f 70 61 73 73 77 6f 72 64 28 22 70 61 73 73 77 _password("passw
0cc0: 6f 72 64 3a 20 22 2c 20 26 70 61 73 73 77 64 2c ord: ", &passwd,
0cd0: 20 31 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 1);. db_mult
0ce0: 69 5f 65 78 65 63 28 0a 20 20 20 20 20 20 22 49 i_exec(. "I
0cf0: 4e 53 45 52 54 20 49 4e 54 4f 20 75 73 65 72 28 NSERT INTO user(
0d00: 6c 6f 67 69 6e 2c 70 77 2c 63 61 70 2c 69 6e 66 login,pw,cap,inf
0d10: 6f 29 22 0a 20 20 20 20 20 20 22 56 41 4c 55 45 o)". "VALUE
0d20: 53 28 25 42 2c 25 42 2c 27 6a 6e 6f 72 27 2c 25 S(%B,%B,'jnor',%
0d30: 42 29 22 2c 0a 20 20 20 20 20 20 26 6c 6f 67 69 B)",. &logi
0d40: 6e 2c 20 26 70 61 73 73 77 64 2c 20 26 63 6f 6e n, &passwd, &con
0d50: 74 61 63 74 0a 20 20 20 20 29 3b 0a 20 20 7d 65 tact. );. }e
0d60: 6c 73 65 20 69 66 28 20 6e 3e 3d 32 20 26 26 20 lse if( n>=2 &&
0d70: 73 74 72 6e 63 6d 70 28 67 2e 61 72 67 76 5b 32 strncmp(g.argv[2
0d80: 5d 2c 22 64 65 66 61 75 6c 74 22 2c 6e 29 3d 3d ],"default",n)==
0d90: 30 20 29 7b 0a 20 20 20 20 75 73 65 72 5f 73 65 0 ){. user_se
0da0: 6c 65 63 74 28 29 3b 0a 20 20 20 20 69 66 28 20 lect();. if(
0db0: 67 2e 61 72 67 63 3d 3d 33 20 29 7b 0a 20 20 20 g.argc==3 ){.
0dc0: 20 20 20 70 72 69 6e 74 66 28 22 25 73 5c 6e 22 printf("%s\n"
0dd0: 2c 20 67 2e 7a 4c 6f 67 69 6e 29 3b 0a 20 20 20 , g.zLogin);.
0de0: 20 7d 65 6c 73 65 20 69 66 28 20 67 2e 6c 6f 63 }else if( g.loc
0df0: 61 6c 4f 70 65 6e 20 29 7b 0a 20 20 20 20 20 20 alOpen ){.
0e00: 64 62 5f 6c 73 65 74 28 22 64 65 66 61 75 6c 74 db_lset("default
0e10: 2d 75 73 65 72 22 2c 20 67 2e 7a 4c 6f 67 69 6e -user", g.zLogin
0e20: 29 3b 0a 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20 );. }else{.
0e30: 20 20 20 20 64 62 5f 73 65 74 28 22 64 65 66 61 db_set("defa
0e40: 75 6c 74 2d 75 73 65 72 22 2c 20 67 2e 7a 4c 6f ult-user", g.zLo
0e50: 67 69 6e 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 65 gin);. }. }e
0e60: 6c 73 65 20 69 66 28 20 6e 3e 3d 32 20 26 26 20 lse if( n>=2 &&
0e70: 73 74 72 6e 63 6d 70 28 67 2e 61 72 67 76 5b 32 strncmp(g.argv[2
0e80: 5d 2c 22 6c 69 73 74 22 2c 6e 29 3d 3d 30 20 29 ],"list",n)==0 )
0e90: 7b 0a 20 20 20 20 53 74 6d 74 20 71 3b 0a 20 20 {. Stmt q;.
0ea0: 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c db_prepare(&q,
0eb0: 20 22 53 45 4c 45 43 54 20 6c 6f 67 69 6e 2c 20 "SELECT login,
0ec0: 69 6e 66 6f 20 46 52 4f 4d 20 75 73 65 72 20 4f info FROM user O
0ed0: 52 44 45 52 20 42 59 20 6c 6f 67 69 6e 22 29 3b RDER BY login");
0ee0: 0a 20 20 20 20 77 68 69 6c 65 28 20 64 62 5f 73 . while( db_s
0ef0: 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f tep(&q)==SQLITE_
0f00: 52 4f 57 20 29 7b 0a 20 20 20 20 20 20 70 72 69 ROW ){. pri
0f10: 6e 74 66 28 22 25 2d 31 32 73 20 25 73 5c 6e 22 ntf("%-12s %s\n"
0f20: 2c 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 , db_column_text
0f30: 28 26 71 2c 20 30 29 2c 20 64 62 5f 63 6f 6c 75 (&q, 0), db_colu
0f40: 6d 6e 5f 74 65 78 74 28 26 71 2c 20 31 29 29 3b mn_text(&q, 1));
0f50: 0a 20 20 20 20 7d 0a 20 20 20 20 64 62 5f 66 69 . }. db_fi
0f60: 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20 7d 65 nalize(&q);. }e
0f70: 6c 73 65 20 69 66 28 20 6e 3e 3d 32 20 26 26 20 lse if( n>=2 &&
0f80: 73 74 72 6e 63 6d 70 28 67 2e 61 72 67 76 5b 32 strncmp(g.argv[2
0f90: 5d 2c 22 70 61 73 73 77 6f 72 64 22 2c 32 29 3d ],"password",2)=
0fa0: 3d 30 20 29 7b 0a 20 20 20 20 63 68 61 72 20 2a =0 ){. char *
0fb0: 7a 50 72 6f 6d 70 74 3b 0a 20 20 20 20 69 6e 74 zPrompt;. int
0fc0: 20 75 69 64 3b 0a 20 20 20 20 42 6c 6f 62 20 70 uid;. Blob p
0fd0: 77 3b 0a 20 20 20 20 69 66 28 20 67 2e 61 72 67 w;. if( g.arg
0fe0: 63 21 3d 34 20 29 20 75 73 61 67 65 28 22 75 73 c!=4 ) usage("us
0ff0: 65 72 20 70 61 73 73 77 6f 72 64 20 55 53 45 52 er password USER
1000: 4e 41 4d 45 22 29 3b 0a 20 20 20 20 75 69 64 20 NAME");. uid
1010: 3d 20 64 62 5f 69 6e 74 28 30 2c 20 22 53 45 4c = db_int(0, "SEL
1020: 45 43 54 20 75 69 64 20 46 52 4f 4d 20 75 73 65 ECT uid FROM use
1030: 72 20 57 48 45 52 45 20 6c 6f 67 69 6e 3d 25 51 r WHERE login=%Q
1040: 22 2c 20 67 2e 61 72 67 76 5b 33 5d 29 3b 0a 20 ", g.argv[3]);.
1050: 20 20 20 69 66 28 20 75 69 64 3d 3d 30 20 29 7b if( uid==0 ){
1060: 0a 20 20 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 . fossil_fa
1070: 74 61 6c 28 22 6e 6f 20 73 75 63 68 20 75 73 65 tal("no such use
1080: 72 3a 20 25 73 22 2c 20 67 2e 61 72 67 76 5b 33 r: %s", g.argv[3
1090: 5d 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 7a 50 ]);. }. zP
10a0: 72 6f 6d 70 74 20 3d 20 6d 70 72 69 6e 74 66 28 rompt = mprintf(
10b0: 22 6e 65 77 20 70 61 73 73 77 64 20 66 6f 72 20 "new passwd for
10c0: 25 73 3a 20 22 2c 20 67 2e 61 72 67 76 5b 33 5d %s: ", g.argv[3]
10d0: 29 3b 0a 20 20 20 20 70 72 6f 6d 70 74 5f 66 6f );. prompt_fo
10e0: 72 5f 70 61 73 73 77 6f 72 64 28 7a 50 72 6f 6d r_password(zProm
10f0: 70 74 2c 20 26 70 77 2c 20 31 29 3b 0a 20 20 20 pt, &pw, 1);.
1100: 20 69 66 28 20 62 6c 6f 62 5f 73 69 7a 65 28 26 if( blob_size(&
1110: 70 77 29 3d 3d 30 20 29 7b 0a 20 20 20 20 20 20 pw)==0 ){.
1120: 70 72 69 6e 74 66 28 22 70 61 73 73 77 6f 72 64 printf("password
1130: 20 75 6e 63 68 61 6e 67 65 64 5c 6e 22 29 3b 0a unchanged\n");.
1140: 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 }else{.
1150: 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 22 db_multi_exec("
1160: 55 50 44 41 54 45 20 75 73 65 72 20 53 45 54 20 UPDATE user SET
1170: 70 77 3d 25 42 20 57 48 45 52 45 20 75 69 64 3d pw=%B WHERE uid=
1180: 25 64 22 2c 20 26 70 77 2c 20 75 69 64 29 3b 0a %d", &pw, uid);.
1190: 20 20 20 20 7d 0a 20 20 7d 65 6c 73 65 20 69 66 }. }else if
11a0: 28 20 6e 3e 3d 32 20 26 26 20 73 74 72 6e 63 6d ( n>=2 && strncm
11b0: 70 28 67 2e 61 72 67 76 5b 32 5d 2c 22 63 61 70 p(g.argv[2],"cap
11c0: 61 62 69 6c 69 74 69 65 73 22 2c 32 29 3d 3d 30 abilities",2)==0
11d0: 20 29 7b 0a 20 20 20 20 69 6e 74 20 75 69 64 3b ){. int uid;
11e0: 0a 20 20 20 20 69 66 28 20 67 2e 61 72 67 63 21 . if( g.argc!
11f0: 3d 34 20 26 26 20 67 2e 61 72 67 63 21 3d 35 20 =4 && g.argc!=5
1200: 29 7b 0a 20 20 20 20 20 20 75 73 61 67 65 28 22 ){. usage("
1210: 75 73 65 72 20 63 61 70 61 62 69 6c 69 74 69 65 user capabilitie
1220: 73 20 55 53 45 52 4e 41 4d 45 20 3f 50 45 52 4d s USERNAME ?PERM
1230: 49 53 53 49 4f 4e 53 3f 22 29 3b 0a 20 20 20 20 ISSIONS?");.
1240: 7d 0a 20 20 20 20 75 69 64 20 3d 20 64 62 5f 69 }. uid = db_i
1250: 6e 74 28 30 2c 20 22 53 45 4c 45 43 54 20 75 69 nt(0, "SELECT ui
1260: 64 20 46 52 4f 4d 20 75 73 65 72 20 57 48 45 52 d FROM user WHER
1270: 45 20 6c 6f 67 69 6e 3d 25 51 22 2c 20 67 2e 61 E login=%Q", g.a
1280: 72 67 76 5b 33 5d 29 3b 0a 20 20 20 20 69 66 28 rgv[3]);. if(
1290: 20 75 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 20 uid==0 ){.
12a0: 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22 6e fossil_fatal("n
12b0: 6f 20 73 75 63 68 20 75 73 65 72 3a 20 25 73 22 o such user: %s"
12c0: 2c 20 67 2e 61 72 67 76 5b 33 5d 29 3b 0a 20 20 , g.argv[3]);.
12d0: 20 20 7d 0a 20 20 20 20 69 66 28 20 67 2e 61 72 }. if( g.ar
12e0: 67 63 3d 3d 35 20 29 7b 0a 20 20 20 20 20 20 64 gc==5 ){. d
12f0: 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 0a 20 20 b_multi_exec(.
1300: 20 20 20 20 20 20 22 55 50 44 41 54 45 20 75 73 "UPDATE us
1310: 65 72 20 53 45 54 20 63 61 70 3d 25 51 20 57 48 er SET cap=%Q WH
1320: 45 52 45 20 75 69 64 3d 25 64 22 2c 20 67 2e 61 ERE uid=%d", g.a
1330: 72 67 76 5b 34 5d 2c 0a 20 20 20 20 20 20 20 20 rgv[4],.
1340: 75 69 64 0a 20 20 20 20 20 20 29 3b 0a 20 20 20 uid. );.
1350: 20 7d 0a 20 20 20 20 70 72 69 6e 74 66 28 22 25 }. printf("%
1360: 73 5c 6e 22 2c 20 64 62 5f 74 65 78 74 28 30 2c s\n", db_text(0,
1370: 20 22 53 45 4c 45 43 54 20 63 61 70 20 46 52 4f "SELECT cap FRO
1380: 4d 20 75 73 65 72 20 57 48 45 52 45 20 75 69 64 M user WHERE uid
1390: 3d 25 64 22 2c 20 75 69 64 29 29 3b 0a 20 20 7d =%d", uid));. }
13a0: 65 6c 73 65 7b 0a 20 20 20 20 66 6f 73 73 69 6c else{. fossil
13b0: 5f 70 61 6e 69 63 28 22 75 73 65 72 20 73 75 62 _panic("user sub
13c0: 63 6f 6d 6d 61 6e 64 20 73 68 6f 75 6c 64 20 62 command should b
13d0: 65 20 6f 6e 65 20 6f 66 3a 20 22 0a 20 20 20 20 e one of: ".
13e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 63 61 "ca
13f0: 70 61 62 69 6c 69 74 69 65 73 20 64 65 66 61 75 pabilities defau
1400: 6c 74 20 6c 69 73 74 20 6e 65 77 20 70 61 73 73 lt list new pass
1410: 77 6f 72 64 22 29 3b 0a 20 20 7d 0a 7d 0a 0a 2f word");. }.}../
1420: 2a 0a 2a 2a 20 41 74 74 65 6d 70 74 20 74 6f 20 *.** Attempt to
1430: 73 65 74 20 74 68 65 20 75 73 65 72 20 74 6f 20 set the user to
1440: 7a 4c 6f 67 69 6e 0a 2a 2f 0a 73 74 61 74 69 63 zLogin.*/.static
1450: 20 69 6e 74 20 61 74 74 65 6d 70 74 5f 75 73 65 int attempt_use
1460: 72 28 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 4c r(const char *zL
1470: 6f 67 69 6e 29 7b 0a 20 20 69 6e 74 20 75 69 64 ogin){. int uid
1480: 3b 0a 0a 20 20 69 66 28 20 7a 4c 6f 67 69 6e 3d ;.. if( zLogin=
1490: 3d 30 20 29 7b 0a 20 20 20 20 72 65 74 75 72 6e =0 ){. return
14a0: 20 30 3b 0a 20 20 7d 0a 20 20 75 69 64 20 3d 20 0;. }. uid =
14b0: 64 62 5f 69 6e 74 28 30 2c 20 22 53 45 4c 45 43 db_int(0, "SELEC
14c0: 54 20 75 69 64 20 46 52 4f 4d 20 75 73 65 72 20 T uid FROM user
14d0: 57 48 45 52 45 20 6c 6f 67 69 6e 3d 25 51 22 2c WHERE login=%Q",
14e0: 20 7a 4c 6f 67 69 6e 29 3b 0a 20 20 69 66 28 20 zLogin);. if(
14f0: 75 69 64 20 29 7b 0a 20 20 20 20 67 2e 75 73 65 uid ){. g.use
1500: 72 55 69 64 20 3d 20 75 69 64 3b 0a 20 20 20 20 rUid = uid;.
1510: 67 2e 7a 4c 6f 67 69 6e 20 3d 20 6d 70 72 69 6e g.zLogin = mprin
1520: 74 66 28 22 25 73 22 2c 20 7a 4c 6f 67 69 6e 29 tf("%s", zLogin)
1530: 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 31 3b 0a ;. return 1;.
1540: 20 20 7d 0a 20 20 72 65 74 75 72 6e 20 30 3b 0a }. return 0;.
1550: 7d 0a 0a 2f 2a 0a 2a 2a 20 46 69 67 75 72 65 20 }../*.** Figure
1560: 6f 75 74 20 77 68 61 74 20 75 73 65 72 20 69 73 out what user is
1570: 20 61 74 20 74 68 65 20 63 6f 6e 74 72 6f 6c 73 at the controls
1580: 2e 0a 2a 2a 0a 2a 2a 20 20 20 28 31 29 20 20 55 ..**.** (1) U
1590: 73 65 20 74 68 65 20 2d 2d 75 73 65 72 20 61 6e se the --user an
15a0: 64 20 2d 55 20 63 6f 6d 6d 61 6e 64 2d 6c 69 6e d -U command-lin
15b0: 65 20 6f 70 74 69 6f 6e 73 2e 0a 2a 2a 0a 2a 2a e options..**.**
15c0: 20 20 20 28 32 29 20 20 49 66 20 74 68 65 20 6c (2) If the l
15d0: 6f 63 61 6c 20 64 61 74 61 62 61 73 65 20 69 73 ocal database is
15e0: 20 6f 70 65 6e 2c 20 63 68 65 63 6b 20 69 6e 20 open, check in
15f0: 56 56 41 52 2e 0a 2a 2a 0a 2a 2a 20 20 20 28 33 VVAR..**.** (3
1600: 29 20 20 43 68 65 63 6b 20 74 68 65 20 64 65 66 ) Check the def
1610: 61 75 6c 74 20 75 73 65 72 20 69 6e 20 74 68 65 ault user in the
1620: 20 72 65 70 6f 73 69 74 6f 72 79 0a 2a 2a 0a 2a repository.**.*
1630: 2a 20 20 20 28 34 29 20 20 54 72 79 20 74 68 65 * (4) Try the
1640: 20 55 53 45 52 20 65 6e 76 69 72 6f 6e 6d 65 6e USER environmen
1650: 74 20 76 61 72 69 61 62 6c 65 2e 0a 2a 2a 0a 2a t variable..**.*
1660: 2a 20 20 20 28 35 29 20 20 55 73 65 20 74 68 65 * (5) Use the
1670: 20 66 69 72 73 74 20 75 73 65 72 20 69 6e 20 74 first user in t
1680: 68 65 20 55 53 45 52 20 74 61 62 6c 65 2e 0a 2a he USER table..*
1690: 2a 0a 2a 2a 20 54 68 65 20 75 73 65 72 20 6e 61 *.** The user na
16a0: 6d 65 20 69 73 20 73 74 6f 72 65 64 20 69 6e 20 me is stored in
16b0: 67 2e 7a 4c 6f 67 69 6e 2e 20 20 54 68 65 20 75 g.zLogin. The u
16c0: 69 64 20 69 73 20 69 6e 20 67 2e 75 73 65 72 55 id is in g.userU
16d0: 69 64 2e 0a 2a 2f 0a 76 6f 69 64 20 75 73 65 72 id..*/.void user
16e0: 5f 73 65 6c 65 63 74 28 76 6f 69 64 29 7b 0a 20 _select(void){.
16f0: 20 53 74 6d 74 20 73 3b 0a 0a 20 20 69 66 28 20 Stmt s;.. if(
1700: 67 2e 75 73 65 72 55 69 64 20 29 20 72 65 74 75 g.userUid ) retu
1710: 72 6e 3b 0a 20 20 69 66 28 20 61 74 74 65 6d 70 rn;. if( attemp
1720: 74 5f 75 73 65 72 28 67 2e 7a 4c 6f 67 69 6e 29 t_user(g.zLogin)
1730: 20 29 20 72 65 74 75 72 6e 3b 0a 0a 20 20 69 66 ) return;.. if
1740: 28 20 67 2e 6c 6f 63 61 6c 4f 70 65 6e 20 26 26 ( g.localOpen &&
1750: 20 61 74 74 65 6d 70 74 5f 75 73 65 72 28 64 62 attempt_user(db
1760: 5f 6c 67 65 74 28 22 64 65 66 61 75 6c 74 2d 75 _lget("default-u
1770: 73 65 72 22 2c 30 29 29 20 29 20 72 65 74 75 72 ser",0)) ) retur
1780: 6e 3b 0a 0a 20 20 69 66 28 20 61 74 74 65 6d 70 n;.. if( attemp
1790: 74 5f 75 73 65 72 28 64 62 5f 67 65 74 28 22 64 t_user(db_get("d
17a0: 65 66 61 75 6c 74 2d 75 73 65 72 22 2c 20 30 29 efault-user", 0)
17b0: 29 20 29 20 72 65 74 75 72 6e 3b 0a 0a 20 20 69 ) ) return;.. i
17c0: 66 28 20 61 74 74 65 6d 70 74 5f 75 73 65 72 28 f( attempt_user(
17d0: 67 65 74 65 6e 76 28 22 55 53 45 52 22 29 29 20 getenv("USER"))
17e0: 29 20 72 65 74 75 72 6e 3b 0a 0a 20 20 64 62 5f ) return;.. db_
17f0: 70 72 65 70 61 72 65 28 26 73 2c 20 22 53 45 4c prepare(&s, "SEL
1800: 45 43 54 20 75 69 64 2c 20 6c 6f 67 69 6e 20 46 ECT uid, login F
1810: 52 4f 4d 20 75 73 65 72 20 57 48 45 52 45 20 6c ROM user WHERE l
1820: 6f 67 69 6e 3c 3e 27 61 6e 6f 6e 79 6d 6f 75 73 ogin<>'anonymous
1830: 27 22 29 3b 0a 20 20 69 66 28 20 64 62 5f 73 74 '");. if( db_st
1840: 65 70 28 26 73 29 3d 3d 53 51 4c 49 54 45 5f 52 ep(&s)==SQLITE_R
1850: 4f 57 20 29 7b 0a 20 20 20 20 67 2e 75 73 65 72 OW ){. g.user
1860: 55 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f Uid = db_column_
1870: 69 6e 74 28 26 73 2c 20 30 29 3b 0a 20 20 20 20 int(&s, 0);.
1880: 67 2e 7a 4c 6f 67 69 6e 20 3d 20 6d 70 72 69 6e g.zLogin = mprin
1890: 74 66 28 22 25 73 22 2c 20 64 62 5f 63 6f 6c 75 tf("%s", db_colu
18a0: 6d 6e 5f 74 65 78 74 28 26 73 2c 20 31 29 29 3b mn_text(&s, 1));
18b0: 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 . }. db_finali
18c0: 7a 65 28 26 73 29 3b 0a 0a 20 20 69 66 28 20 67 ze(&s);.. if( g
18d0: 2e 75 73 65 72 55 69 64 3d 3d 30 20 29 7b 0a 20 .userUid==0 ){.
18e0: 20 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 73 db_prepare(&s
18f0: 2c 20 22 53 45 4c 45 43 54 20 75 69 64 2c 20 6c , "SELECT uid, l
1900: 6f 67 69 6e 20 46 52 4f 4d 20 75 73 65 72 22 29 ogin FROM user")
1910: 3b 0a 20 20 20 20 69 66 28 20 64 62 5f 73 74 65 ;. if( db_ste
1920: 70 28 26 73 29 3d 3d 53 51 4c 49 54 45 5f 52 4f p(&s)==SQLITE_RO
1930: 57 20 29 7b 0a 20 20 20 20 20 20 67 2e 75 73 65 W ){. g.use
1940: 72 55 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e rUid = db_column
1950: 5f 69 6e 74 28 26 73 2c 20 30 29 3b 0a 20 20 20 _int(&s, 0);.
1960: 20 20 20 67 2e 7a 4c 6f 67 69 6e 20 3d 20 6d 70 g.zLogin = mp
1970: 72 69 6e 74 66 28 22 25 73 22 2c 20 64 62 5f 63 rintf("%s", db_c
1980: 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 73 2c 20 31 olumn_text(&s, 1
1990: 29 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 64 62 ));. }. db
19a0: 5f 66 69 6e 61 6c 69 7a 65 28 26 73 29 3b 0a 20 _finalize(&s);.
19b0: 20 7d 0a 0a 20 20 69 66 28 20 67 2e 75 73 65 72 }.. if( g.user
19c0: 55 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 64 62 Uid==0 ){. db
19d0: 5f 6d 75 6c 74 69 5f 65 78 65 63 28 0a 20 20 20 _multi_exec(.
19e0: 20 20 20 22 49 4e 53 45 52 54 20 49 4e 54 4f 20 "INSERT INTO
19f0: 75 73 65 72 28 6c 6f 67 69 6e 2c 20 70 77 2c 20 user(login, pw,
1a00: 63 61 70 2c 20 69 6e 66 6f 29 22 0a 20 20 20 20 cap, info)".
1a10: 20 20 22 56 41 4c 55 45 53 28 27 61 6e 6f 6e 79 "VALUES('anony
1a20: 6d 6f 75 73 27 2c 20 27 27 2c 20 27 27 2c 20 27 mous', '', '', '
1a30: 27 29 22 0a 20 20 20 20 29 3b 0a 20 20 20 20 67 ')". );. g
1a40: 2e 75 73 65 72 55 69 64 20 3d 20 64 62 5f 6c 61 .userUid = db_la
1a50: 73 74 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 28 st_insert_rowid(
1a60: 29 3b 0a 20 20 20 20 67 2e 7a 4c 6f 67 69 6e 20 );. g.zLogin
1a70: 3d 20 22 61 6e 6f 6e 79 6d 6f 75 73 22 3b 0a 20 = "anonymous";.
1a80: 20 7d 0a 7d 0a }.}.