Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/adduser » Compare

Compare StarterPak/!Newsbase/Transports/taylor/adduser with StarterPak/!Newsbase/Transports/taylor/moduser

File: Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/adduser
Compared with: Archimedes archive » Acorn User » AU 1995-08.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/moduser
Similarity: 65% of bytes duplicated

60 of 101 lines (61.9%) are identical in the two listings. Duplicated Different

Line numbers are ignored when comparing lines, so that renumbered programs still match.

StarterPak/!Newsbase/Transports/taylor/adduser StarterPak/!Newsbase/Transports/taylor/moduser
10REM >adduser 10REM >moduser
20REM add a user to the /etc/passwd file, whereever it is. 20REM modify a user to the /etc/passwd file, whereever it is.
30REM 30REM
40REM Author: Gunnar ZREPORTtl 40REM Author: Gunnar ZREPORTtl
50REM Date: 18-Sep-1994 50REM Date: 10-Nov-1994
60REM Last modified: 06-Nov-1994 60REM Last modified: 15-Dec-1994
70 70
80ONERROR REPORT:PRINT" at line ";ERL:END 80ONERROR REPORT:PRINT" at line ";ERL:END
90 90
100LIBRARY "<NewsBase$TaylorDir>.ScriptLib" 100LIBRARY "<NewsBase$TaylorDir>.ScriptLib"
110 110
120REM default value for group 120REM default value for group
130GRP% = 1 130GRP% = 1
140 140
150REM get command line parameters 150REM get command line parameters
160PROCentry 160PROCentry
170IF (argc = 3) OR (argc = 5) THEN 170IF (argc = 3) OR (argc = 5) THEN
180 FOR i%=1 TO argc - 1 180 FOR i%=1 TO argc - 1
190 CASE argv$(i%) OF 190 CASE argv$(i%) OF
200 WHEN "-u": N$ = argv$(i% + 1): i% += 1 200 WHEN "-u": N$ = argv$(i% + 1): i% += 1
210 WHEN "-g": GRP% = VAL(argv$(i% + 1)): i% += 1 210 WHEN "-g": GRP% = VAL(argv$(i% + 1)): i% += 1
220 OTHERWISE PROCexit(1, "Invalid Parameter") 220 OTHERWISE PROCexit(1, "Invalid Parameter")
230 ENDCASE 230 ENDCASE
240 NEXT i% 240 NEXT i%
250ENDIF 250ENDIF
260 260
270REM remove spaces from username. 270REM remove spaces from username.
280user$ = FNstripspaces(N$) 280user$ = FNstripspaces(N$)
290user$ = FNtolower(user$) + ":" 290user$ = FNtolower(user$) + ":"
300len% = LEN(user$) 300len% = LEN(user$)
310 310
320IF FNgetenv("Wimp$ScrapDir") = "" THEN 320IF FNgetenv("Wimp$ScrapDir") = "" THEN
330 PROCexit(0, "ScrapDir must have been seen") 330 PROCexit(0, "ScrapDir must have been seen")
340ENDIF 340ENDIF
350etcpasswd$ = FNupath("/etc/passwd") 350etcpasswd$ = FNupath("/etc/passwd")
360etcbpasswd$ = FNupath("<Wimp$ScrapDir>.passwd") 360etcbpasswd$ = FNupath("<Wimp$ScrapDir>.passwd")
370 370
380REM first we determine the length of /etc/passd and the highest 380REM we copy from /etc/passwd to the temp. file until we find
390REM user number so far. 390REM the specified user. Then we just alter his group number,
400REM and write the new entry out to the temp. file.
400if% = OPENIN(etcpasswd$) 410if% = OPENIN(etcpasswd$)
410IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd") 420IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd")
420l%=0 430of% = OPENOUT(etcbpasswd$)
430h%=0 440IF of% = 0 THEN PROCexit(1, "could not open " + etcbpasswd$)
440mu% = 0 450i% = 0
460j% = 0
450REPEAT 470REPEAT
460 c$ = GET$#if% 480 c$ = GET$#if%
470REM IF LEFT$(c$, len%) = user$ 490 IF LEFT$(c$, len%) = user$ THEN
480REM CLOSE #if% 500 i% = INSTR(c$, ":")
490REM PROCexit(1, "User already exists") 510 i% = INSTR(c$, ":", i% + 1)
500REM ENDIF 520 REM extract strings before and after group number
510 IF c$ <> "" THEN l% += 1 530 i% = INSTR(c$, ":", i% + 1)
520 i% = INSTR(c$, ":") 540 j% = INSTR(c$, ":", i% + 1)
530 i% = INSTR(c$, ":", i% + 1) 550 o$=LEFT$(c$, i%) + STR$(GRP%) + MID$(c$, j%)
540 u% = VAL(MID$(c$, i% + 1)) 560 BPUT #of%,o$
550 IF u% > mu% THEN mu% = u% 570 ELSE
560UNTIL c$="" 580 BPUT #of%,c$
570CLOSE #if% 590 ENDIF
580 600UNTIL (c$="")
590REM now we copy the passwd file to a scrapfile line by line.
600if% = OPENIN(etcpasswd$)
610of% = OPENOUT(etcbpasswd$)
620IF of% = 0 THEN PROCexit(1, "could not open <Wimp$ScrapDir>.passwd")
630FOR i% = 1 TO l%
640 c$ = GET$#if%
650 BPUT #of%,c$
660NEXT i%
670
680REM after that we compose out new entry: username, new user
690REM number is highest user number + 1, groupnumber is GRP%
700o$ = user$ + ":"+ STR$(mu% + 1) + ":" + STR$(GRP%)
710o$ = o$ + "::/usr/" + user$ + ":/bin/sh"
720REM then we append the new entry to the scrapfile.
730BPUT #of%, o$
740CLOSE #of% 610CLOSE #of%
750CLOSE #if% 620CLOSE #if%
760OSCLI("settype " +etcbpasswd$ + " FFF")
770 630
780REM now copy our new file over the old one then exit and tell 640IF i% > 0 THEN
790REM NewsBase that all went fine. 650 REM now copy our new file over the old one then exit and tell
800OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V") 660 REM NewsBase that all went fine.
810PROCexit(0, "user added") 670 OSCLI("settype " +etcbpasswd$ + " FFF")
680 OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V")
690 PROCexit(0, "user " + user$ + " modified")
700ELSE
710 REM otherwise complain and die.
720 PROCexit(1, "user " + user$ + " not found")
730ENDIF
820END 740END
830 750
840REM convert all characters in a string to lowercase. 760REM convert all characters in a string to lowercase.
850REM 770REM
860DEF FNtolower(a$) 780DEF FNtolower(a$)
870LOCAL i%, c$ 790LOCAL i%, c$
880FOR i% = 1 TO LENa$ 800FOR i% = 1 TO LENa$
890 c$ = MID$(a$, i%, 1) 810 c$ = MID$(a$, i%, 1)
900 IF c$ >= "A" AND c$ <= "Z" THEN 820 IF c$ >= "A" AND c$ <= "Z" THEN
910 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff) 830 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff)
920 ENDIF 840 ENDIF
930= a$ 850= a$
940 860
950REM exit from here, returning appropriate info. 870REM exit from here, returning appropriate info.
960REM 880REM
970DEFPROCexit(n%,a$) 890DEFPROCexit(n%,a$)
980OSCLI("set NewsBase$ReturnCode "+STR$n%) 900OSCLI("set NewsBase$ReturnCode "+STR$n%)
990OSCLI("set NewsBase$ReturnInfo "+a$) 910OSCLI("set NewsBase$ReturnInfo "+a$)
1000END 920END
1010ENDPROC 930ENDPROC