}
#endif
+
+/* Printer ClearTxtUAM login */
+static int passwd_printer(start, stop, username, out)
+ char *start, *stop, *username;
+ struct papfile *out;
+{
+ struct passwd *pwd;
+#ifdef SHADOWPW
+ struct spwd *sp;
+#endif
+ char *data, *p, *q;
+ char password[PASSWDLEN + 1] = "\0";
+ static const char *loginok = "0\r";
+ int ulen;
+
+ data = (char *)malloc(stop - start + 1);
+ strncpy(data, start, stop - start + 1);
+
+ /* We are looking for the following format in data:
+ * (username) (password)
+ *
+ * Let's hope username doesn't contain ") ("!
+ */
+
+ /* Parse input for username in () */
+ if ((p = strchr(data, '(' )) == NULL) {
+ syslog(LOG_INFO,"Bad Login ClearTxtUAM: username not found in string");
+ free(data);
+ return(-1);
+ }
+ p++;
+ if ((q = strstr(data, ") (" )) == NULL) {
+ syslog(LOG_INFO,"Bad Login ClearTxtUAM: username not found in string");
+ free(data);
+ return(-1);
+ }
+ strncpy(username, p, q - p);
+
+ /* Parse input for password in next () */
+ p = q + 3;
+ if ((q = strrchr(data, ')' )) == NULL) {
+ syslog(LOG_INFO,"Bad Login ClearTxtUAM: password not found in string");
+ free(data);
+ return(-1);
+ }
+ strncpy(password, p, q - p);
+
+ /* Done copying username and password, clean up */
+ free(data);
+
+ ulen = strlen(username);
+
+ if (( pwd = uam_getname(username, ulen)) == NULL ) {
+ syslog(LOG_INFO, "Bad Login ClearTxtUAM: ( %s ) not found ",
+ username);
+ return(-1);
+ }
+
+ if (uam_checkuser(pwd) < 0) {
+ /* syslog of error happens in uam_checkuser */
+ return(-1);
+ }
+
+#ifdef SHADOWPW
+ if (( sp = getspnam( pwd->pw_name )) == NULL ) {
+ syslog(LOG_INFO, "Bad Login ClearTxtUAM: no shadow passwd entry for %s",
+ username);
+ return(-1);
+ }
+ pwd->pw_passwd = sp->sp_pwdp;
+#endif SHADOWPW
+
+ if (!pwd->pw_passwd) {
+ syslog(LOG_INFO, "Bad Login ClearTxtUAM: no password for %s",
+ username);
+ return(-1);
+ }
+
+#ifdef AFS
+ if ( kcheckuser( pwd, password) == 0)
+ return(0);
+#endif AFS
+
+ p = crypt(password, pwd->pw_passwd);
+ if (strcmp(p, pwd->pw_passwd) != 0) {
+ syslog(LOG_INFO, "Bad Login ClearTxtUAM: %s: bad password", username);
+ return(-1);
+ }
+
+ /* Login successful */
+ append(out, loginok, strlen(loginok));
+ syslog(LOG_INFO, "Login ClearTxtUAM: %s", username);
+ return(0);
+}
+
+
static int uam_setup(const char *path)
{
- if (uam_register(UAM_SERVER_LOGIN, path,
- "Cleartxt Passwrd", passwd_login, NULL, NULL) < 0)
- return -1;
- /*uam_register(UAM_SERVER_PRINTAUTH, path, "Cleartxt Passwrd",
- passwd_printer);*/
+ if (uam_register(UAM_SERVER_LOGIN, path, "Cleartxt Passwrd",
+ passwd_login, NULL, NULL) < 0)
+ return -1;
+ if (uam_register(UAM_SERVER_PRINTAUTH, path, "ClearTxtUAM",
+ passwd_printer) < 0)
+ return -1;
+
return 0;
}
static void uam_cleanup(void)
{
uam_unregister(UAM_SERVER_LOGIN, "Cleartxt Passwrd");
- /*uam_unregister(UAM_SERVER_PRINTAUTH, "Cleartxt Passwrd"); */
+ uam_unregister(UAM_SERVER_PRINTAUTH, "ClearTxtUAM");
}
UAM_MODULE_EXPORT struct uam_export uams_clrtxt = {