X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libatalk%2Fvfs%2Fea_sys.c;h=374248bc8a9e4696eedf28519aeeec5a80fa7761;hb=bcb41b85b62fcc24337c9a7748dd64c10044fe46;hp=77ab783b04c8d3546f20ecb66e5d6335e387ae82;hpb=1a6013c7ecd313e03eee1192d54bee624d4a9293;p=netatalk.git diff --git a/libatalk/vfs/ea_sys.c b/libatalk/vfs/ea_sys.c index 77ab783b..374248bc 100644 --- a/libatalk/vfs/ea_sys.c +++ b/libatalk/vfs/ea_sys.c @@ -1,5 +1,4 @@ /* - $Id: ea_sys.c,v 1.8 2010-04-13 08:05:06 franklahm Exp $ Copyright (c) 2009 Frank Lahm This program is free software; you can redistribute it and/or modify @@ -26,20 +25,7 @@ #include #include #include - -#if HAVE_ATTR_XATTR_H -#include -#elif HAVE_SYS_XATTR_H -#include -#endif - -#ifdef HAVE_SYS_EA_H -#include -#endif - -#ifdef HAVE_SYS_EXTATTR_H -#include -#endif +#include #include #include @@ -51,11 +37,6 @@ #include #include -#ifndef ENOATTR -#define ENOATTR ENODATA -#endif - - /********************************************************************************** * EA VFS funcs for storing EAs in nativa filesystem EAs **********************************************************************************/ @@ -100,14 +81,15 @@ int sys_get_easize(VFS_FUNC_ARGS_EA_GETSIZE) switch(errno) { case OPEN_NOFOLLOW_ERRNO: /* its a symlink and client requested O_NOFOLLOW */ - LOG(log_debug, logtype_afpd, "sys_getextattr_size(%s): encountered symlink with kXAttrNoFollow", uname); - return AFP_OK; + LOG(log_debug, logtype_afpd, "sys_getextattr_size(%s): symlink with kXAttrNoFollow", uname); + return AFPERR_MISC; case ENOATTR: + case ENOENT: return AFPERR_MISC; default: - LOG(log_error, logtype_afpd, "sys_getextattr_size: error: %s", strerror(errno)); + LOG(log_debug, logtype_afpd, "sys_getextattr_size: error: %s", strerror(errno)); return AFPERR_MISC; } } @@ -175,14 +157,14 @@ int sys_get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT) switch(errno) { case OPEN_NOFOLLOW_ERRNO: /* its a symlink and client requested O_NOFOLLOW */ - LOG(log_debug, logtype_afpd, "sys_getextattr_content(%s): encountered symlink with kXAttrNoFollow", uname); - return AFP_OK; + LOG(log_debug, logtype_afpd, "sys_getextattr_content(%s): symlink with kXAttrNoFollow", uname); + return AFPERR_MISC; case ENOATTR: return AFPERR_MISC; default: - LOG(log_error, logtype_afpd, "sys_getextattr_content(%s): error: %s", attruname, strerror(errno)); + LOG(log_debug, logtype_afpd, "sys_getextattr_content(%s): error: %s", attruname, strerror(errno)); return AFPERR_MISC; } } @@ -215,6 +197,8 @@ int sys_get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT) * * Copies names of all EAs of uname as consecutive C strings into rbuf. * Increments *rbuflen accordingly. + * We hide the adouble:ea extended attributes here, but we currently + * allow reading, writing and deleteting them. */ int sys_list_eas(VFS_FUNC_ARGS_EA_LIST) { @@ -236,43 +220,40 @@ int sys_list_eas(VFS_FUNC_ARGS_EA_LIST) if (ret == -1) switch(errno) { case OPEN_NOFOLLOW_ERRNO: - /* its a symlink and client requested O_NOFOLLOW */ - ret = AFPERR_BADTYPE; - goto exit; -#ifdef HAVE_ATTROPEN /* Solaris */ - case ENOATTR: + /* its a symlink and client requested O_NOFOLLOW, we pretend 0 EAs */ + LOG(log_debug, logtype_afpd, "sys_list_extattr(%s): symlink with kXAttrNoFollow", uname); ret = AFP_OK; goto exit; -#endif default: - LOG(log_error, logtype_afpd, "sys_list_extattr(%s): error opening atttribute dir: %s", uname, strerror(errno)); - ret= AFPERR_MISC; + LOG(log_debug, logtype_afpd, "sys_list_extattr(%s): error opening atttribute dir: %s", uname, strerror(errno)); + ret = AFPERR_MISC; goto exit; } ptr = buf; while (ret > 0) { len = strlen(ptr); + if (NOT_NETATALK_EA(ptr)) { + /* Convert name to CH_UTF8_MAC and directly store in in the reply buffer */ + if ( 0 >= ( nlen = convert_string(vol->v_volcharset, CH_UTF8_MAC, ptr, len, attrnamebuf + attrbuflen, 256)) ) { + ret = AFPERR_MISC; + goto exit; + } - /* Convert name to CH_UTF8_MAC and directly store in in the reply buffer */ - if ( 0 >= ( nlen = convert_string(vol->v_volcharset, CH_UTF8_MAC, ptr, len, attrnamebuf + attrbuflen, 256)) ) { - ret = AFPERR_MISC; - goto exit; - } - - LOG(log_debug7, logtype_afpd, "sys_list_extattr(%s): attribute: %s", uname, ptr); + LOG(log_debug7, logtype_afpd, "sys_list_extattr(%s): attribute: %s", uname, ptr); - attrbuflen += nlen + 1; - if (attrbuflen > (ATTRNAMEBUFSIZ - 256)) { - /* Next EA name could overflow, so bail out with error. - FIXME: evantually malloc/memcpy/realloc whatever. - Is it worth it ? */ - LOG(log_warning, logtype_afpd, "sys_list_extattr(%s): running out of buffer for EA names", uname); - ret = AFPERR_MISC; - goto exit; + attrbuflen += nlen + 1; + if (attrbuflen > (ATTRNAMEBUFSIZ - 256)) { + /* Next EA name could overflow, so bail out with error. + FIXME: evantually malloc/memcpy/realloc whatever. + Is it worth it ? */ + LOG(log_warning, logtype_afpd, "sys_list_extattr(%s): running out of buffer for EA names", uname); + ret = AFPERR_MISC; + goto exit; + } } - ret -= len +1; - ptr += len +1; + ret -= len + 1; + ptr += len + 1; } ret = AFP_OK; @@ -325,8 +306,8 @@ int sys_set_ea(VFS_FUNC_ARGS_EA_SET) switch(errno) { case OPEN_NOFOLLOW_ERRNO: /* its a symlink and client requested O_NOFOLLOW */ - LOG(log_debug, logtype_afpd, "sys_set_ea(\"%s/%s\", ea:'%s'): encountered symlink with kXAttrNoFollow", - getcwdpath(), uname, attruname); + LOG(log_debug, logtype_afpd, "sys_set_ea(\"%s\", ea:'%s'): symlink with kXAttrNoFollow", + uname, attruname); return AFP_OK; case EEXIST: LOG(log_debug, logtype_afpd, "sys_set_ea(\"%s/%s\", ea:'%s'): EA already exists", @@ -379,13 +360,10 @@ int sys_remove_ea(VFS_FUNC_ARGS_EA_REMOVE) switch(errno) { case OPEN_NOFOLLOW_ERRNO: /* its a symlink and client requested O_NOFOLLOW */ - LOG(log_debug, logtype_afpd, "sys_remove_ea(%s/%s): encountered symlink with kXAttrNoFollow", uname); + LOG(log_debug, logtype_afpd, "sys_remove_ea(%s/%s): symlink with kXAttrNoFollow", uname); return AFP_OK; - case EACCES: - LOG(log_debug, logtype_afpd, "sys_remove_ea(%s/%s): error: %s", uname, attruname, strerror(errno)); - return AFPERR_ACCESS; default: - LOG(log_error, logtype_afpd, "sys_remove_ea(%s/%s): error: %s", uname, attruname, strerror(errno)); + LOG(log_debug, logtype_afpd, "sys_remove_ea(%s/%s): error: %s", uname, attruname, strerror(errno)); return AFPERR_MISC; } } @@ -461,6 +439,9 @@ int sys_ea_copyfile(VFS_FUNC_ARGS_COPYFILE) if (!*name) continue; + if (STRCMP(name, ==, AD_EA_META)) + continue; + if (sfd != -1) { if (fchdir(sfd) == -1) { LOG(log_error, logtype_afpd, "sys_ea_copyfile: cant chdir to sfd: %s",