File: adduser

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (303 lines) | stat: -rw-r--r-- 10,161 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
!!! variables used (to check) : replacelist , up_xx for xx in replacelist and in firstname, lastname
!!! regvars_cnt  techvarlist and ???

uu=$wims_read_parm
!if user notwordof $wims_prefix
  wims_prefix=$wims_prefix user class
!endif
!default up_class=$wims_class
class_type=!defof class_type in wimshome/log/classes/$up_class/.def
authidp=!defof class_authidp in wimshome/log/classes/$up_class/.def
!default class_type=0
!read adm/class/authchars
l=!text select $char_login in $uu
t=!char 1 of $uu
n=!charcnt $l
!if $class_type isin 012
!! and $wims_superclass=$empty notneeded 20180612 FG ?
  regvarlist=!makelist regprop x for x=1 to $regvars_cnt
  regvarlist=!nospace $regvarlist
  replacelist=!append item $regvarlist to $replacelist
!else
  regvarlist=$empty
!endif

!if $l!=$uu or $t isin $char_punct or $n<$login_min or $n>$login_max
  !exit
!endif
uu=!translate internal . to @ in $uu
login_wims=$uu

!reset user_lastname,user_firstname,user_password,user_email,user_comments,user_photourl,\
    user_exists,user_participate,user_supervise,user_supervisable,user_external_auth,user_mkclass,\
    user_forcechpwd
!for j in $regvarlist
  !if $(user_$j)!=$empty
    !reset user_$j
  !endif
!next j
!read adm/class/userdef classes,$up_class,$uu
!sh mkdir -p $Userfolder
!defread $userdef

!if $class_type isin 24 and $user_exists=yes and \
  (($user_supervisable!=yes and $up_supervisable=yes) or \
   ($user_supervisable=yes and $up_supervisable!=yes and supervisable \
   isitemof $replacelist))
  bad=!append item $uu to $bad
  !exit
!endif

!if $class_type isin 13
  !if $class_Supervisor=$wims_realuser
    !if $class_type=1 and $user_supervisable=yes
      replacelist=!listcomplement supervisable in $replacelist
    !else
      replacelist=!listcomplement participate,supervisable in $replacelist
    !endif
  !else
    replacelist=!listcomplement supervise,participate,supervisable in $replacelist
  !endif

  !! only real supervisor of class (mean : creator) can modify teacher account (very important protection)
  !if $wims_user=supervisor and yes isin $user_supervisable $up_supervisable and $class_Supervisor!=$wims_realuser
    bad=!append item $uu to $bad
    !exit
  !endif

  !! creator of class cannot loose manage access
  !if $class_Supervisor=$uu and $wims_class notin $up_supervise
    up_supervise=!append item $wims_class to $up_supervise
  !endif

  !if $adduser_replace iswordof none nopass and $user_password!=$empty
    !if $wims_user iswordof supervisor $uu
      !default up_password=$user_password
    !endif
    !! both can be already crypten
    p1=!word 1 of $user_password
    p1=!passcrypt $p1
    p2=!word 1 of $up_password
    pass_check=!passcheck $p2 and $p1
    p2=!passcrypt $p2
    !if $p1!=$p2 and $pass_check!=yes
      bad=!append item $uu to $bad
      !exit
    !endif
  !endif
!endif

!if $wims_mail_hidden=yes and $wims_user=supervisor and $user_supervisable!=yes
 replacelist=!listcomplement email in $replacelist
!endif

!if $user_exists= and email notitemof $replacelist
  replacelist=!append item email to $replacelist
!endif

up_exists=yes
!default up_supervisable=$user_supervisable
replace_=
!if $adduser_replace=none
  !goto next
!endif
!!!
!for n in lastname,firstname,email,regnum,comments,exists,supervise,supervisable,participate,photourl,\
  external_auth,agreecgu,$regvarlist,$techvarlist
  !if $n isitemof $replacelist,lastname,firstname,exists,supervisable,agreecgu,external_auth
    l_=!singlespace $(up_$n)
    !if $n=comments
      !readproc adm/class/mkcomment name
      !let vname=$n$scriptout
    !else
      !let vname=$n
    !endif
    !if ($(up_$n)!=$empty or $n=photourl) and $(up_$n)!=$(user_$vname)
      l_=!singlespace $(up_$n)
      !if $l_ issametext
        l_=
      !endif
      !if $n iswordof participate supervise
        l_=!words2items $l_
        l__=
        !for a_ in $l_
          part_=!text select 1234567890/ in $a_
          part_test=!replace internal / by , in $part_
          !if $(part_test[1])=$wims_class or $(part_test[1])=$wims_superclass
            l__=!append item $part_ to $l__
          !endif
        !next a_
        !if $n iswordof participate
          !if $user_supervisable!=yes
            l_=!listuniq $l__,$(user_$n)
          !endif
        !else
          l_=!listuniq $l__
        !endif
      !else
        !if techvar isin $n
          !!!FIXME add a test for validity or add the value to the possible values
        !endif
        !!FIXME one can do l_=!detag $l ???
        !if $n isitemof $regvarlist
          l_=!detag $l_
        !endif
        l_=!replace , by &#44; in $l_
        l_=!replace < by &lt; in $l_
        l_=!translate internal "#*!$$ to $.....$ in $l_
      !endif
      !if $n isitemof comments,photourl,$regvarlist
        l_=!char 1 to 5000 of $l_
      !else
        !if $n iswordof participate supervise
          l_=!char 1 to 500 of $l_
        !else
          l_=!char 1 to 100 of $l_
        !endif
      !endif
      replace_=!append line !set user_$(vname)=$l_ to $replace_
    !endif
  !endif
!next n

!if $user_exists!=yes and \
  ($up_password=$empty or $up_lastname=$empty or $up_firstname=$empty)
  bad=!append item $uu to $bad
  !exit
!endif

:next
!! verification of user_participate and sharing (needed for teachers in order to register as student)
!if $class_type isin 13 and $up_class notitemof $user_participate
  typename=!defof class_typename in wimshome/log/classes/$up_class/.def
  !if $typename != $empty and $typename notwordof class course
    bad=!append item $uu to $bad
    !exit
  !endif
  !if $typename issametext course
    typename=!defof class_typename in wimshome/log/classes/$wims_class/.def
    !if $wims_class!=$empty and $typename issametext course and \
        $wims_class=$up_class and $wims_user=supervisor
      au_1=!translate internal / to , in $wims_class
      au_1=!translate internal , to / in $(au_1[1..-2])
      au_1=!nospace $au_1
      up_class=$au_1
      typename=!defof class_typename in wimshome/log/classes/$au_1/.def
    !endif
    !!case of program occurs in case of an intercourse
    !if $wims_class=$empty or $typename notwordof class program or \
        ../$wims_superclass/ notin ../$up_class
      !exit
    !endif
    user_class=!replace internal ../$wims_superclass/ by in ../$wims_class
    user_course=!replace internal ../$wims_superclass/ by in ../$up_class
    au_test=!defof user_class in wimshome/log/classes/$up_class/.users/$uu
    !if $au_test!=$empty
      au_test=$wims_superclass/$au_test
      user_courses=!getdef user_courses in wimshome/log/classes/$au_test/.users/$uu
      user_courses=!listcomplement $user_course in $user_courses
      !setdef !set user_courses=$user_courses in wimshome/log/classes/$au_test/.users/$uu
    !endif
    !setdef !set user_class=$user_class in wimshome/log/classes/$up_class/.users/$uu
    user_courses=!getdef user_courses in wimshome/log/classes/$wims_class/.users/$uu
    user_courses=!listunion $user_courses and $user_course
    !setdef !set user_courses=$user_courses in wimshome/log/classes/$wims_class/.users/$uu
    change=!listunion $change and $uu
  !else
    !!if participate isitemof $replace_list
    !!change up_participate here
    up_participate=!listunion $user_participate and $up_class
    shclass=!defof sharing_user in wimshome/log/classes/$up_class/neighbors
    !default shclass=$up_class
    sharing=!defof sharable_user in wimshome/log/classes/$shclass/neighbors
    sharing=!append item $shclass to $sharing
    sharing=!listcomplement $up_participate in $sharing
    !if $sharing!=$empty
      !for sh in $sharing
        test=!defof class_superclass in wimshome/log/classes/$sh/.def
        !if $test!=$empty and $test=$wims_superclass
          up_participate=!append item $sh to $up_participate
        !endif
      !next sh
    !endif
    !if $user_exists=yes
      !setdef !set user_participate=$up_participate in $userdef
      change=!listunion $change and $uu
    !else
      replace_=!append line !set user_participate=$up_participate to $replace_
    !endif
  !endif
!endif

!if $adduser_replace=none
  !exit
!endif

!if $up_password!=$empty and $up_password!=$user_password
  c=!char 1 of $up_password
  !if $c=* and $wims_priv_cryptpass=allow
    p=!text select */$char_passwd in $up_password
  !else
    p=!text select $char_passwd in $up_password
  !endif
  n=!charcnt $p
  !if $p!=$up_password or $n<$passwd_min or $n>$passwd_max
    bad=!append item $uu to $bad
    !exit
  !endif
  up_password=!passcrypt $up_password
  replace_=!append line !set user_password=$up_password to $replace_
  !if $wims_user!=$empty and $uu!=$wims_user and $(authidp[1;])=$empty
    up_forcechpwd=yes
  !else
    up_forcechpwd=no
  !endif
  replace_=!append line !set user_forcechpwd=$up_forcechpwd to $replace_
!endif

!if $up_vars!=$empty
  up_vars=!nonempty lines $up_vars
  up_vars=!replace internal ! by &#33; in $up_vars
  up_vars=!rows2lines $up_vars
  up_vars=!replace internal = by , in $up_vars
  !if $tv_varfilterreaden!=yes
    !readproc adm/vfilter/listvarfilter.proc
  !endif
  n=!linecnt $up_vars
  !for i=1 to $n
    llll=!line $i of $up_vars
    llll=!trim $llll
    !distribute item $llll into nv_,vv_
    !if $nv_ isitemof $tv_listname
      po_=!positionof item $nv_ in $tv_listname
      !if $po_ isitemof $tv_listlocal
        p_=!line $po_ of $tv_listtechvar
        val_=!record $(p_[3]) of wimshome/log/classes/$(p_[2])/.techvar
        val_=!line 2 of $val_
        t_=!item $po_ of $tv_listcode
        !bound vv_ within $val_,$empty default $empty
        replace_=!append line !set user_techvar_$(t_)=$vv_ to $replace_
      !endif
    !endif
  !next i
!endif
!!FIXME even if there is no change in user_techvar, it is changed
!! and add to the list of users.

!if $class_type=2 and $user_mkclass!=$up_mkclass and $user_supervisable=yes
  !bound up_mkclass within yes,no default yes
  replace_=!append line !set user_mkclass=$up_mkclass to $replace_
!endif


!if $replace_=$empty
  !exit
!endif

change=!listunion $change and $uu

!setdef $replace_ in $userdef

!if $up_class=$wims_class
  wims_class_log=User info $uu
!endif