+ if (trythisname == NULL) return login_not_found;
+
+ /* If a "master user" is defined, handle its authentication if specified */
+ CC->is_master = 0;
+ if (strlen(config.c_master_user) > 0) if (strlen(config.c_master_pass) > 0) if (authname) {
+ if (!strcasecmp(authname, config.c_master_user)) {
+ CC->is_master = 1;
+ }
+ }
+
+ /* Continue attempting user validation... */
+ safestrncpy(username, trythisname, USERNAME_SIZE);
+ striplt(username);
+
+ if (IsEmptyStr(username)) {
+ return login_not_found;
+ }
+
+ if (config.c_auth_mode == 1) {
+
+ /* host auth mode */
+
+ struct passwd pd;
+ struct passwd *tempPwdPtr;
+ char pwdbuffer[256];
+
+ lprintf(CTDL_DEBUG, "asking host about <%s>\n", username);
+#ifdef SOLARIS_GETPWUID
+ tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer);
+#else
+ getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
+#endif
+ if (tempPwdPtr == NULL) {
+ return login_not_found;
+ }
+ lprintf(CTDL_DEBUG, "found it! uid=%ld, gecos=%s\n", (long)pd.pw_uid, pd.pw_gecos);
+
+ /* Locate the associated Citadel account.
+ * If not found, make one attempt to create it.
+ */
+ found_user = getuserbyuid(&CC->user, pd.pw_uid);
+ if (found_user != 0) {
+ create_user(username, 0);
+ found_user = getuserbyuid(&CC->user, pd.pw_uid);
+ }
+
+ }
+
+ else {
+ /* native auth mode */