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/deluser
| 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/deluser |
| Similarity: | 62% of bytes duplicated |
59 of 101 lines (66.7%) 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/deluser |
|---|---|
| 10REM >adduser | 10REM >deluser |
| 20REM add a user to the /etc/passwd file, whereever it is. | 20REM delete a user from the /etc/passwd file, whereever it is. |
| 30REM | 30REM |
| 40REM Author: Gunnar ZREPORTtl | 40REM Author: Gunnar ZREPORTtl |
| 50REM Date: 18-Sep-1994 | 50REM Date: 18-Sep-1994 |
| 60REM Last modified: 06-Nov-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) THEN |
| 180 FOR i%=1 TO argc - 1 | 180 IF argv$(1) = "-u" THEN |
| 190 CASE argv$(i%) OF | 190 N$ = argv$(2) |
| 200 WHEN "-u": N$ = argv$(i% + 1): i% += 1 | 200 ELSE |
| 210 WHEN "-g": GRP% = VAL(argv$(i% + 1)): i% += 1 | 210 PROCexit(1, "Invalid Parameters") |
| 220 OTHERWISE PROCexit(1, "Invalid Parameter") | 220 ENDIF |
| 230 ENDCASE | 230ELSE |
| 240 NEXT i% | 240 PROCexit(1, "Invalid Parameters") |
| 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$) | |
| 310 | 300 |
| 320IF FNgetenv("Wimp$ScrapDir") = "" THEN | 310IF FNgetenv("Wimp$ScrapDir") = "" THEN |
| 330 PROCexit(0, "ScrapDir must have been seen") | 320 PROCexit(0, "ScrapDir must have been seen") |
| 340ENDIF | 330ENDIF |
| 350etcpasswd$ = FNupath("/etc/passwd") | 340etcpasswd$ = FNupath("/etc/passwd") |
| 360etcbpasswd$ = FNupath("<Wimp$ScrapDir>.passwd") | 350etcbpasswd$ = FNupath("<Wimp$ScrapDir>.passwd") |
| 360cdiff = ASC"a" - ASC"A" | |
| 370 | 370 |
| 380REM first we determine the length of /etc/passd and the highest | 380REM we copy the passwd file to a scrapfile line by line, |
| 390REM user number so far. | 390REM omitting the line that has our user. |
| 400if% = OPENIN(etcpasswd$) | 400if% = OPENIN(etcpasswd$) |
| 410IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd") | 410IF if% = 0 THEN PROCexit(1, "could not open /etc/passwd") |
| 420l%=0 | |
| 430h%=0 | |
| 440mu% = 0 | |
| 450REPEAT | |
| 460 c$ = GET$#if% | |
| 470REM IF LEFT$(c$, len%) = user$ | |
| 480REM CLOSE #if% | |
| 490REM PROCexit(1, "User already exists") | |
| 500REM ENDIF | |
| 510 IF c$ <> "" THEN l% += 1 | |
| 520 i% = INSTR(c$, ":") | |
| 530 i% = INSTR(c$, ":", i% + 1) | |
| 540 u% = VAL(MID$(c$, i% + 1)) | |
| 550 IF u% > mu% THEN mu% = u% | |
| 560UNTIL c$="" | |
| 570CLOSE #if% | |
| 580 | |
| 590REM now we copy the passwd file to a scrapfile line by line. | |
| 600if% = OPENIN(etcpasswd$) | |
| 610of% = OPENOUT(etcbpasswd$) | 420of% = OPENOUT(etcbpasswd$) |
| 620IF of% = 0 THEN PROCexit(1, "could not open <Wimp$ScrapDir>.passwd") | 430IF of% = 0 THEN PROCexit(1, "could not open <Wimp$ScrapDir>.passwd") |
| 630FOR i% = 1 TO l% | 440l% = LEN(user$) |
| 450REPEAT | |
| 640 c$ = GET$#if% | 460 c$ = GET$#if% |
| 650 BPUT #of%,c$ | 470 IF user$ <> FNtolower(LEFT$(c$, l%)) THEN BPUT #of%,c$ |
| 660NEXT i% | 480UNTIL c$ = "" |
| 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% | 490CLOSE #of% |
| 750CLOSE #if% | 500CLOSE #if% |
| 760OSCLI("settype " +etcbpasswd$ + " FFF") | 510OSCLI("settype " +etcbpasswd$ + " FFF") |
| 770 | 520 |
| 780REM now copy our new file over the old one then exit and tell | 530REM now copy our new file over the old one then exit and tell |
| 790REM NewsBase that all went fine. | 540REM NewsBase that all went fine. |
| 800OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V") | 550OSCLI("copy " + etcbpasswd$ + " " + etcpasswd$ + " FD~C~V") |
| 810PROCexit(0, "user added") | 560PROCexit(0, "user added") |
| 820END | 570END |
| 830 | 580 |
| 840REM convert all characters in a string to lowercase. | 590REM convert all characters in a string to lowercase. |
| 850REM | 600REM |
| 860DEF FNtolower(a$) | 610DEF FNtolower(a$) |
| 870LOCAL i%, c$ | 620LOCAL i%, c$ |
| 880FOR i% = 1 TO LENa$ | 630FOR i% = 1 TO LENa$ |
| 890 c$ = MID$(a$, i%, 1) | 640 c$ = MID$(a$, i%, 1) |
| 900 IF c$ >= "A" AND c$ <= "Z" THEN | 650 IF c$ >= "A" AND c$ <= "Z" THEN |
| 910 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff) | 660 MID$(a$, i%, 1) = CHR$(ASC(c$) + cdiff) |
| 920 ENDIF | 670 ENDIF |
| 930= a$ | 680= a$ |
| 940 | 690 |
| 950REM exit from here, returning appropriate info. | 700REM exit from here, returning appropriate info. |
| 960REM | 710REM |
| 970DEFPROCexit(n%,a$) | 720DEFPROCexit(n%,a$) |
| 980OSCLI("set NewsBase$ReturnCode "+STR$n%) | 730OSCLI("set NewsBase$ReturnCode "+STR$n%) |
| 990OSCLI("set NewsBase$ReturnInfo "+a$) | 740OSCLI("set NewsBase$ReturnInfo "+a$) |
| 1000END | 750END |
| 1010ENDPROC | 760ENDPROC |
.