[660] | 1 | /* Provide routines to store/check/access user credentials
|
---|
| 2 | stored in a shared memory object */
|
---|
[1023] | 3 |
|
---|
| 4 | /*
|
---|
| 5 | Copyright (C) 2007-2017 Herwig Bauernfeind for bww bitwise works GmbH.
|
---|
| 6 |
|
---|
| 7 | This program is free software: you can redistribute it and/or modify
|
---|
| 8 | it under the terms of the GNU General Public License as published by
|
---|
| 9 | the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | (at your option) any later version.
|
---|
| 11 |
|
---|
| 12 | This program is distributed in the hope that it will be useful,
|
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | GNU General Public License for more details.
|
---|
| 16 |
|
---|
| 17 | You should have received a copy of the GNU General Public License
|
---|
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
[660] | 20 |
|
---|
| 21 | _ucInitObj: procedure expose ucMem
|
---|
| 22 | /* Initialize shared memory object */
|
---|
| 23 | /* Not implemented as we use only an existing object */
|
---|
| 24 | ucMem = '\SHAREMEM\INETXXX'
|
---|
| 25 | return ucMem
|
---|
| 26 |
|
---|
| 27 | _ucChkObj: procedure expose ucMem ucPtr
|
---|
| 28 | /* Check if appropriate memory object is available */
|
---|
| 29 | Success = 0
|
---|
| 30 | getrc = RxGetNamedSharedMem('ucPtr', ucMem , 'rw')
|
---|
| 31 | if getrc = 0 then Success = 1
|
---|
| 32 | return Success
|
---|
| 33 |
|
---|
| 34 | _ucChkUc: procedure expose ucMem ucPtr
|
---|
| 35 | /* Check whether credentials are stored in memory object */
|
---|
| 36 | rawMem = RxStorage( ucPtr , 4096 )
|
---|
| 37 | ucPos = lastpos('--user=',rawMem)
|
---|
| 38 | Success = (ucPos > 0)
|
---|
| 39 | return Success
|
---|
| 40 |
|
---|
| 41 | _ucSetUc: procedure expose ucMem ucPtr UserCred
|
---|
| 42 | /* Set/Store credentials in memory object */
|
---|
| 43 | Success = 0
|
---|
| 44 | rawMem = RxStorage( ucPtr , 4096 )
|
---|
| 45 | ucL = length(UserCred)
|
---|
| 46 | rawMem = overlay(UserCred, rawMem, 4096-ucL)
|
---|
| 47 | rawMem = RxStorage( ucPtr , 4096, rawMem )
|
---|
| 48 | Success = 1
|
---|
| 49 | return Success
|
---|
| 50 |
|
---|
| 51 | _ucDelUc: procedure expose ucMem ucPtr UserCred
|
---|
| 52 | /* Delete credentials from memory object */
|
---|
| 53 | rawMem = RxStorage( ucPtr , 4096 )
|
---|
| 54 | cPos = lastpos('--user=',rawMem)
|
---|
| 55 | rawMem = overlay(copies('00'x,4096-cPos), rawMem, cPos)
|
---|
| 56 | rawMem = RxStorage( ucPtr , 4096, rawMem )
|
---|
| 57 | return 1
|
---|
| 58 |
|
---|
| 59 | _ucGetUc: procedure expose ucMem ucPtr
|
---|
| 60 | /* Read credentials from memory object */
|
---|
| 61 | rawMem = RxStorage( ucPtr , 4096 )
|
---|
| 62 | ucPos = lastpos('--user=',rawMem)
|
---|
| 63 | UserCred = strip(substr(rawMem,ucPos),,'00'x)
|
---|
| 64 | return UserCred
|
---|