From: franklahm Date: Thu, 4 Feb 2010 10:52:29 +0000 (+0000) Subject: volume option debugfile X-Git-Tag: HEAD-before-symlink-merge~6 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=f1139f03e41e2d86208100483a572e29af858954 volume option debugfile --- diff --git a/NEWS b/NEWS index 54410534..42dedb42 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,10 @@ Changes in 2.1-beta1 * NEW: support for Unicode characters in the range above U+010000 using internal surrogate pairs * NEW: apple_dump: utility to dump AppleSingle and AppleDouble files +* NEW: afpd: new volume option to enable live debugging of AFP connections: + debugfile:FILE. When FILE is created in volume root from the AFP + client, the afpd process raises its debug level to log_maxdebug + and writes to FILE. * UPD: atalkd and papd are now disabled by default. AppleTalk is legacy. * UPD: slp advertisement is now disabled by default. server option -slp SRVLOC is legacy. diff --git a/etc/afpd/file.c b/etc/afpd/file.c index 82c7739d..41195251 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1,5 +1,5 @@ /* - * $Id: file.c,v 1.131 2010-01-26 20:39:52 didg Exp $ + * $Id: file.c,v 1.132 2010-02-04 10:52:29 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -596,7 +596,7 @@ int afp_createfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, } upath = s_path->u_name; - + /* if upath is deleted we already in trouble anyway */ if ((of = of_findname(s_path))) { adp = of->of_ad; @@ -667,6 +667,18 @@ createfile_done: setvoltime(obj, vol ); + /* Check if this is the magic debugfile */ + if (retvalue == AFP_OK + && curdir->d_did == htonl(2) + && vol->v_debugfile + && strcmp(upath, vol->v_debugfile) == 0) { + char *path = absupath(vol, curdir, upath); + char *logstring = malloc(strlen("default log_maxdebug ") + strlen(path) + 1); + sprintf(logstring, "default log_maxdebug %s", path); + setuplog(logstring); + free(logstring); + } + return (retvalue); } diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index e43d3b4a..53c3a9cb 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1,5 +1,5 @@ /* - * $Id: volume.c,v 1.115 2010-01-26 09:31:59 didg Exp $ + * $Id: volume.c,v 1.116 2010-02-04 10:52:29 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -128,8 +128,8 @@ static void free_extmap(void); #define VOLOPT_FPERM 25 /* fperm default files perms */ #define VOLOPT_DFLTPERM 26 /* perm */ #define VOLOPT_EA_VFS 27 /* Extended Attributes vfs indirection */ - -#define VOLOPT_MAX 28 /* <== IMPORTANT !!!!!! */ +#define VOLOPT_DEBUG_FILE 28 /* Enable debugging for one AFP process */ +#define VOLOPT_MAX 29 /* <== IMPORTANT !!!!!! */ #define VOLOPT_NUM (VOLOPT_MAX + 1) #define VOLPASSLEN 8 @@ -522,6 +522,9 @@ static void volset(struct vol_option *options, struct vol_option *save, else if (strcasecmp(val + 1, "none") == 0) options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_NONE; + } else if (optionok(tmp, "debugfile:", val)) { + setoption(options, save, VOLOPT_DEBUG_FILE, val); + } else { /* ignore unknown options */ LOG(log_debug, logtype_afpd, "ignoring unknown volume option: %s", tmp); @@ -786,6 +789,10 @@ static int creatvol(AFPObj *obj, struct passwd *pwd, if (options[VOLOPT_ROOTPOSTEXEC].c_value) volume->v_root_postexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_ROOTPOSTEXEC].c_value, pwd, path, name); } + + if (options[VOLOPT_DEBUG_FILE].c_value) + volume->v_debugfile = strdup(options[VOLOPT_DEBUG_FILE].c_value); + } volume->v_dperm |= volume->v_perm; volume->v_fperm |= volume->v_perm; diff --git a/include/atalk/volume.h b/include/atalk/volume.h index 0a4f1c88..df24620f 100644 --- a/include/atalk/volume.h +++ b/include/atalk/volume.h @@ -1,5 +1,5 @@ /* - * $Id: volume.h,v 1.11 2010-01-05 12:06:34 franklahm Exp $ + * $Id: volume.h,v 1.12 2010-02-04 10:52:29 franklahm Exp $ * * Copyright (c) 1990,1994 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -82,7 +82,7 @@ struct vol { char *v_postexec; int v_root_preexec_close; int v_preexec_close; - + char *v_debugfile; /* magic file that enables debugging when created in did 2 */ #ifdef FORCE_UIDGID char *v_forceuid; char *v_forcegid;