2 Copyright (c) 1993 Richard V. Nash.
3 Copyright (c) 2000 Dan Papasian
4 Copyright (C) Andrew Tridgell 2002
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 static void usage(char *progname)
25 d_printf( "Usage: %s [-l] [-n] UserName FullName EmailAddress\n", progname);
31 static char *funame = NULL, *fname = NULL, *email = NULL;
33 unsigned chessd_reload_flag;
36 int main(int argc, char *argv[])
40 char password[PASSLEN + 1];
47 while((ch = getopt(argc, argv, "lna:")) != -1) {
60 funame = strdup(argv[argc-3]);
61 fname = strdup(argv[argc-2]);
62 email = strdup(argv[argc-1]);
63 if (!funame || !fname || !email)
66 /* Add the player here */
67 if (strlen(funame) >= MAX_LOGIN_NAME) {
68 d_printf( "Player name is too long\n");
71 if (strlen(funame) < 3) {
72 d_printf( "Player name is too short\n");
75 if (!alphastring(funame)) {
76 d_printf( "Illegal characters in player name. Only A-Za-z allowed.\n");
82 if (!player_read(p, funame)) {
83 d_printf( "%s already exists.\n", funame);
87 pp = &player_globals.parray[p];
89 pp->name = strdup(funame);
90 pp->login = strdup(funame);
91 pp->adminLevel = admin;
94 pp->fullName = strdup(fname);
95 pp->emailAddress = strdup(email);
96 for (i = 0; i < PASSLEN; i++) {
97 password[i] = 'a' + random() % 26;
100 salt[0] = 'a' + random() % 26;
101 salt[1] = 'a' + random() % 26;
103 pp->passwd = strdup(chessd_crypt(password,salt));
104 PFlagON(p, PFLAG_REG);
105 /* pp->network_player = !local; */
106 PFlagON(p, PFLAG_RATED);
108 /* changed by Sparky 12/15/95 Dropped reference to 'Network' players
111 printf("Added %s player >%s< >%s< >%s< >%s<\n", local ? "local" : "network",
112 funame, fname, email, password);
113 rasprintf(&text, "\nYou have been added as a %s player.\nIf this is a network account it may take a while to show up on all of the\nclients.\n\nLogin Name: %s\nFull Name: %s\nEmail Address: %s\nInitial Password: %s\n\nIf any of this information is incorrect, please contact the administrator\nto get it corrected.\nPlease write down your password, as it will be your initial passoword\non all of the servers.\n", local ? "local" : "network", funame, fname, email, password);
116 printf("Added %s account: >%s< >%s< >%s< >%s<\n",
117 admin?"ADMIN":"player",
118 funame, fname, email, password);
120 asprintf(&text, "\nYour player account has been created.\n\n"
121 "Login Name: %s\nFull Name: %s\nEmail Address: %s\nInitial Password: %s\n\n"
122 "If any of this information is incorrect, please contact the administrator\n"
123 "to get it corrected.\n\n"
124 "You may change your password with the password command on the the server.\n"
125 "\nPlease be advised that if this is an unauthorized duplicate account for\n"
126 "you, by using it you take the risk of being banned from accessing this\n"
128 "Regards,\n\nThe FICS admins\n",
129 funame, fname, email, password);
133 mail_string_to_address(email, "FICS Account Created", text);