Although it is possible to set a password for your RISC OS Pi computer, horrible things happened last time I tried, and that resulted in a reinstall. I am not going to try again.
Instead I have written a BASIC program that performs the same operation. The file is set to run as soon as the computer boots and it is not possible to escape from the program until the correct password is entered. Although it is not the most secure of systems, it will prevent all but the most determined of attacker.
If you wish to follow these instructions, then they are split into the following sections:
- The code
- An explanation of the code
- Setting the file to run at boot time
The code
10 REM Password protection
20 REM T Street
30 REM Version 2.0
40 REM 2017-04-02
50 :
60 pass$ = "fish"
70 :
80 welcome$ = FNreadWelcome
90 MODE 18:
VDU23,1,0;0;0;0;
100 ON ERROR IF ERR = 17 RUN
110 COLOUR 120
120 PRINTTAB(0,1)welcome$
130 ok% = FALSE
140 guess$ = ""
150 WHILE NOT(ok%)
160 PRINTTAB(0,3)"Password : "STRING$(LEN(guess$),"*")" "
170 g = GET
180 IF LEN(guess$)=0 THEN PRINTTAB(0,5)STRING$(19," ")
190 CASE g OF
200 WHEN 8,127
210 IF guess$<>"" THEN guess$=LEFT$(guess$,LEN(guess$)-1)
220 WHEN 13
230 IF guess$ = pass$ THEN OSCLI("DESKTOP") ELSE PRINTTAB(0,3)"Password : "STRING$(LEN(guess$)," "):
COLOUR2:
PRINTTAB(0,5)"PASSWORD INCORRECT!":
guess$ = "":
COLOUR120
240 OTHERWISE
250 IF LEN(guess$)<60 THEN guess$ = guess$ + CHR$(g)
260 ENDCASE
270 ENDWHILE
280 :
290 DEFFNreadWelcome
300 LOCAL file%, welcome$
310 file% = OPENIN(":0.Scripts.welcome")
320 IF file% = 0 THEN = "RISC OS Pi, Welcome"
330 WHILE NOT(EOF#file%)
340 welcome$ = welcome$ + CHR$(BGET#file%)
350 ENDWHILE
360 =LEFT$(welcome$,78)
Explanation
You can either type the code directly into your BASIC editor in RISC OS, or download a copy of the file from OneDrive.
- The password is set on line 60.
- Line 80 reads a custom welcome message from a text file set in line 310. You will need to provide a text file with your welcome message.
- Line 110 should be omitted whilst you are developing and testing. It prevents the program from exiting on pressing of the "ESCAPE" key.
- Line 310 reads a text file with your custom welcome message. For example you might want to provide a rude message for your little sister. You will need to provide this text in a text file called 'welcome'. You must also provide the full path to the file in line 310. Here I have it in a folder called 'Scripts' in my root directory.
- Line 320 provides a default welcome message should the file not exist. Note that only the first 78 characters of the welcome message are used by the program - so keep it short.
Setting the program to run at boot
Once you are happy that the program is running, save it and then add it to the programs that run at boot. To do this select the '!configure' icon with a double left-click. Then single click 'Boot', then 'Run'. Drag the BASIC 'password' file into the 'Run at startup' window and click 'set', and then 'set' on the boot sequence.
This program will defeat all but the most determined of attackers. It will not stop someone from accessing the BASIC program itself once you are logged in. Although this program will deter the casual nosy parker from accessing your RISC OS machine, you should not rely on it for system security.
Still reading? How about some more Raspberry Pi stuff?