2 * $Id: uams_guest.c,v 1.6 2001-06-27 18:22:20 uhees Exp $
4 * (c) 2001 (see COPYING)
9 #endif /* HAVE_CONFIG_H */
17 #include <atalk/afp.h>
18 #include <atalk/uam.h>
20 static int noauth_login(void *obj, struct passwd **uam_pwd,
21 char *ibuf, int ibuflen,
22 char *rbuf, int *rbuflen)
25 char *guest, *username;
28 syslog( LOG_INFO, "login noauth" );
30 if (uam_afpserver_option(obj, UAM_OPTION_GUEST, (void *) &guest,
34 if (uam_afpserver_option(obj, UAM_OPTION_USERNAME,
35 (void *) &username, NULL) < 0)
38 strcpy(username, guest);
39 if ((pwent = getpwnam(guest)) == NULL) {
40 syslog( LOG_ERR, "noauth_login: getpwnam( %s ): %m", guest);
41 return( AFPERR_BADUAM );
46 syslog( LOG_ERR, "noauth_login: setpag: %m" );
47 return( AFPERR_BADUAM );
56 /* Printer NoAuthUAM Login */
57 int noauth_printer(start, stop, username, out)
58 char *start, *stop, *username;
62 static const char *loginok = "0\r";
64 data = (char *)malloc(stop - start + 1);
65 strncpy(data, start, stop - start + 1);
67 /* We are looking for the following format in data:
70 * Hopefully username doesn't contain a ")"
73 if ((p = strchr(data, '(' )) == NULL) {
74 syslog(LOG_INFO,"Bad Login NoAuthUAM: username not found in string");
79 if ((q = strchr(data, ')' )) == NULL) {
80 syslog(LOG_INFO,"Bad Login NoAuthUAM: username not found in string");
84 strncpy(username, p, q - p);
86 /* Done copying username, clean up */
89 if (getpwnam(username) == NULL) {
90 syslog(LOG_INFO, "Bad Login NoAuthUAM: %s: %m", username);
94 /* Login successful */
95 append(out, loginok, strlen(loginok));
96 syslog(LOG_INFO, "Login NoAuthUAM: %s", username);
101 static int uam_setup(const char *path)
103 if (uam_register(UAM_SERVER_LOGIN, path, "No User Authent",
104 noauth_login, NULL, NULL) < 0)
106 if (uam_register(UAM_SERVER_PRINTAUTH, path, "NoAuthUAM",
113 static void uam_cleanup()
115 uam_unregister(UAM_SERVER_LOGIN, "No User Authent");
116 uam_unregister(UAM_SERVER_PRINTAUTH, "NoAuthUAM");
119 UAM_MODULE_EXPORT struct uam_export uams_guest = {
122 uam_setup, uam_cleanup