From: Frank Lahm Date: Wed, 15 Feb 2012 11:43:36 +0000 (+0100) Subject: Default adouble:ea, check for EA, fallback to v2. loglevel support multiple statement... X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=3399095adaa5fad2ec2c7fbbed1de9222106da59 Default adouble:ea, check for EA, fallback to v2. loglevel support multiple statement seperated by comma. Fixes. --- diff --git a/etc/afpd/file.c b/etc/afpd/file.c index c8101048..ce2ab545 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -79,6 +79,7 @@ void *get_finderinfo(const struct vol *vol, const char *upath, struct adouble *a void *ad_finder = NULL; int chk_ext = 0; + if (adp) ad_finder = ad_entry(adp, ADEID_FINDERI); if (ad_finder) { diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index 54f52c8e..0a86cfd2 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef CNID_DB #include @@ -117,7 +118,7 @@ static const _special_folder special_folders[] = { static void handle_special_folders (const struct vol *); static void deletevol(struct vol *vol); static void volume_free(struct vol *vol); -static void check_ea_sys_support(struct vol *vol); +static void check_ea_support(struct vol *vol); static char *get_vol_uuid(const AFPObj *obj, const char *volname); static void volfree(struct vol_option *options, const struct vol_option *save) @@ -305,7 +306,7 @@ static void setoption(struct vol_option *options, const struct vol_option *save, { if (options[opt].c_value && (!save || options[opt].c_value != save[opt].c_value)) free(options[opt].c_value); - options[opt].c_value = strdup(val + 1); + options[opt].c_value = strdup(val); } /* Parse iniconfig and initalize volume options */ @@ -729,8 +730,8 @@ static int creatvol(AFPObj *obj, struct passwd *pwd, volume->v_fperm |= volume->v_perm; /* Check EA support on volume */ - if (volume->v_vfs_ea == AFPVOL_EA_AUTO) - check_ea_sys_support(volume); + if (volume->v_vfs_ea == AFPVOL_EA_AUTO || volume->v_adouble == AD_VERSION_EA) + check_ea_support(volume); initvol_vfs(volume); /* get/store uuid from file in afpd master*/ @@ -938,8 +939,6 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, struct passwd *p LOG(log_debug, logtype_afpd, "readvolfile: BEGIN"); - p1->mtime = 0; - memset(default_options, 0, sizeof(default_options)); /* Enable some default options for all volumes */ @@ -1588,7 +1587,7 @@ void load_volumes(AFPObj *obj) /* try putting a read lock on the volume file twice, sleep 1 second if first attempt fails */ - fd = open(obj->options.configfile, O_RDWR); + fd = open(obj->options.configfile, O_RDONLY); while (retries < 2) { if ((read_lock(fd, 0, SEEK_SET, 0)) != 0) { @@ -1785,49 +1784,67 @@ static int volume_openDB(const AFPObj *obj, struct vol *volume) } /* - Check if the underlying filesystem supports EAs for ea:sys volumes. + Check if the underlying filesystem supports EAs. If not, switch to ea:ad. As we can't check (requires write access) on ro-volumes, we switch ea:auto volumes that are options:ro to ea:none. */ -static void check_ea_sys_support(struct vol *vol) +static int do_check_ea_support(const struct vol *vol) { - uid_t process_uid = 0; + int haseas; char eaname[] = {"org.netatalk.supports-eas.XXXXXX"}; const char *eacontent = "yes"; - if (vol->v_vfs_ea == AFPVOL_EA_AUTO) { + if ((vol->v_flags & AFPVOL_RO) == AFPVOL_RO) { + LOG(log_note, logtype_afpd, "read-only volume '%s', can't test for EA support, assuming yes", vol->v_localname); + return 1; + } + + mktemp(eaname); + + become_root(); + + if ((sys_setxattr(vol->v_path, eaname, eacontent, 4, 0)) == 0) { + sys_removexattr(vol->v_path, eaname); + haseas = 1; + } else { + LOG(log_warning, logtype_afpd, "volume \"%s\" does not support Extended Attributes", + vol->v_localname); + haseas = 0; + } + + unbecome_root(); + + return haseas; +} +static void check_ea_support(struct vol *vol) +{ + int haseas; + char eaname[] = {"org.netatalk.supports-eas.XXXXXX"}; + const char *eacontent = "yes"; + + haseas = do_check_ea_support(vol); + + if (vol->v_vfs_ea == AFPVOL_EA_AUTO) { if ((vol->v_flags & AFPVOL_RO) == AFPVOL_RO) { LOG(log_info, logtype_afpd, "read-only volume '%s', can't test for EA support, disabling EAs", vol->v_localname); vol->v_vfs_ea = AFPVOL_EA_NONE; return; } - mktemp(eaname); - - process_uid = geteuid(); - if (process_uid) - if (seteuid(0) == -1) { - LOG(log_error, logtype_afpd, "check_ea_sys_support: can't seteuid(0): %s", strerror(errno)); - exit(EXITERR_SYS); - } - - if ((sys_setxattr(vol->v_path, eaname, eacontent, 4, 0)) == 0) { - sys_removexattr(vol->v_path, eaname); + if (haseas) { vol->v_vfs_ea = AFPVOL_EA_SYS; } else { LOG(log_warning, logtype_afpd, "volume \"%s\" does not support Extended Attributes, using ea:ad instead", vol->v_localname); vol->v_vfs_ea = AFPVOL_EA_AD; } + } - if (process_uid) { - if (seteuid(process_uid) == -1) { - LOG(log_error, logtype_afpd, "can't seteuid back %s", strerror(errno)); - exit(EXITERR_SYS); - } - } + if (vol->v_adouble == AD_VERSION_EA) { + if (!haseas) + vol->v_adouble = AD_VERSION2; } } diff --git a/include/atalk/adouble.h b/include/atalk/adouble.h index c130a5e9..9291e9c2 100644 --- a/include/atalk/adouble.h +++ b/include/atalk/adouble.h @@ -53,7 +53,7 @@ #define AD_VERSION_EA 0x00020002 /* default */ -#define AD_VERSION AD_VERSION2 +#define AD_VERSION AD_VERSION_EA /* * AppleDouble entry IDs. diff --git a/libatalk/util/logger.c b/libatalk/util/logger.c index b96b2181..6d3be477 100644 --- a/libatalk/util/logger.c +++ b/libatalk/util/logger.c @@ -627,24 +627,29 @@ void setuplog(const char *logstr, const char *logfile) save = ptr = strdup(logstr); - while (*ptr) { - while (*ptr && isspace(*ptr)) - ptr++; + ptr = strtok(ptr, ","); - logtype = ptr; - ptr = strpbrk(ptr, ":"); - if (!ptr) - break; - *ptr = 0; + while (ptr) { + while (*ptr) { + while (*ptr && isspace(*ptr)) + ptr++; + + logtype = ptr; + ptr = strpbrk(ptr, ":"); + if (!ptr) + break; + *ptr = 0; - ptr++; - loglevel = ptr; - while (*ptr && !isspace(*ptr)) ptr++; - c = *ptr; - *ptr = 0; - setuplog_internal(loglevel, logtype, logfile); - *ptr = c; + loglevel = ptr; + while (*ptr && !isspace(*ptr)) + ptr++; + c = *ptr; + *ptr = 0; + setuplog_internal(loglevel, logtype, logfile); + *ptr = c; + } + ptr = strtok(NULL, ","); } free(save);