Changed username tests

This commit is contained in:
Michiel Broek 2002-07-28 12:31:28 +00:00
parent 38f0cb2e8c
commit d28605477c
6 changed files with 129 additions and 70 deletions

View File

@ -33,6 +33,9 @@ v0.35.03 06-Jul-2002
newuser:
Check for Unix accounts is now case sensitive.
Check existing usernames now also checks handles.
Check for existing Unix names now also includes the name ping
and services names.
Check for handle now also checks Unix names.
mbsebbs:
Check existing usernames now also checks handles.
@ -40,6 +43,8 @@ v0.35.03 06-Jul-2002
expired, the bbs crashed.
Fixed a problem with extra spaces in UUCP replyto address.
Added test for HA archiver.
When changing a Handle, Unix names are checked as forbidden
names as well.
mbtask:
Changed logging of multiple logmessages that are equal.

View File

@ -230,32 +230,25 @@ int CheckHandle(char *Name)
{
FILE *fp;
int Status = FALSE;
char *temp, *temp1;
struct userhdr uhdr;
struct userrec u;
char *temp;
temp = calloc(PATH_MAX, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char));
strcpy(temp1, tl(Name));
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp,"rb")) != NULL) {
fread(&uhdr, sizeof(uhdr), 1, fp);
while (fread(&u, uhdr.recsize, 1, fp) == 1) {
strcpy(temp, tl(u.sHandle));
if((strcmp(temp, temp1)) == 0) {
if ((strcasecmp(u.sHandle, Name)) == 0) {
Status = TRUE;
break;
}
}
free(temp);
free(temp1);
fclose(fp);
}
free(temp);
return Status;
}
@ -287,26 +280,21 @@ void Chg_Handle()
free(temp);
return;
}
strcpy(Handle, tlcap(temp));
strcpy(Handle, tl(temp));
if (CheckHandle(Handle))
if (CheckHandle(Handle) || CheckUnixNames(Handle)) {
pout(12, 0, (char *)"\nThat handle is already been used\n");
else
if (CheckName(Handle))
} else if (CheckName(Handle)) {
pout(12, 0, (char *)"\nThat name is already been used\n");
else
if((strcmp(Handle, "sysop")) == 0)
} else if((strcmp(Handle, "sysop")) == 0) {
pout(12, 0, (char *)"\nYou cannot use Sysop as a handle\n");
else {
if(strcmp(temp, "") != 0) {
} else if(strcmp(temp, "") != 0) {
Setup(exitinfo.sHandle, temp);
pout(10, 0, (char *)"\nHandle Changed!\n\n");
Syslog('+', "New handle \"%s\"", exitinfo.sHandle);
break;
}
}
}
WriteExitinfo();
free(temp);

View File

@ -109,6 +109,69 @@ int CheckName(char *Name)
/*
* Check several Unix names and other build-in system names
* that are forbidden to select for new users.
*/
int CheckUnixNames(char *name)
{
struct passwd *pw;
char *temp;
FILE *fp;
int rc = FALSE;
/*
* Basic checks
*/
if (name == NULL)
rc = TRUE;
else if (strlen(name) == 0)
rc = TRUE;
else if (strlen(name) > 8)
rc = TRUE;
/*
* Check Unix names in the password file
*/
if (! rc) {
if ((pw = getpwnam(name)) != NULL)
rc = TRUE;
endpwent();
}
/*
* Username ping is used by the PING function
*/
if (! rc) {
if (strcasecmp(name, (char *)"ping") == 0)
rc = TRUE;
}
/*
* Check service names
*/
if (! rc) {
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/service.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) != NULL) {
fread(&servhdr, sizeof(servhdr), 1, fp);
while (fread(&servrec, servhdr.recsize, 1, fp) == 1) {
if ((strcasecmp(servrec.Service, name) == 0) && servrec.Active) {
rc = TRUE;
break;
}
}
fclose(fp);
}
free(temp);
}
return rc;
}
/*
* Function will check and create a home directory for the user if
* needed. It will also change into the users home directory when

View File

@ -6,6 +6,7 @@
void UserSilent(int); /* Update users silent flag info */
int CheckStatus(void); /* Check BBS open status */
int CheckUnixNames(char *); /* Check Unix and other forbidden names */
int CheckName(char *); /* Check if user name exists */
char *ChangeHomeDir(char *, int); /* Change and Create Users Home Directories */
void CheckDir(char *); /* Check and create directory */

View File

@ -335,8 +335,9 @@ int newuser()
alarm_on();
Getname(temp, 34);
badname = (BadNames(temp) || CheckName(temp));
badname = (strlen(temp) && (BadNames(temp) || CheckName(temp) || CheckUnixNames(temp)));
if (badname) {
Syslog('+', "User tried \"%s\" as Handle", MBSE_SS(temp));
/* That login name already exists, please choose another one. */
language(LIGHTRED, BLACK, 386);
Enter(1);
@ -604,12 +605,11 @@ void Good_Bye(int onsig)
char *NameGen(char *FidoName)
{
char *sUserName;
struct passwd *pw;
sUserName = calloc(10, sizeof(char));
Syslog('+', "NameGen(%s)", FidoName);
while ((strcmp(sUserName, "") == 0) || ((pw = getpwnam(sUserName)) != NULL) || (strlen(sUserName) < 3)) {
while ((strcmp(sUserName, "") == 0) || (CheckUnixNames(sUserName)) || (strlen(sUserName) < 3)) {
colour(LIGHTRED, BLACK);
printf("\n%s\n\n", (char *) Language(381));
colour(WHITE, BLACK);
@ -624,10 +624,11 @@ char *NameGen(char *FidoName)
fflush(stdin);
GetstrU(sUserName, 7);
if ((pw = getpwnam(sUserName)) != NULL) {
if (CheckUnixNames(sUserName)) {
/* That login name already exists, please choose another one. */
colour(LIGHTRED, BLACK);
printf("\n%s\n", (char *) Language(386));
Syslog('+', "Users tried to use \"%s\" as Unix name", MBSE_SS(sUserName));
}
}
return sUserName;
@ -706,6 +707,7 @@ int BadNames(char *Username)
Striplf(String);
if ((strstr(User, String)) != NULL) {
printf("\nSorry that name is not acceptable on this system\n");
Syslog('+', "User tried username \"%s\", found in %s", Username, temp);
iFoundName = TRUE;
break;
}

View File

@ -1 +1 @@
filelist installinit.log
filelist editor installinit.log