10 static int noauth_login(void *obj, struct passwd **uam_pwd,
11 char *ibuf, int ibuflen,
12 char *rbuf, int *rbuflen)
15 char *guest, *username;
18 syslog( LOG_INFO, "login noauth" );
20 if (uam_afpserver_option(obj, UAM_OPTION_GUEST, (void *) &guest,
24 if (uam_afpserver_option(obj, UAM_OPTION_USERNAME,
25 (void *) &username, NULL) < 0)
28 strcpy(username, guest);
29 if ((pwent = getpwnam(guest)) == NULL) {
30 syslog( LOG_ERR, "noauth_login: getpwnam( %s ): %m", guest);
31 return( AFPERR_BADUAM );
36 syslog( LOG_ERR, "noauth_login: setpag: %m" );
37 return( AFPERR_BADUAM );
46 /* Printer NoAuthUAM Login */
47 int noauth_printer(start, stop, username, out)
48 char *start, *stop, *username;
52 static const char *loginok = "0\r";
54 data = (char *)malloc(stop - start + 1);
55 strncpy(data, start, stop - start + 1);
57 /* We are looking for the following format in data:
60 * Hopefully username doesn't contain a ")"
63 if ((p = strchr(data, '(' )) == NULL) {
64 syslog(LOG_INFO,"Bad Login NoAuthUAM: username not found in string");
69 if ((q = strchr(data, ')' )) == NULL) {
70 syslog(LOG_INFO,"Bad Login NoAuthUAM: username not found in string");
74 strncpy(username, p, q - p);
76 /* Done copying username, clean up */
79 if (getpwnam(username) == NULL) {
80 syslog(LOG_INFO, "Bad Login NoAuthUAM: %s: %m", username);
84 /* Login successful */
85 append(out, loginok, strlen(loginok));
86 syslog(LOG_INFO, "Login NoAuthUAM: %s", username);
91 static int uam_setup(const char *path)
93 if (uam_register(UAM_SERVER_LOGIN, path, "No User Authent",
94 noauth_login, NULL, NULL) < 0)
96 if (uam_register(UAM_SERVER_PRINTAUTH, path, "NoAuthUAM",
103 static void uam_cleanup()
105 uam_unregister(UAM_SERVER_LOGIN, "No User Authent");
106 uam_unregister(UAM_SERVER_PRINTAUTH, "NoAuthUAM");
109 UAM_MODULE_EXPORT struct uam_export uams_guest = {
112 uam_setup, uam_cleanup