X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fauth.c;h=3c2db203059ae704dacfb08ddee6577df9a69cde;hb=b1338b390059f9f7019edc1080833f5002e948d8;hp=dcb36a2ce4701f260273cafeab5a859fd9ab664a;hpb=ef392707747a6a31bc70837303db8f7d0d63ffc1;p=netatalk.git diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index dcb36a2c..3c2db203 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -39,6 +39,7 @@ extern void afp_get_cmdline( int *ac, char ***av ); #include #include #include +#include #include #include @@ -170,6 +171,7 @@ static int set_auth_switch(const AFPObj *obj, int expired) afp_switch = postauth_switch; switch (obj->afp_version) { + case 34: case 33: case 32: #ifdef HAVE_ACLS @@ -185,7 +187,9 @@ static int set_auth_switch(const AFPObj *obj, int expired) case 31: uam_afpserver_action(AFP_SYNCDIR, UAM_AFPSERVER_POSTAUTH, afp_syncdir, NULL); uam_afpserver_action(AFP_SYNCFORK, UAM_AFPSERVER_POSTAUTH, afp_syncfork, NULL); +#ifdef HAVE_TRACKER uam_afpserver_action(AFP_SPOTLIGHT_PRIVATE, UAM_AFPSERVER_POSTAUTH, afp_spotlight_rpc, NULL); +#endif uam_afpserver_action(AFP_ENUMERATE_EXT2, UAM_AFPSERVER_POSTAUTH, afp_enumerate_ext2, NULL); case 30: @@ -223,8 +227,13 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi return AFPERR_NOTAUTH; } - LOG(log_note, logtype_afpd, "%s Login by %s", - afp_versions[afp_version_index].av_name, pwd->pw_name); + if (obj->cnx_cnt > obj->cnx_max) { + LOG(log_error, logtype_dsi, "login: too many connections, limit: %d", obj->cnx_max); + return AFPERR_MAXSESS; + } + + LOG(log_note, logtype_afpd, "Login by %s (%s)", + pwd->pw_name, afp_versions[afp_version_index].av_name); if (set_groups(obj, pwd) != 0) return AFPERR_BADUAM; @@ -307,6 +316,9 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi /* Some PAM module might have reset our signal handlers and timer, so we need to reestablish them */ afp_over_dsi_sighandlers(obj); + /* Send FCE login event */ + fce_register(obj, FCE_LOGIN, "", NULL); + return( AFP_OK ); } @@ -825,6 +837,10 @@ int afp_logout(AFPObj *obj, char *ibuf _U_, size_t ibuflen _U_, char *rbuf _U_ close_all_vol(obj); dsi->flags = DSI_AFP_LOGGED_OUT; *rbuflen = 0; + + /* Send FCE login event */ + fce_register(obj, FCE_LOGOUT, "", NULL); + return AFP_OK; } @@ -961,7 +977,7 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, atalk_uuid_t uuid; ret = getuuidfromname( obj->username, UUID_USER, uuid); if (ret != 0) { - LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID !"); + LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID!"); return AFPERR_NOITEM; } LOG(log_debug, logtype_afpd, "afp_getuserinfo: got UUID: %s", uuid_bin2string(uuid)); @@ -1013,9 +1029,9 @@ int auth_register(const int type, struct uam_obj *uam) } /* load all of the modules */ -int auth_load(const char *path, const char *list) +int auth_load(AFPObj *obj, const char *path, const char *list) { - char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p; + char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p, *last; struct uam_mod *mod; struct stat st; size_t len; @@ -1023,8 +1039,10 @@ int auth_load(const char *path, const char *list) if (!path || !*path || !list || (len = strlen(path)) > sizeof(name) - 2) return -1; + LOG(log_debug, logtype_afpd, "auth_load: %s, %s", path, list); + strlcpy(buf, list, sizeof(buf)); - if ((p = strtok(buf, ", ")) == NULL) + if ((p = strtok_r(buf, ", ", &last)) == NULL) return -1; strcpy(name, path); @@ -1040,7 +1058,7 @@ int auth_load(const char *path, const char *list) if ((stat(name, &st) == 0) && (mod = uam_load(name, p))) { */ if (stat(name, &st) == 0) { - if ((mod = uam_load(name, p))) { + if ((mod = uam_load(obj, name, p))) { uam_attach(&uam_modules, mod); LOG(log_debug, logtype_afpd, "uam: %s loaded", p); } else { @@ -1049,7 +1067,7 @@ int auth_load(const char *path, const char *list) } else { LOG(log_info, logtype_afpd, "uam: uam not found (status=%d)", stat(name, &st)); } - p = strtok(NULL, ", "); + p = strtok_r(NULL, ", ", &last); } return 0;