[mw-devel] [Git][arthur/mw][master] 2 commits: Make the new user sign up process more sensible

Andrew Price welshbyte at sucs.org
Thu Dec 6 19:59:04 GMT 2018


Andrew Price pushed to branch master at Justin Mitchell / mw


Commits:
5be21eb1 by Andrew Price at 2018-12-06T19:49:08Z
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).

- - - - -
0d769674 by Andrew Price at 2018-12-06T19:57:09Z
Don't capitalise the builder's username

Seems a bit pointless. Also this is a portability improvement since it
doesn't work on *BSD.

- - - - -


4 changed files:

- Makefile.common
- src/Makefile
- src/bb.h
- src/client/user.c


Changes:

=====================================
Makefile.common
=====================================
@@ -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
@@ -51,12 +52,13 @@ LDSEC = -pie -Wl,-z,relro,-z,now
 
 # info strings, do not edit.
 DEFS:= -DBUILD_DATE=\"$(shell date +%Y%m%d)\"
-DEFS+= -DBUILD_USER=\"$(shell whoami | sed 's/^./\u&/')\"
+DEFS+= -DBUILD_USER=\"$(shell whoami)\"
 DEFS+= -DVERSION=\"$(VERSION)\"
 DEFS+= -DHOMEPATH=\"$(HOMEPATH)\"
 DEFS+= -DLOGDIR=\"$(LOGDIR)\"
 DEFS+= -DSTATEDIR=\"$(STATEDIR)\"
 DEFS+= -DMSGDIR=\"$(MSGDIR)\"
+DEFS+= -DSYSCONFDIR=\"$(sysconfdir)\"
 
 DEFS+= -D_GNU_SOURCE
 


=====================================
src/Makefile
=====================================
@@ -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


=====================================
src/bb.h
=====================================
@@ -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"


=====================================
src/client/user.c
=====================================
@@ -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 */



View it on GitLab: https://projects.sucs.org/arthur/mw/compare/4e82e903f326d269f702ccd63803473afa70a6cb...0d769674780a561697a1b179b7e9b38acb8549df

-- 
View it on GitLab: https://projects.sucs.org/arthur/mw/compare/4e82e903f326d269f702ccd63803473afa70a6cb...0d769674780a561697a1b179b7e9b38acb8549df
You're receiving this email because of your account on projects.sucs.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20181206/e1e9abf8/attachment-0001.html>


More information about the mw-devel mailing list