void bftpdutmp_end() { if (bftpdutmp) { if (bftpdutmp_offset != -1) bftpdutmp_log(0); fclose(bftpdutmp); bftpdutmp = NULL; } }
void bftpdutmp_end() { #ifdef TC_REMOVE if (bftpdutmp) { if (bftpdutmp_offset != -1) bftpdutmp_log(0); fclose(bftpdutmp); bftpdutmp = NULL; } #endif }
int bftpd_login(char *password) { #if 0 // brcm char str[256]; char *foo; int maxusers; #endif //brcm //printf("In bftpd_login password=%s, user=%s\n", password, user); // brcm if (!getpwnam(user)) { control_printf(SL_FAILURE, "421 Login incorrect."); return 1; } // brcm add local/remote login check if ((glbAccessMode == CLI_ACCESS_LOCAL && (strcmp(user, "user") && strcmp(user, "root"))) || (glbAccessMode == CLI_ACCESS_REMOTE && strcmp(user, "support"))) { control_printf(SL_FAILURE, "421 Login incorrect."); return 1; } #if 0 //brcm if (strncasecmp(foo = config_getoption("DENY_LOGIN"), "no", 2)) { if (foo[0] != '\0') { if (strncasecmp(foo, "yes", 3)) control_printf(SL_FAILURE, "421-Server disabled.\r\n421 Reason: %s", foo); else control_printf(SL_FAILURE, "421 Login incorrect."); bftpd_log("Login as user '%s' failed: Server disabled.\n", user); exit(0); } } maxusers = strtoul(config_getoption("USERLIMIT_GLOBAL"), NULL, 10); if ((maxusers) && (maxusers == bftpdutmp_usercount("*"))) { control_printf(SL_FAILURE, "421 There are already %i users logged in.", maxusers); exit(0); } maxusers = strtoul(config_getoption("USERLIMIT_SINGLEUSER"), NULL, 10); if ((maxusers) && (maxusers == bftpdutmp_usercount(user))) { control_printf(SL_FAILURE, "421 User %s is already logged in %i times.", user, maxusers); exit(0); } #endif //brcm if(checkuser() || checkshell()) { control_printf(SL_FAILURE, "421 Login incorrect."); exit(0); } if (checkpass(password)) return 1; #if 0 //brcm if (strcasecmp((char *) config_getoption("RATIO"), "none")) { sscanf((char *) config_getoption("RATIO"), "%i/%i", &ratio_send, &ratio_recv); } strcpy(str, config_getoption("ROOTDIR")); if (!str[0]) strcpy(str, "%h"); replace(str, "%u", userinfo.pw_name); replace(str, "%h", userinfo.pw_dir); if (!strcasecmp(config_getoption("RESOLVE_UIDS"), "yes")) { passwdfile = fopen("/etc/passwd", "r"); groupfile = fopen("/etc/group", "r"); } #endif //brcm setgid(userinfo.pw_gid); initgroups(userinfo.pw_name, userinfo.pw_gid); #if 0 //brcm if (strcasecmp(config_getoption("DO_CHROOT"), "no")) { if (chroot(str)) { control_printf(SL_FAILURE, "421 Unable to change root directory.\r\n%s.", strerror(errno)); exit(0); } if (bftpd_setuid(userinfo.pw_uid)) { control_printf(SL_FAILURE, "421 Unable to change uid."); exit(0); } if (chdir("/")) { control_printf(SL_FAILURE, "421 Unable to change working directory.\r\n%s.", strerror(errno)); exit(0); } } else { if (bftpd_setuid(userinfo.pw_uid)) { control_printf(SL_FAILURE, "421 Unable to change uid."); exit(0); } if (chdir(str)) { control_printf(SL_FAILURE, "230 Couldn't change cwd to '%s': %s.", str, strerror(errno)); chdir("/"); } } new_umask(); print_file(230, config_getoption("MOTD_USER")); #endif //brcm control_printf(SL_SUCCESS, "230 User logged in."); #ifdef HAVE_UTMP_H bftpd_logwtmp(1); #endif #if 0 //brcm bftpdutmp_log(1); bftpd_log("Successfully logged in as user '%s'.\n", user); if (config_getoption("AUTO_CHDIR")[0]) chdir(config_getoption("AUTO_CHDIR")); #endif //brcm state = STATE_AUTHENTICATED; //brcm bftpd_cwd_init(); return 0; }