+
+int uam_sia_validate_user(sia_collect_func_t * collect, int argc, char **argv,
+ char *hostname, char *username, char *tty,
+ int colinput, char *gssapi, char *passphrase)
+/* A clone of the Tru64 system function sia_validate_user() that calls
+ * sia_ses_authent() rather than sia_ses_reauthent()
+ * Added extra code to take into account suspected SIA bug whereby it clobbers
+ * the signal handler on SIGALRM (tickle) installed by Netatalk/afpd
+ */
+{
+ SIAENTITY *entity = NULL;
+ struct sigaction act;
+ int rc;
+
+ if ((rc=sia_ses_init(&entity, argc, argv, hostname, username, tty,
+ colinput, gssapi)) != SIASUCCESS) {
+ LOG(log_error, logtype_afpd, "cannot initialise SIA");
+ return SIAFAIL;
+ }
+
+ /* save old action for restoration later */
+ if (sigaction(SIGALRM, NULL, &act))
+ LOG(log_error, logtype_afpd, "cannot save SIGALRM handler");
+
+ if ((rc=sia_ses_authent(collect, passphrase, entity)) != SIASUCCESS) {
+ /* restore old action after clobbering by sia_ses_authent() */
+ if (sigaction(SIGALRM, &act, NULL))
+ LOG(log_error, logtype_afpd, "cannot restore SIGALRM handler");
+
+ LOG(log_info, logtype_afpd, "unsuccessful login for %s",
+(hostname?hostname:"(null)"));
+ return SIAFAIL;
+ }
+ LOG(log_info, logtype_afpd, "successful login for %s",
+(hostname?hostname:"(null)"));
+
+ /* restore old action after clobbering by sia_ses_authent() */
+ if (sigaction(SIGALRM, &act, NULL))
+ LOG(log_error, logtype_afpd, "cannot restore SIGALRM handler");
+
+ sia_ses_release(&entity);
+
+ return SIASUCCESS;
+}