annotate 3rdparty/packages/uucpbb/src/adduser.c @ 3226:9749d0dfc4a2

Changed a puls PC to rts to save cycles
author David Ladd <drencor-xeen@users.sourceforge.net>
date Sat, 20 Jan 2018 19:32:22 -0600
parents c4c7facbd082
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1772
5ba8e711a1a3 source added
boisy
parents:
diff changeset
1 /* adduser.c Program to allow new user accounts to be added to the system.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
2 Copyright (C) 1990, 1993 Mark Griffith and Bob Billson
5ba8e711a1a3 source added
boisy
parents:
diff changeset
3
5ba8e711a1a3 source added
boisy
parents:
diff changeset
4 This file is part of the OS-9 UUCP package, UUCPbb.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
5
5ba8e711a1a3 source added
boisy
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify
5ba8e711a1a3 source added
boisy
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
5ba8e711a1a3 source added
boisy
parents:
diff changeset
8 the Free Software Foundation; either version 2 of the License, or
5ba8e711a1a3 source added
boisy
parents:
diff changeset
9 (at your option) any later version.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
10
5ba8e711a1a3 source added
boisy
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
5ba8e711a1a3 source added
boisy
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5ba8e711a1a3 source added
boisy
parents:
diff changeset
14 GNU General Public License for more details.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
15
5ba8e711a1a3 source added
boisy
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
5ba8e711a1a3 source added
boisy
parents:
diff changeset
17 along with this program; if not, write to the Free Software
5ba8e711a1a3 source added
boisy
parents:
diff changeset
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
19
5ba8e711a1a3 source added
boisy
parents:
diff changeset
20 The author of UUCPbb, Bob Billson, can be contacted at:
5ba8e711a1a3 source added
boisy
parents:
diff changeset
21 bob@kc2wz.bubble.org or uunet!kc2wz!bob or by snail mail:
5ba8e711a1a3 source added
boisy
parents:
diff changeset
22 21 Bates Way, Westfield, NJ 07090
5ba8e711a1a3 source added
boisy
parents:
diff changeset
23 */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
24
5ba8e711a1a3 source added
boisy
parents:
diff changeset
25 /* Adds a new user to the system by updating the password file and
5ba8e711a1a3 source added
boisy
parents:
diff changeset
26 creating required user files. Requires my LOGIN and PASSWORD
5ba8e711a1a3 source added
boisy
parents:
diff changeset
27 utilities to work correctly.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
28
5ba8e711a1a3 source added
boisy
parents:
diff changeset
29 * * * N O T I C E * * *
5ba8e711a1a3 source added
boisy
parents:
diff changeset
30
5ba8e711a1a3 source added
boisy
parents:
diff changeset
31 This code assumes the use of Shell+
5ba8e711a1a3 source added
boisy
parents:
diff changeset
32 Requires the Kreider library to compile
5ba8e711a1a3 source added
boisy
parents:
diff changeset
33
5ba8e711a1a3 source added
boisy
parents:
diff changeset
34 Mark Griffith
5ba8e711a1a3 source added
boisy
parents:
diff changeset
35 DeLand, Fl.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
36
5ba8e711a1a3 source added
boisy
parents:
diff changeset
37 91 Jun o Changes to Mark's code made by Bob Billson
5ba8e711a1a3 source added
boisy
parents:
diff changeset
38 <uunet!kc2wz!bob> are indicated by 'REB'
5ba8e711a1a3 source added
boisy
parents:
diff changeset
39
5ba8e711a1a3 source added
boisy
parents:
diff changeset
40 ?? ??? ?? o Further changes made by Charles Ownes
5ba8e711a1a3 source added
boisy
parents:
diff changeset
41 <trystro!czos9!chuck> to make it work more happily
5ba8e711a1a3 source added
boisy
parents:
diff changeset
42 with Rick Adams' UUCP are indicated by 'CNO'.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
43
5ba8e711a1a3 source added
boisy
parents:
diff changeset
44 HINT: If you edit /dd/sys/password by hand, be sure you don't
5ba8e711a1a3 source added
boisy
parents:
diff changeset
45 add any extra carrige returns at the end of the file.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
46 Each line should end with one carrige return. There
5ba8e711a1a3 source added
boisy
parents:
diff changeset
47 should be no blank lines between entries. If this
5ba8e711a1a3 source added
boisy
parents:
diff changeset
48 format is not adhered to, ADDUSER will not work
5ba8e711a1a3 source added
boisy
parents:
diff changeset
49 properly. -- CNO
5ba8e711a1a3 source added
boisy
parents:
diff changeset
50
5ba8e711a1a3 source added
boisy
parents:
diff changeset
51 92 Oct 20 o Minor additions to allow compiling with the makefile in
5ba8e711a1a3 source added
boisy
parents:
diff changeset
52 Rick Adams' UUCP.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
53 o Improved the way chk_uid() picks its own user id.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
54 o get_entries() now detects and reports blank lines in the
5ba8e711a1a3 source added
boisy
parents:
diff changeset
55 password file.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
56 o User's login file script can now be customized. -- REB
5ba8e711a1a3 source added
boisy
parents:
diff changeset
57
5ba8e711a1a3 source added
boisy
parents:
diff changeset
58 93 Feb 14 o User name can now be given on the command line -- REB
5ba8e711a1a3 source added
boisy
parents:
diff changeset
59
5ba8e711a1a3 source added
boisy
parents:
diff changeset
60 93 Sep 4 o Special processing for user named 'daemon' --REB
5ba8e711a1a3 source added
boisy
parents:
diff changeset
61
5ba8e711a1a3 source added
boisy
parents:
diff changeset
62 94 Mar 30 o Added -s option for super user, fixed for OSK -- BGP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
63 */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
64
5ba8e711a1a3 source added
boisy
parents:
diff changeset
65 #define MAIN
5ba8e711a1a3 source added
boisy
parents:
diff changeset
66
5ba8e711a1a3 source added
boisy
parents:
diff changeset
67 /* To compile for UUCPbb, make the next line '#undef MARK'
5ba8e711a1a3 source added
boisy
parents:
diff changeset
68 To compile for Mark's original, make the next line '#define MARK' */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
69
5ba8e711a1a3 source added
boisy
parents:
diff changeset
70 #undef MARK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
71
5ba8e711a1a3 source added
boisy
parents:
diff changeset
72 /* To send certain login messages to the Speech Sound Pak, make the next
5ba8e711a1a3 source added
boisy
parents:
diff changeset
73 line '#define SSP'. ***NOTE*** do this only if you ALWAYS have the SSP in
5ba8e711a1a3 source added
boisy
parents:
diff changeset
74 place.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
75
5ba8e711a1a3 source added
boisy
parents:
diff changeset
76 If you do NOT wish to send messages to the SSP, make the next line
5ba8e711a1a3 source added
boisy
parents:
diff changeset
77 '#undef SSP' -- CNO */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
78 #undef SSP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
79
5ba8e711a1a3 source added
boisy
parents:
diff changeset
80 #ifndef MARK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
81 #include "uucp.h" /* default to Rick's */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
82 #else /* uucp -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
83 #include <stdio.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
84 #include <string.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
85 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
86 #include <modes.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
87 #include <ctype.h> /* Added -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
88 #include <password.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
89 #include <sgstat.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
90
5ba8e711a1a3 source added
boisy
parents:
diff changeset
91 /* Defines for password file array */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
92
5ba8e711a1a3 source added
boisy
parents:
diff changeset
93 #define NAME 0 /* User name */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
94 #define PASS 1 /* User password */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
95 #define ID 2 /* User ID */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
96 #define PRI 3 /* User priority */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
97 #define DIRX 4 /* Execution directory */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
98 #define DIRW 5 /* Working directory */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
99 #define CMD 6 /* first command to run */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
100 #define PW_SIZE 7 /* Number of entries */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
101 #define ON 1
5ba8e711a1a3 source added
boisy
parents:
diff changeset
102 #define OFF 0
5ba8e711a1a3 source added
boisy
parents:
diff changeset
103
5ba8e711a1a3 source added
boisy
parents:
diff changeset
104 /* made direct page -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
105 QQ char *daemon = "daemon",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
106 *Sorry = "Sorry, only the Superuser can use this utility!",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
107 *NewID = "Enter new user ID number\n ('Q' to quit) or press <ENTER> and I'll pick: ";
5ba8e711a1a3 source added
boisy
parents:
diff changeset
108
5ba8e711a1a3 source added
boisy
parents:
diff changeset
109 /* Change the filenames below as needed ONLY if compiling for Mark's version.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
110 For UUCPbb: userdir, maildir and logdir are defined in uucp.h PASSWORD and
5ba8e711a1a3 source added
boisy
parents:
diff changeset
111 PWEMAX are defined in password.h -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
112
5ba8e711a1a3 source added
boisy
parents:
diff changeset
113 #ifdef MARK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
114 QQ char *userdir = "/DD/USR", /* default user directory */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
115 *logdir = "/DD/LOG", /* default user log file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
116 *maildir = "/DD/MAIL"; /* default mail directory */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
117 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
118 QQ char *userdir = USERDIR;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
119 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
120
5ba8e711a1a3 source added
boisy
parents:
diff changeset
121 /* these apply to both UUCPbb and Mark's version */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
122 QQ char *passfile = PASSWORD, /* default password file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
123 *motd = "/DD/SYS/motd"; /* location of motd file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
124
5ba8e711a1a3 source added
boisy
parents:
diff changeset
125 char pw[PW_SIZE][30],
5ba8e711a1a3 source added
boisy
parents:
diff changeset
126 tempstr[256], dirname[256],
5ba8e711a1a3 source added
boisy
parents:
diff changeset
127 u_name[PWEMAX][20],
5ba8e711a1a3 source added
boisy
parents:
diff changeset
128 mailname[256]; /* added -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
129 flag isdaemon = FALSE; /* */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
130
5ba8e711a1a3 source added
boisy
parents:
diff changeset
131 unsigned u_uid[PWEMAX];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
132 #ifdef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
133 QQ int super = 256;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
134 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
135 QQ int super = 1; /* added -- BGP for super user creation */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
136 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
137 QQ int entries = 0; /* made direct page -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
138 QQ FILE *fp; /* */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
139 QQ PWENT *entry; /* */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
140
5ba8e711a1a3 source added
boisy
parents:
diff changeset
141
2106
c4c7facbd082 Fixed up some warnings
boisy
parents: 1772
diff changeset
142 int main (argc, argv)
1772
5ba8e711a1a3 source added
boisy
parents:
diff changeset
143 int argc;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
144 char *argv[];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
145 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
146 register int i; /* made register -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
147 int path, uloginpath;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
148 flag ipickit; /* added --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
149 unsigned userid;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
150 char *p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
151
5ba8e711a1a3 source added
boisy
parents:
diff changeset
152 /* Get the user's userid */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
153 /* Must be the superuser to add a new user */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
154
5ba8e711a1a3 source added
boisy
parents:
diff changeset
155 if ( getuid() )
5ba8e711a1a3 source added
boisy
parents:
diff changeset
156 exit (_errmsg (0, "%s\n", Sorry));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
157
5ba8e711a1a3 source added
boisy
parents:
diff changeset
158 /* need help? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
159 if (argc > 3 || strcmp (argv[1], "-?") == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
160 usage();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
161
5ba8e711a1a3 source added
boisy
parents:
diff changeset
162 *tempstr = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
163
5ba8e711a1a3 source added
boisy
parents:
diff changeset
164 #ifndef MARK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
165 if ((maildir = getenv ("MAIL")) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
166 maildir = strdup (maildir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
167 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
168 fatal ("MAIL is undefined");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
169
5ba8e711a1a3 source added
boisy
parents:
diff changeset
170 if ((logdir = getenv ("LOGDIR")) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
171 logdir = strdup (logdir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
172 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
173 logdir = LOGDIR;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
174 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
175 /* allow creation of super users? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
176 if (argc >= 2 && strcmp (argv[1], "-s") == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
177 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
178 if (argc == 3)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
179 strcpy (tempstr, argv[2]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
180 argc = 1; /* so that we don't get caught later on -- BGP */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
181 super = 0;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
182 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
183
5ba8e711a1a3 source added
boisy
parents:
diff changeset
184 /* delete a local user? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
185 if (argc >= 2 && strcmp (argv[1], "-r") == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
186 if (argc == 3)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
187 removeuser (argv[2]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
188 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
189 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
190 fputs ("adduser: -r requires a username\n\n", stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
191 usage();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
192 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
193
5ba8e711a1a3 source added
boisy
parents:
diff changeset
194 /* Set up some default password file entries -- edit as you require */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
195 strcpy (pw[PRI], "128");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
196 strcpy (pw[DIRX], "/dd/cmds");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
197 strcat (strcpy (pw[DIRW], userdir), "/");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
198 strcpy (pw[PASS], "000000");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
199 get_entries(); /* read the password file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
200
5ba8e711a1a3 source added
boisy
parents:
diff changeset
201 /* user name given on command line? --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
202 if (argc >= 2)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
203 strcpy (tempstr, argv[1]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
204
5ba8e711a1a3 source added
boisy
parents:
diff changeset
205 /* Get the new username. If they enter a 'Q', end the program.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
206 Otherwise, check to see if the username is already used. If it is,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
207 ask them for another one. */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
208 do
5ba8e711a1a3 source added
boisy
parents:
diff changeset
209 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
210 while (*tempstr == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
211 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
212 printf ("\nEnter username (Q to quit): ");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
213 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
214
5ba8e711a1a3 source added
boisy
parents:
diff changeset
215 if (mfgets (tempstr, sizeof (tempstr), stdin) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
216 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
217 errno = 0;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
218 fatal ("<ESC> hit...exiting");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
219 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
220 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
221
5ba8e711a1a3 source added
boisy
parents:
diff changeset
222 if (*tempstr == 'Q' || *tempstr == 'q')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
223 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
224 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
225 while ( chk_name() ); /* name already in use? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
226
5ba8e711a1a3 source added
boisy
parents:
diff changeset
227 if (strucmp (tempstr, daemon) == 0) /* user 'daemon' is special */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
228 isdaemon = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
229
5ba8e711a1a3 source added
boisy
parents:
diff changeset
230 strcat (pw[DIRW], tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
231 strcpy (pw[NAME], tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
232
5ba8e711a1a3 source added
boisy
parents:
diff changeset
233 /* user ID given on command line? --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
234 if (argc == 3)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
235 strcpy (tempstr, argv[2]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
236 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
237 *tempstr = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
238
5ba8e711a1a3 source added
boisy
parents:
diff changeset
239 /* Get the new user ID number -- make my own if user enters nothing
5ba8e711a1a3 source added
boisy
parents:
diff changeset
240 changed -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
241 putchar ('\n');
5ba8e711a1a3 source added
boisy
parents:
diff changeset
242 do
5ba8e711a1a3 source added
boisy
parents:
diff changeset
243 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
244 if (*tempstr == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
245 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
246 fputs (NewID, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
247 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
248
5ba8e711a1a3 source added
boisy
parents:
diff changeset
249 if (mfgets (tempstr, sizeof (tempstr), stdin) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
250 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
251 errno = 0;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
252 fatal ("<ESC> hit...exiting");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
253 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
254
5ba8e711a1a3 source added
boisy
parents:
diff changeset
255 if (*tempstr == 'Q' || *tempstr == 'q')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
256 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
257 else if (*tempstr == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
258 ipickit = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
259 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
260 ipickit = FALSE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
261 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
262 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
263 ipickit = FALSE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
264
5ba8e711a1a3 source added
boisy
parents:
diff changeset
265 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
266 userid = (unsigned) atoi (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
267 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
268 userid = (unsigned) uIDtoInt (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
269 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
270 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
271 while (chk_uid (&userid, ipickit));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
272
5ba8e711a1a3 source added
boisy
parents:
diff changeset
273 #ifdef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
274 p = InttouID (userid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
275 strcpy (pw[ID], p);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
276 free (p);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
277 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
278 sprintf (pw[ID], "%u", userid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
279 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
280 printf ("\nAdding new user '%s' as UID %s\n", pw[NAME], pw[ID]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
281
5ba8e711a1a3 source added
boisy
parents:
diff changeset
282 /* Create user login file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
283 sprintf (tempstr, "%s/%s.login", logdir, pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
284
5ba8e711a1a3 source added
boisy
parents:
diff changeset
285 if ((path = create (tempstr, S_IREAD+S_IWRITE, S_IREAD+S_IWRITE)) == ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
286 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
287 sprintf (tempstr, "%s.login already exists\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
288 fatal (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
289 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
290
5ba8e711a1a3 source added
boisy
parents:
diff changeset
291 close (path);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
292
5ba8e711a1a3 source added
boisy
parents:
diff changeset
293 /* Open and add user data to password file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
294 if ((fp = fopen (passfile, "a")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
295 fatal ("can't open password file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
296
5ba8e711a1a3 source added
boisy
parents:
diff changeset
297 for (i = 0; i < (PW_SIZE - 1); i++)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
298 fprintf (fp, "%s,", pw[i]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
299
5ba8e711a1a3 source added
boisy
parents:
diff changeset
300 /* Create the commands the user will use after logging in.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
301 Changed --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
302 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
303 # ifdef SHELLPLUS
5ba8e711a1a3 source added
boisy
parents:
diff changeset
304 /* turn off Shell+ shell variable expansion so MAIL works properly make
5ba8e711a1a3 source added
boisy
parents:
diff changeset
305 prompt user's name -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
306
5ba8e711a1a3 source added
boisy
parents:
diff changeset
307 fprintf (fp, "ulogin; ex shell -v p=\"%s\"\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
308 # else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
309 fprintf (fp, "ulogin;ex shell\n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
310 # endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
311 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
312 fprintf (fp, "ulogin;ex shell\n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
313 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
314 fclose (fp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
315
5ba8e711a1a3 source added
boisy
parents:
diff changeset
316 /* Create user directory with owner bits only set. */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
317 strcpy (tempstr, pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
318 sprintf (dirname, "%s/%s", userdir, strupr (tempstr));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
319 setuid (atoi (pw[ID])); /* set uid to new user */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
320
5ba8e711a1a3 source added
boisy
parents:
diff changeset
321 if ((mknod (dirname, S_IREAD+S_IWRITE+S_IEXEC)) == ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
322 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
323 sprintf (tempstr, "can't create user's home directory...error %d\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
324 errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
325 fatal (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
326 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
327
5ba8e711a1a3 source added
boisy
parents:
diff changeset
328 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
329 /* CoCo user needs a UUCP directory in their home directory for UUCPbb */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
330 sprintf (tempstr, "%s/UUCP", dirname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
331
5ba8e711a1a3 source added
boisy
parents:
diff changeset
332 if ((mknod (tempstr, S_IREAD+S_IWRITE+S_IEXEC)) == ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
333 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
334 sprintf (tempstr, "can't create user's home UUCP directory...error %d\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
335 errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
336 fatal (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
337 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
338 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
339
5ba8e711a1a3 source added
boisy
parents:
diff changeset
340 /* Create user mail directory with owner bits only set. Mail directory
5ba8e711a1a3 source added
boisy
parents:
diff changeset
341 is compatible with UUCPbb --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
342
5ba8e711a1a3 source added
boisy
parents:
diff changeset
343 /* user 'daemon' does not need a mail directory */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
344 if (!isdaemon)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
345 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
346 strcpy (tempstr, pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
347 sprintf (mailname, "%s/%s", maildir, strupr (tempstr));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
348
5ba8e711a1a3 source added
boisy
parents:
diff changeset
349 if ((mknod (mailname, S_IREAD+S_IWRITE+S_IEXEC)) == ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
350 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
351 sprintf (tempstr,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
352 "can't create user's mail directory '%s'...error %d\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
353 mailname, errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
354 fatal (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
355 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
356 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
357
5ba8e711a1a3 source added
boisy
parents:
diff changeset
358 /* Setup users login file in their directory */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
359 sprintf (tempstr, "%s/%s/ulogin", userdir, pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
360
5ba8e711a1a3 source added
boisy
parents:
diff changeset
361 /* changed -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
362 if ((uloginpath = create (tempstr, S_IWRITE, S_IREAD+S_IWRITE)) == ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
363 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
364 sprintf (tempstr, "Can't create user's ulogin file '%s'...error %d\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
365 tempstr, errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
366 fatal (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
367 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
368
5ba8e711a1a3 source added
boisy
parents:
diff changeset
369 /* now turn the path number in a file descriptor for writing -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
370 if ((fp = fdopen (uloginpath, "w")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
371 fatal ("can't create user's 'ulogin' file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
372
5ba8e711a1a3 source added
boisy
parents:
diff changeset
373 asetuid (0); /* set uid back to SuperUser */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
374
5ba8e711a1a3 source added
boisy
parents:
diff changeset
375 /* create user's ulogin file...moved -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
376 make_ulogin (fp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
377
5ba8e711a1a3 source added
boisy
parents:
diff changeset
378 /* make sure all I/O is flushed and chop off any junk at the end
5ba8e711a1a3 source added
boisy
parents:
diff changeset
379 before we close the file -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
380
5ba8e711a1a3 source added
boisy
parents:
diff changeset
381 fflush (fp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
382 _ss_size (uloginpath, ftell (fp));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
383 fclose (fp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
384
5ba8e711a1a3 source added
boisy
parents:
diff changeset
385 printf ("\n\nUser '%s' has been added to the system\n\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
386 printf ("**NOTE** the password for user '%s' is NOT set right now.\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
387 pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
388 puts (" You must use the utility PASSWORD to set it.\n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
389 free (maildir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
390 free (logdir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
391 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
392 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
393
5ba8e711a1a3 source added
boisy
parents:
diff changeset
394
5ba8e711a1a3 source added
boisy
parents:
diff changeset
395
5ba8e711a1a3 source added
boisy
parents:
diff changeset
396 /* Read the password file getting all the usernames and UID there. */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
397
5ba8e711a1a3 source added
boisy
parents:
diff changeset
398 int get_entries()
5ba8e711a1a3 source added
boisy
parents:
diff changeset
399 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
400 register char *p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
401 char tmpstr[PWSIZ];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
402 int line, badline;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
403
5ba8e711a1a3 source added
boisy
parents:
diff changeset
404 p = tmpstr;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
405 line = 0;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
406 badline = FALSE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
407
5ba8e711a1a3 source added
boisy
parents:
diff changeset
408 if ((fp = fopen (passfile, "r")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
409 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
410 sprintf (tempstr, "can't open password file...error %d\n", errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
411 fatal (tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
412 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
413
5ba8e711a1a3 source added
boisy
parents:
diff changeset
414 while (fgets (p, sizeof (tmpstr), fp) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
415 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
416 ++line;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
417
5ba8e711a1a3 source added
boisy
parents:
diff changeset
418 if (*p == '\n')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
419 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
420 fputs ("adduser: illegal password entry...line", stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
421 fprintf (stderr, "%d starts with a CR.\n", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
422 badline = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
423 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
424 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
425 fclose (fp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
426
5ba8e711a1a3 source added
boisy
parents:
diff changeset
427 if (badline)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
428 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
429 fputs ("There cannot be blank lines anywhere in the ", stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
430 fputs ("password file. These lines must\nbe fixed ", stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
431 fputs ("fixed before continuing.\n", stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
432 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
433 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
434
5ba8e711a1a3 source added
boisy
parents:
diff changeset
435 while((entry = getpwent()) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
436 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
437 if (entry == (PWENT *)ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
438 fatal ("error in the password file!");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
439
5ba8e711a1a3 source added
boisy
parents:
diff changeset
440 strcpy (u_name[entries], entry->unam);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
441 #ifndef OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
442 u_uid[entries++] = (unsigned) atoi (entry->uid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
443 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
444 u_uid[entries++] = (unsigned) uIDtoInt (entry->uid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
445 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
446 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
447 endpwent();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
448 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
449
5ba8e711a1a3 source added
boisy
parents:
diff changeset
450
5ba8e711a1a3 source added
boisy
parents:
diff changeset
451
5ba8e711a1a3 source added
boisy
parents:
diff changeset
452 /* Check password file entries. If 'ipickit' is FALSE, see if there is a
5ba8e711a1a3 source added
boisy
parents:
diff changeset
453 UID of the same number already used. If 'ipickit' is TRUE, pick the
5ba8e711a1a3 source added
boisy
parents:
diff changeset
454 next highest available UID. If all the UID (0-255) are picked, exit
5ba8e711a1a3 source added
boisy
parents:
diff changeset
455 with an error. Global variable 'tempstr' has the user ID to be checked
5ba8e711a1a3 source added
boisy
parents:
diff changeset
456 on entry. If the user ID is already used, we exit with 'tempstr' set
5ba8e711a1a3 source added
boisy
parents:
diff changeset
457 to a NULL string. -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
458
5ba8e711a1a3 source added
boisy
parents:
diff changeset
459 int chk_uid (uid, ipickit)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
460 int ipickit;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
461 unsigned *uid;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
462 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
463 register int i; /* made register -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
464 unsigned j; /* added -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
465
5ba8e711a1a3 source added
boisy
parents:
diff changeset
466 /* UID was passed to us, is it taken? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
467 if (!ipickit)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
468 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
469 for (i = 0; i < entries; i++)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
470 if (*uid == u_uid[i])
5ba8e711a1a3 source added
boisy
parents:
diff changeset
471 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
472 fprintf (stderr, "\nUID '%d' is already used\n\n", *uid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
473 *tempstr = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
474 return (TRUE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
475 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
476 return (FALSE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
477 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
478 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
479 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
480 /* we have to pick the UID. find the lowest unused one */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
481 for (j = super; j < 65536; ++j)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
482 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
483 for (i = 0; i < entries; i++)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
484 if (j == u_uid[i])
5ba8e711a1a3 source added
boisy
parents:
diff changeset
485 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
486
5ba8e711a1a3 source added
boisy
parents:
diff changeset
487 /* didn't find a match, this is our UID */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
488 if (i == entries)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
489 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
490 *uid = j;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
491 return (FALSE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
492 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
493 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
494
5ba8e711a1a3 source added
boisy
parents:
diff changeset
495 /* all 65535 user IDs are taken (wow!) */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
496 fatal ("all user IDs are used");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
497 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
498 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
499
5ba8e711a1a3 source added
boisy
parents:
diff changeset
500
5ba8e711a1a3 source added
boisy
parents:
diff changeset
501
5ba8e711a1a3 source added
boisy
parents:
diff changeset
502 /* Check the password file entries and see if the username entered is
5ba8e711a1a3 source added
boisy
parents:
diff changeset
503 already in the file. global variable 'tempstr' has the username on
5ba8e711a1a3 source added
boisy
parents:
diff changeset
504 entry. */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
505
5ba8e711a1a3 source added
boisy
parents:
diff changeset
506 int chk_name()
5ba8e711a1a3 source added
boisy
parents:
diff changeset
507 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
508 register int i; /* made register -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
509
5ba8e711a1a3 source added
boisy
parents:
diff changeset
510 for (i = 0; i < entries; i++)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
511 if ((strucmp (tempstr, u_name[i])) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
512 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
513 fprintf (stderr, "\nUsername '%s' already exists\n", tempstr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
514
5ba8e711a1a3 source added
boisy
parents:
diff changeset
515 if (strucmp (tempstr, daemon) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
516 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
517 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
518 *tempstr = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
519
5ba8e711a1a3 source added
boisy
parents:
diff changeset
520 return (TRUE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
521 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
522 return (FALSE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
523 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
524
5ba8e711a1a3 source added
boisy
parents:
diff changeset
525
5ba8e711a1a3 source added
boisy
parents:
diff changeset
526
5ba8e711a1a3 source added
boisy
parents:
diff changeset
527 /* make the user's ulogin file...expanded -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
528
5ba8e711a1a3 source added
boisy
parents:
diff changeset
529 int make_ulogin (fptr)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
530 FILE *fptr;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
531 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
532 char script[256], answer, get_yn();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
533 int done = FALSE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
534
5ba8e711a1a3 source added
boisy
parents:
diff changeset
535 /* user 'daemon' has a really short login script */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
536 if (isdaemon)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
537 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
538 fputs ("echo daemon is logged in; echo", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
539 return (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
540 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
541
5ba8e711a1a3 source added
boisy
parents:
diff changeset
542 while (!done)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
543 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
544 /* start script */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
545 fprintf (fptr, "* Login file for %s *\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
546
5ba8e711a1a3 source added
boisy
parents:
diff changeset
547
5ba8e711a1a3 source added
boisy
parents:
diff changeset
548 cls();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
549 printf ("Do you wish to customize %s's login script?\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
550 fputs (" (NO means use default script) y/n --> ", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
551 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
552 answer = get_yn();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
553
5ba8e711a1a3 source added
boisy
parents:
diff changeset
554 /* customize our own ulogin script */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
555 if (answer == 'y')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
556 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
557 cls();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
558 printf (" ");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
559 ReVOn();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
560 printf (" Customize ulogin script ");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
561 ReVOff();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
562 puts ("\nEnter commands one line at time. Check for waiting mail has already been");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
563 puts ("included at the beginning of the script.\n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
564 puts ("<ENTER> only for any line ends the customizing. If you make a mistake, end");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
565 fputs ("customizing and answer 'N' (no) to 'Script okay?' prompt. You may then start\nover.\n", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
566 #ifdef SSP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
567 puts ("\nYou may send text to the Speech Sound Pak by redirecting it. For example:");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
568 puts (" echo hi there >/ssp");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
569 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
570 fputs ("\nHit <ENTER> to begin --> ", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
571 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
572 answer = getchar();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
573 cls();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
574 ReVOn();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
575 fputs (" ulogin script so far: ", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
576 ReVOff();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
577 puts ("\n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
578
5ba8e711a1a3 source added
boisy
parents:
diff changeset
579 /* put in the standard stuff */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
580 fputs ("-x\n", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
581 puts ("-x");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
582 fprintf (fptr, "list %s\n", motd);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
583 printf ("list %s\n", motd);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
584 fputs ("echo\n", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
585 puts ("echo");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
586 #ifndef SSP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
587 fprintf (fptr, "echo Hello %s\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
588 printf ("echo Hello %s\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
589 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
590 /* Send 'hello <name>' to speech pak if SSP is set -- CNO */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
591 fprintf (fptr, "echo Hello %s >/ssp&\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
592 printf ("echo Hello %s >/ssp&\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
593 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
594 /* This line is specific to the mail utility packaged with the
5ba8e711a1a3 source added
boisy
parents:
diff changeset
595 OS9 uucp port. Added code for Rick Adams' UUCP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
596 enhancements -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
597 #ifdef MARK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
598 fputs ("lmail -c\n", fptr); /* Mark's original UUCP */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
599 puts ("lmail -c");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
600 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
601 fputs ("mailx -c\n", fptr); /* Rick Adams' UUCP */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
602 puts ("mailx -c");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
603 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
604 putchar ('\n');
5ba8e711a1a3 source added
boisy
parents:
diff changeset
605 ReVOn();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
606 printf (" Continue script... ");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
607 ReVOff();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
608 puts("\n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
609
5ba8e711a1a3 source added
boisy
parents:
diff changeset
610 for (;;)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
611 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
612 fgets (script, sizeof (script), stdin);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
613
5ba8e711a1a3 source added
boisy
parents:
diff changeset
614 if (*script == '\n')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
615 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
616 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
617 fputs (script, fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
618 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
619
5ba8e711a1a3 source added
boisy
parents:
diff changeset
620 fputs ("\nScript okay? (y/n) --> ", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
621 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
622 answer = get_yn();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
623
5ba8e711a1a3 source added
boisy
parents:
diff changeset
624 if (answer == 'y')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
625 done = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
626 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
627 rewind (fptr); /* try again */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
628 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
629 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
630 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
631 /* make the default login script */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
632 fputs ("-x\n", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
633 fprintf (fptr, "list %s\n", motd);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
634 fputs("x\n", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
635 fputs ("echo\n", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
636 #ifndef SSP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
637 fprintf (fptr, "echo Hello %s\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
638 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
639 /* Send 'hello <name>' to speech pak if SSP is set -- CNO */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
640 fprintf (fptr, "echo Hello %s >/ssp&\n", pw[NAME]);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
641 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
642 /* This line is specific to the mail utility packaged with the
5ba8e711a1a3 source added
boisy
parents:
diff changeset
643 OS9 uucp port. Added code for Rick Adams' UUCP enhancement
5ba8e711a1a3 source added
boisy
parents:
diff changeset
644 -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
645 #ifdef MARK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
646 fputs ("lmail -c\n", fptr); /* Mark's original mailer */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
647 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
648 fputs ("mailx -c\n", fptr); /* UUCPbb */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
649 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
650 fputs ("echo\n", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
651 fputs ("echo Please use the 'bye' command to log off\n\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
652 fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
653 done = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
654 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
655 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
656 fputs ("* End of Script *\n", fptr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
657 return (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
658 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
659
5ba8e711a1a3 source added
boisy
parents:
diff changeset
660
5ba8e711a1a3 source added
boisy
parents:
diff changeset
661
5ba8e711a1a3 source added
boisy
parents:
diff changeset
662 /* get a single character response from the user. Added --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
663
5ba8e711a1a3 source added
boisy
parents:
diff changeset
664 char get_yn()
5ba8e711a1a3 source added
boisy
parents:
diff changeset
665 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
666 char answer;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
667
5ba8e711a1a3 source added
boisy
parents:
diff changeset
668 echo (OFF);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
669
5ba8e711a1a3 source added
boisy
parents:
diff changeset
670 for (;;)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
671 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
672 while (_gs_rdy (0) <= 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
673 tsleep (4);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
674
5ba8e711a1a3 source added
boisy
parents:
diff changeset
675 read (0, &answer, 1);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
676 answer &= 0xff;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
677 answer = tolower (answer);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
678
5ba8e711a1a3 source added
boisy
parents:
diff changeset
679 if (answer == 'y' || answer == 'n')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
680 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
681 putchar (answer);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
682 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
683 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
684 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
685
5ba8e711a1a3 source added
boisy
parents:
diff changeset
686 echo (ON);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
687 return (answer);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
688 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
689
5ba8e711a1a3 source added
boisy
parents:
diff changeset
690
5ba8e711a1a3 source added
boisy
parents:
diff changeset
691
5ba8e711a1a3 source added
boisy
parents:
diff changeset
692 /* Turn off or on echo on the standard input path --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
693
5ba8e711a1a3 source added
boisy
parents:
diff changeset
694 int echo (onoroff)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
695 int onoroff;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
696 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
697 struct sgbuf stdinpath;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
698
5ba8e711a1a3 source added
boisy
parents:
diff changeset
699 _gs_opt (1, &stdinpath);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
700 stdinpath.sg_echo = onoroff; /* switch standard input echo */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
701 _ss_opt (1, &stdinpath); /* update the path descriptor */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
702 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
703
5ba8e711a1a3 source added
boisy
parents:
diff changeset
704
5ba8e711a1a3 source added
boisy
parents:
diff changeset
705
5ba8e711a1a3 source added
boisy
parents:
diff changeset
706 /* Convert a string to upper case. Returns a pointer to the start of the
5ba8e711a1a3 source added
boisy
parents:
diff changeset
707 string. --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
708
5ba8e711a1a3 source added
boisy
parents:
diff changeset
709 char *strupr (string)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
710 char *string;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
711 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
712 register char *p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
713
5ba8e711a1a3 source added
boisy
parents:
diff changeset
714 p = string;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
715 while (*p)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
716 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
717 *p = toupper (*p);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
718 ++p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
719 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
720 return (string);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
721 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
722
5ba8e711a1a3 source added
boisy
parents:
diff changeset
723
5ba8e711a1a3 source added
boisy
parents:
diff changeset
724
5ba8e711a1a3 source added
boisy
parents:
diff changeset
725 int usage()
5ba8e711a1a3 source added
boisy
parents:
diff changeset
726 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
727 char temp[80], *strdetab();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
728 register char **use;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
729 static char *usetext[] = {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
730 "ADDUSER: add a user to or remove a user from the system",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
731 "Usage: adduser [opts] [<username> [<userid>] ]",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
732 " ",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
733 "opts: -r <username> - remove <username> from the system",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
734 " -s - allow the creation of super users",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
735 "\t-?\t\t - this message",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
736 " ",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
737 "\tacceptable command lines are:",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
738 "\t adduser",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
739 "\t adduser <username>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
740 "\t adduser <username> <userid>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
741 "\t adduser -r <username>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
742 "\t adduser -s <username>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
743 NULL
5ba8e711a1a3 source added
boisy
parents:
diff changeset
744 };
5ba8e711a1a3 source added
boisy
parents:
diff changeset
745
5ba8e711a1a3 source added
boisy
parents:
diff changeset
746 for (use = usetext; *use != NULL; ++use)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
747 fprintf (stderr, " %s\n", strdetab (strcpy (temp, *use), 6));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
748
5ba8e711a1a3 source added
boisy
parents:
diff changeset
749 fprintf (stderr, "\nv%s (%s) This is free software released under the GNU General Public\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
750 version, VERDATE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
751 fputs ("License. Please send suggestions/bug reports to: bob@kc2wz.bubble.org\n", stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
752 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
753 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
754
5ba8e711a1a3 source added
boisy
parents:
diff changeset
755
5ba8e711a1a3 source added
boisy
parents:
diff changeset
756
5ba8e711a1a3 source added
boisy
parents:
diff changeset
757 int fatal (msg)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
758 char *msg;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
759 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
760 fprintf (stderr, "adduser: %s", msg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
761
5ba8e711a1a3 source added
boisy
parents:
diff changeset
762 if (errno != 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
763 fprintf (stderr, "...error %d", errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
764
5ba8e711a1a3 source added
boisy
parents:
diff changeset
765 putc ('\n', stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
766 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
767 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
768
5ba8e711a1a3 source added
boisy
parents:
diff changeset
769
5ba8e711a1a3 source added
boisy
parents:
diff changeset
770
5ba8e711a1a3 source added
boisy
parents:
diff changeset
771 int removeuser (username)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
772 char *username;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
773 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
774 userbegone (username);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
775 fatal ("removing user is not implemented yet");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
776 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
777
5ba8e711a1a3 source added
boisy
parents:
diff changeset
778
5ba8e711a1a3 source added
boisy
parents:
diff changeset
779
5ba8e711a1a3 source added
boisy
parents:
diff changeset
780 int userbegone (name)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
781 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
782 }