11 #include <atalk/afp.h>
12 #include <atalk/uam.h>
14 static int noauth_login(void *obj, struct passwd **uam_pwd,
15 char *ibuf, int ibuflen,
16 char *rbuf, int *rbuflen)
19 char *guest, *username;
22 syslog( LOG_INFO, "login noauth" );
24 if (uam_afpserver_option(obj, UAM_OPTION_GUEST, (void *) &guest,
28 if (uam_afpserver_option(obj, UAM_OPTION_USERNAME,
29 (void *) &username, NULL) < 0)
32 strcpy(username, guest);
33 if ((pwent = getpwnam(guest)) == NULL) {
34 syslog( LOG_ERR, "noauth_login: getpwnam( %s ): %m", guest);
35 return( AFPERR_BADUAM );
40 syslog( LOG_ERR, "noauth_login: setpag: %m" );
41 return( AFPERR_BADUAM );
50 /* Printer NoAuthUAM Login */
51 int noauth_printer(start, stop, username, out)
52 char *start, *stop, *username;
56 static const char *loginok = "0\r";
58 data = (char *)malloc(stop - start + 1);
59 strncpy(data, start, stop - start + 1);
61 /* We are looking for the following format in data:
64 * Hopefully username doesn't contain a ")"
67 if ((p = strchr(data, '(' )) == NULL) {
68 syslog(LOG_INFO,"Bad Login NoAuthUAM: username not found in string");
73 if ((q = strchr(data, ')' )) == NULL) {
74 syslog(LOG_INFO,"Bad Login NoAuthUAM: username not found in string");
78 strncpy(username, p, q - p);
80 /* Done copying username, clean up */
83 if (getpwnam(username) == NULL) {
84 syslog(LOG_INFO, "Bad Login NoAuthUAM: %s: %m", username);
88 /* Login successful */
89 append(out, loginok, strlen(loginok));
90 syslog(LOG_INFO, "Login NoAuthUAM: %s", username);
95 static int uam_setup(const char *path)
97 if (uam_register(UAM_SERVER_LOGIN, path, "No User Authent",
98 noauth_login, NULL, NULL) < 0)
100 if (uam_register(UAM_SERVER_PRINTAUTH, path, "NoAuthUAM",
107 static void uam_cleanup()
109 uam_unregister(UAM_SERVER_LOGIN, "No User Authent");
110 uam_unregister(UAM_SERVER_PRINTAUTH, "NoAuthUAM");
113 UAM_MODULE_EXPORT struct uam_export uams_guest = {
116 uam_setup, uam_cleanup