diff -ur proftpd-1.2.5rc3/modules/mod_auth.c proftpd-1.2.5rc3+bif/modules/mod_auth.c --- proftpd-1.2.5rc3/modules/mod_auth.c Tue May 21 22:47:16 2002 +++ proftpd-1.2.5rc3+bif/modules/mod_auth.c Thu Jun 6 15:29:33 2002 @@ -1364,6 +1364,34 @@ * if this would exceed the max. */ maxc = find_config((c ? c->subset : cmd->server->conf), + CONF_PARAM, "MaxClientsPerUser", FALSE); + + if(maxc && (int)maxc->argv[0] != -1) { + int max = (int) maxc->argv[0]; + char *maxstr = "Sorry, the maximum number of clients (%m) you are allowed are " + "already connected."; + char maxn[10] = {'\0'}; + + snprintf(maxn, sizeof(maxn), "%d", max); + + if(maxc->argc > 1) + maxstr = maxc->argv[1]; + + if(usersessions >= max) { + send_response(R_530, "%s", + sreplace(cmd->tmp_pool,maxstr, "%m", maxn, NULL)); + + remove_config(cmd->server->conf, C_USER, FALSE); + remove_config(cmd->server->conf, C_PASS, FALSE); + + log_auth(LOG_NOTICE, "Connection refused (max clients per user %s).", + user); + + end_login(0); + } + } + + maxc = find_config((c ? c->subset : cmd->server->conf), CONF_PARAM, "MaxClientsPerHost", FALSE); if(maxc && (int)maxc->argv[0] != -1) { diff -ur proftpd-1.2.5rc3/modules/mod_core.c proftpd-1.2.5rc3+bif/modules/mod_core.c --- proftpd-1.2.5rc3/modules/mod_core.c Tue May 21 22:47:16 2002 +++ proftpd-1.2.5rc3+bif/modules/mod_core.c Wed Jun 5 21:02:54 2002 @@ -488,6 +488,38 @@ return HANDLED(cmd); } +MODRET set_maxuserclients(cmd_rec *cmd) +{ + int max; + char *endp; + config_rec *c; + + CHECK_CONF(cmd, CONF_ROOT | CONF_VIRTUAL | CONF_ANON | CONF_GLOBAL); + + if(cmd->argc < 2 || cmd->argc > 3) + CONF_ERROR(cmd, "invalid number of arguments"); + + if(!strcasecmp(cmd->argv[1], "none")) { + max = -1; + } else { + max = (int) strtol(cmd->argv[1], &endp, 10); + + if((endp && *endp) || max < 1) + CONF_ERROR(cmd, "argument must be 'none' or a number greater than 0."); + } + + if(cmd->argc == 3) { + c = add_config_param("MaxClientsPerUser", 2, (void *) max, NULL); + c->argv[1] = pstrdup(c->pool, cmd->argv[2]); + } else { + c = add_config_param("MaxClientsPerUser", 1, (void *) max); + } + + c->flags |= CF_MERGEDOWN; + + return HANDLED(cmd); +} + MODRET set_maxhostclients(cmd_rec *cmd) { int max; @@ -3282,6 +3314,7 @@ { "MasqueradeAddress", add_masqueradeaddress, NULL }, { "MaxClients", set_maxclients, NULL }, { "MaxClientsPerHost", set_maxhostclients, NULL }, + { "MaxClientsPerUser", set_maxuserclients, NULL }, { "MaxHostsPerUser", set_maxhostsperuser, NULL }, { "MaxInstances", set_maxinstances, NULL }, { "MaxLoginAttempts", set_maxloginattempts, NULL },