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

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

File: Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/moduser
Compared with: Archimedes archive » Acorn User » AU 1995-08.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/adduser
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/moduser StarterPak/!Newsbase/Transports/taylor/adduser
10REM >moduser 10REM >adduser
20REM modify a user to the /etc/passwd file, whereever it is. 20REM add a user to the /etc/passwd file, whereever it is.
30REM 30REM
40REM Author: Gunnar ZREPORTtl 40REM Author: Gunnar ZREPORTtl
50REM Date: 10-Nov-1994 50REM Date: 18-Sep-1994
60REM Last modified: 15-Dec-1994 60REM Last modified: 06-Nov-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 we copy from /etc/passwd to the temp. file until we find 380REM first we determine the length of /etc/passd and the highest
390REM the specified user. Then we just alter his group number, 390REM user number so far.
400REM and write the new entry out to the temp. file.
410if% = OPENIN(etcpasswd$) 400if% = OPENIN(etcpasswd$)
420IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd") 410IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd")
430of% = OPENOUT(etcbpasswd$) 420l%=0
440IF of% = 0 THEN PROCexit(1, "could not open " + etcbpasswd$) 430h%=0
450i% = 0 440mu% = 0
460j% = 0
470REPEAT 450REPEAT
480 c$ = GET$#if% 460 c$ = GET$#if%
490 IF LEFT$(c$, len%) = user$ THEN 470REM IF LEFT$(c$, len%) = user$
500 i% = INSTR(c$, ":") 480REM CLOSE #if%
510 i% = INSTR(c$, ":", i% + 1) 490REM PROCexit(1, "User already exists")
520 REM extract strings before and after group number 500REM ENDIF
530 i% = INSTR(c$, ":", i% + 1) 510 IF c$ <> "" THEN l% += 1
540 j% = INSTR(c$, ":", i% + 1) 520 i% = INSTR(c$, ":")
550 o$=LEFT$(c$, i%) + STR$(GRP%) + MID$(c$, j%) 530 i% = INSTR(c$, ":", i% + 1)
560 BPUT #of%,o$ 540 u% = VAL(MID$(c$, i% + 1))
570 ELSE 550 IF u% > mu% THEN mu% = u%
580 BPUT #of%,c$ 560UNTIL c$=""
590 ENDIF 570CLOSE #if%
600UNTIL (c$="") 580
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$
610CLOSE #of% 740CLOSE #of%
620CLOSE #if% 750CLOSE #if%
760OSCLI("settype " +etcbpasswd$ + " FFF")
630 770
640IF i% > 0 THEN 780REM now copy our new file over the old one then exit and tell
650 REM now copy our new file over the old one then exit and tell 790REM NewsBase that all went fine.
660 REM NewsBase that all went fine. 800OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V")
670 OSCLI("settype " +etcbpasswd$ + " FFF") 810PROCexit(0, "user added")
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
740END 820END
750 830
760REM convert all characters in a string to lowercase. 840REM convert all characters in a string to lowercase.
770REM 850REM
780DEF FNtolower(a$) 860DEF FNtolower(a$)
790LOCAL i%, c$ 870LOCAL i%, c$
800FOR i% = 1 TO LENa$ 880FOR i% = 1 TO LENa$
810 c$ = MID$(a$, i%, 1) 890 c$ = MID$(a$, i%, 1)
820 IF c$ >= "A" AND c$ <= "Z" THEN 900 IF c$ >= "A" AND c$ <= "Z" THEN
830 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff) 910 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff)
840 ENDIF 920 ENDIF
850= a$ 930= a$
860 940
870REM exit from here, returning appropriate info. 950REM exit from here, returning appropriate info.
880REM 960REM
890DEFPROCexit(n%,a$) 970DEFPROCexit(n%,a$)
900OSCLI("set NewsBase$ReturnCode "+STR$n%) 980OSCLI("set NewsBase$ReturnCode "+STR$n%)
910OSCLI("set NewsBase$ReturnInfo "+a$) 990OSCLI("set NewsBase$ReturnInfo "+a$)
920END 1000END
930ENDPROC 1010ENDPROC