Commit 5be21eb1 authored by Andrew Price's avatar Andrew Price

Make the new user sign up process more sensible

Rearrange the order of the questions new users are asked, use more
welcoming words and separate out the data protection statement into a
config file (/etc/mw/data_usage.txt by default).
parent 4e82e903
......@@ -18,6 +18,7 @@ bindir ?= $(prefix)/bin
datadir ?= $(prefix)/share
localstatedir ?= /var
initddir ?= /etc/init.d
sysconfdir ?= /etc
LOGDIR := $(localstatedir)/log/mw
MSGDIR := $(localstatedir)/run/mw
......@@ -57,6 +58,7 @@ DEFS+= -DHOMEPATH=\"$(HOMEPATH)\"
DEFS+= -DLOGDIR=\"$(LOGDIR)\"
DEFS+= -DSTATEDIR=\"$(STATEDIR)\"
DEFS+= -DMSGDIR=\"$(MSGDIR)\"
DEFS+= -DSYSCONFDIR=\"$(sysconfdir)\"
DEFS+= -D_GNU_SOURCE
......
......@@ -38,9 +38,16 @@ test testclean:
$(MAKE) TESTDIR="$(CURDIR)/mwtest" $@
else
test:
$(MAKE) -C $(SRCROOT) libdir="$(TESTDIR)" localstatedir="$(TESTDIR)" install-home
$(MAKE) -C $(SRCROOT) \
libdir="$(TESTDIR)" \
localstatedir="$(TESTDIR)" \
sysconfdir="$(TESTDIR)/etc" \
install-home
cd "$(TESTDIR)" && mkdir -p mw run/mw log/mw lib/mw
$(MAKE) libdir="$(TESTDIR)" localstatedir="$(TESTDIR)" all
$(MAKE) libdir="$(TESTDIR)" \
localstatedir="$(TESTDIR)" \
sysconfdir="$(TESTDIR)/etc" \
all
$(MAKE) -C utils libdir="$(TESTDIR)" localstatedir="$(TESTDIR)" all
testclean: clean
......
......@@ -18,6 +18,10 @@
#define MSGDIR "/run/mw"
#endif
#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif
#define LOGIN_BANNER HOMEPATH"/login.banner"
#define LOCKFILE "/tmp/bb.locked"
#define EDITOR "/usr/bin/vim"
......
......@@ -12,6 +12,7 @@
#include <pwd.h>
#include <time.h>
#include <stdbool.h>
#include <errno.h>
#include <mwlog.h>
#include "special.h"
......@@ -232,6 +233,28 @@ MAX OF 10 MESSAGES IN THE LAST 2 WEEKS
return ret;
}
static void print_data_usage_stmt(void)
{
const char *path = SYSCONFDIR"/mw/data_usage.txt";
FILE *fpin, *fpout = stdout;
char buf[256] = {0};
size_t bytes;
fpin = fopen(path, "r");
if (fpin == NULL) {
if (errno != ENOENT)
perror(path);
return;
}
do {
bytes = fread(buf, 1, 256, fpin);
fwrite(buf, 1, bytes, fpout);
} while (bytes == 256);
fflush(fpout);
fclose(fpin);
printf("\n");
}
static int new_usr(char *name, struct user *u)
{
char passwd[PASSWDSIZE],passwd2[PASSWDSIZE],salt[3];
......@@ -245,31 +268,16 @@ static int new_usr(char *name, struct user *u)
strcpy(c, "y");
}
}while (!*c);
printf("\n");
if(*c=='y' || *c=='Y')
{
int diff=false;
pick_salt(salt);
printf(_("We use a password on this BB.\n"));
fflush(stdout);
do{
if (diff) printf(_("Passwords did not match.\n"));
strcpy(passwd,crypt(get_pass(_("Enter password: ")),salt));
strcpy(passwd2,crypt(get_pass(_("Re-enter password: ")),salt));
}while ((diff=strcmp(passwd,passwd2)));
strncpy(usr->passwd,passwd,PASSWDSIZE);
strncpy(usr->name,name,NAMESIZE);
printf(_("\nPlease enter the following details so that we can register you as a\n"));
printf(_("normal user of this bulletin board. without correct information you\n"));
printf(_("will not be allowed to use the full facilities of this board.\n"));
printf(_("\nDATA PROTECTION ACT:\n"));
printf(_("Any data entered will be recorded in a computer database for the purpose\n"));
printf(_("of the administration, operation and security of the computer society. By \n"));
printf(_("entering this data you consent to the storage of this data, and become an\n"));
printf(_("associate member of the society.\n"));
printf(_("\nIf you do not wish to register, do not enter a name.\n\n"));
strncpy(usr->name, name, NAMESIZE);
print_data_usage_stmt();
printf(_("Please enter the following details to set up your Milliways user account.\n"));
printf(_("If you do not wish to register, do not enter a name.\n"));
printf("\n");
printf(_("Real name: "));
usr->realname[0]=0;
......@@ -286,6 +294,16 @@ static int new_usr(char *name, struct user *u)
get_str(usr->contact,CONTACTSIZE);
strip_str(usr->contact);
pick_salt(salt);
fflush(stdout);
do {
if (diff)
printf(_("Passwords did not match.\n"));
strcpy(passwd, crypt(get_pass(_("Enter password: ")), salt));
strcpy(passwd2, crypt(get_pass(_("Re-enter password: ")), salt));
} while ((diff = strcmp(passwd,passwd2)));
strncpy(usr->passwd, passwd, PASSWDSIZE);
mwlog(user, "CREATED: %s <%s>",usr->realname, usr->contact);
int ret = 2; /* New user */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment