]> arthur.barton.de Git - netatalk.git/commitdiff
volume option debugfile
authorfranklahm <franklahm>
Thu, 4 Feb 2010 10:52:29 +0000 (10:52 +0000)
committerfranklahm <franklahm>
Thu, 4 Feb 2010 10:52:29 +0000 (10:52 +0000)
NEWS
etc/afpd/file.c
etc/afpd/volume.c
include/atalk/volume.h

diff --git a/NEWS b/NEWS
index 5441053468672a8eaa50ab6b1f0dd2f4870b42ed..42dedb42b657d127db686a04a97417edf3784215 100644 (file)
--- 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.
index 82c7739dc155d51ffa42cf7a9c88f3f1854fb5e1..41195251c086e1da8fd3049f50b5d2b2440404c2 100644 (file)
@@ -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);
 }
 
index e43d3b4ab485905ed480be3f3ae9d6370829e049..53c3a9cbc438f3f68977dacad24774c9341355c3 100644 (file)
@@ -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;
index 0a4f1c88c06c3d51d5ced18e1367b403254980fd..df24620fba8dbc94d463e8076ccb209c200fbd07 100644 (file)
@@ -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;