--- proftpd/contrib/mod_copy.c 2010/03/10 19:24:04 1.2
+++ proftpd/contrib/mod_copy.c 2011/04/09 20:26:30 1.3
@@ -2,7 +2,7 @@
* ProFTPD: mod_copy -- a module supporting copying of files on the server
* without transferring the data to the client and back
*
- * Copyright (c) 2009-2010 TJ Saunders
+ * Copyright (c) 2009-2011 TJ Saunders
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,12 +26,12 @@
* This is mod_copy, contrib software for proftpd 1.3.x and above.
* For more information contact TJ Saunders <tj@castaglia.org>.
*
- * $Id: mod_copy.c,v 1.2 2010/03/10 19:24:04 castaglia Exp $
+ * $Id: mod_copy.c,v 1.3 2011/04/09 20:26:30 castaglia Exp $
*/
#include "conf.h"
-#define MOD_COPY_VERSION "mod_copy/0.2"
+#define MOD_COPY_VERSION "mod_copy/0.3"
/* Make sure the version of proftpd is as necessary. */
#if PROFTPD_VERSION_NUMBER < 0x0001030401
@@ -319,7 +319,7 @@
return PR_DECLINED(cmd);
}
- if (strcasecmp(cmd->argv[1], "COPY") == 0) {
+ if (strncasecmp(cmd->argv[1], "COPY", 5) == 0) {
char *cmd_name, *from, *to;
unsigned char *authenticated;
@@ -363,7 +363,7 @@
return PR_HANDLED(cmd);
}
- if (strcasecmp(cmd->argv[1], "HELP") == 0) {
+ if (strncasecmp(cmd->argv[1], "HELP", 5) == 0) {
pr_response_add(R_214, _("CPFR <sp> pathname"));
pr_response_add(R_214, _("CPTO <sp> pathname"));
}
@@ -376,7 +376,7 @@
int res;
char *path = "";
- if (strcasecmp(cmd->argv[1], "CPFR") != 0) {
+ if (strncasecmp(cmd->argv[1], "CPFR", 5) != 0) {
return PR_DECLINED(cmd);
}
@@ -430,7 +430,7 @@
register unsigned int i;
char *from, *to = "";
- if (strcasecmp(cmd->argv[1], "CPTO") != 0) {
+ if (strncasecmp(cmd->argv[1], "CPTO", 5) != 0) {
return PR_DECLINED(cmd);
}
@@ -459,12 +459,21 @@
return PR_ERROR(cmd);
}
- pr_table_remove(session.notes, "mod_copy.cpfr-path", NULL);
-
pr_response_add(R_250, _("Copy successful"));
return PR_HANDLED(cmd);
}
+MODRET copy_log_site(cmd_rec *cmd) {
+ if (strncasecmp(cmd->argv[1], "CPTO", 5) != 0) {
+ return PR_DECLINED(cmd);
+ }
+
+ /* Delete the stashed CPFR path from the session.notes table. */
+ (void) pr_table_remove(session.notes, "mod_copy.cpfr-path", NULL);
+
+ return PR_HANDLED(cmd);
+}
+
/* Initialization functions
*/
@@ -479,9 +488,12 @@
*/
static cmdtable copy_cmdtab[] = {
- { CMD, C_SITE, G_WRITE, copy_copy, FALSE, FALSE, CL_MISC },
- { CMD, C_SITE, G_DIRS, copy_cpfr, FALSE, FALSE, CL_MISC },
- { CMD, C_SITE, G_WRITE, copy_cpto, FALSE, FALSE, CL_MISC },
+ { CMD, C_SITE, G_WRITE, copy_copy, FALSE, FALSE, CL_MISC },
+ { CMD, C_SITE, G_DIRS, copy_cpfr, FALSE, FALSE, CL_MISC },
+ { CMD, C_SITE, G_WRITE, copy_cpto, FALSE, FALSE, CL_MISC },
+ { LOG_CMD, C_SITE, G_NONE, copy_log_site, FALSE, FALSE },
+ { LOG_CMD_ERR, C_SITE, G_NONE, copy_log_site, FALSE, FALSE },
+
{ 0, NULL }
};
--- proftpd/contrib/mod_quotatab.c 2011/03/21 01:01:34 1.72
+++ proftpd/contrib/mod_quotatab.c 2011/04/09 20:26:30 1.73
@@ -28,7 +28,7 @@
* ftp://pooh.urbanrage.com/pub/c/. This module, however, has been written
* from scratch to implement quotas in a different way.
*
- * $Id: mod_quotatab.c,v 1.72 2011/03/21 01:01:34 castaglia Exp $
+ * $Id: mod_quotatab.c,v 1.73 2011/04/09 20:26:30 castaglia Exp $
*/
#include "mod_quotatab.h"
@@ -3584,12 +3584,37 @@
if (cmd->argc < 2)
return PR_DECLINED(cmd);
- if (strcasecmp(cmd->argv[1], "COPY") == 0) {
+ if (strncasecmp(cmd->argv[1], "COPY", 5) == 0) {
cmd_rec *copy_cmd;
copy_cmd = pr_cmd_alloc(cmd->tmp_pool, 3, cmd->argv[1], cmd->argv[2],
cmd->argv[3]);
return quotatab_pre_copy(copy_cmd);
+
+ } else if (strncasecmp(cmd->argv[1], "CPTO", 5) == 0) {
+ register unsigned int i;
+ cmd_rec *copy_cmd;
+ char *from, *to = "";
+
+ if (cmd->argc < 3)
+ return PR_DECLINED(cmd);
+
+ from = pr_table_get(session.notes, "mod_copy.cpfr-path", NULL);
+ if (from == NULL) {
+ pr_response_add_err(R_503, _("Bad sequence of commands"));
+ return PR_ERROR(cmd);
+ }
+
+ /* Construct the target file name by concatenating all the parameters after
+ * the "SITE CPTO", separating them with spaces.
+ */
+ for (i = 2; i <= cmd->argc-1; i++) {
+ to = pstrcat(cmd->tmp_pool, to, *to ? " " : "",
+ pr_fs_decode_path(cmd->tmp_pool, cmd->argv[i]), NULL);
+ }
+
+ copy_cmd = pr_cmd_alloc(cmd->tmp_pool, 3, "COPY", from, to);
+ return quotatab_pre_copy(copy_cmd);
}
return PR_DECLINED(cmd);
@@ -3601,7 +3626,7 @@
if (cmd->argc < 2)
return PR_DECLINED(cmd);
- if (strcasecmp(cmd->argv[1], "QUOTA") == 0) {
+ if (strncasecmp(cmd->argv[1], "QUOTA", 6) == 0) {
char *cmd_name;
unsigned char *authenticated = get_param_ptr(cmd->server->conf,
"authenticated", FALSE);
@@ -3686,7 +3711,7 @@
return PR_HANDLED(cmd);
}
- if (strcasecmp(cmd->argv[1], "HELP") == 0) {
+ if (strncasecmp(cmd->argv[1], "HELP", 5) == 0) {
/* Add a description of SITE QUOTA to the output. */
pr_response_add(R_214, "QUOTA");
@@ -3701,12 +3726,37 @@
if (cmd->argc < 2)
return PR_DECLINED(cmd);
- if (strcasecmp(cmd->argv[1], "COPY") == 0) {
+ if (strncasecmp(cmd->argv[1], "COPY", 5) == 0) {
cmd_rec *copy_cmd;
copy_cmd = pr_cmd_alloc(cmd->tmp_pool, 3, cmd->argv[1], cmd->argv[2],
cmd->argv[3]);
return quotatab_post_copy(copy_cmd);
+
+ } else if (strncasecmp(cmd->argv[1], "CPTO", 5) == 0) {
+ register unsigned int i;
+ cmd_rec *copy_cmd;
+ char *from, *to = "";
+
+ if (cmd->argc < 3)
+ return PR_DECLINED(cmd);
+
+ from = pr_table_get(session.notes, "mod_copy.cpfr-path", NULL);
+ if (from == NULL) {
+ pr_response_add_err(R_503, _("Bad sequence of commands"));
+ return PR_ERROR(cmd);
+ }
+
+ /* Construct the target file name by concatenating all the parameters after
+ * the "SITE CPTO", separating them with spaces.
+ */
+ for (i = 2; i <= cmd->argc-1; i++) {
+ to = pstrcat(cmd->tmp_pool, to, *to ? " " : "",
+ pr_fs_decode_path(cmd->tmp_pool, cmd->argv[i]), NULL);
+ }
+
+ copy_cmd = pr_cmd_alloc(cmd->tmp_pool, 3, "COPY", from, to);
+ return quotatab_post_copy(copy_cmd);
}
return PR_DECLINED(cmd);
@@ -3718,12 +3768,34 @@
if (cmd->argc < 2)
return PR_DECLINED(cmd);
- if (strcasecmp(cmd->argv[1], "COPY") == 0) {
+ if (strncasecmp(cmd->argv[1], "COPY", 5) == 0) {
cmd_rec *copy_cmd;
copy_cmd = pr_cmd_alloc(cmd->tmp_pool, 3, cmd->argv[1], cmd->argv[2],
cmd->argv[3]);
return quotatab_post_copy_err(copy_cmd);
+
+ } else if (strncasecmp(cmd->argv[1], "CPTO", 5) == 0) {
+ register unsigned int i;
+ cmd_rec *copy_cmd;
+ char *from, *to = "";
+
+ from = pr_table_get(session.notes, "mod_copy.cpfr-path", NULL);
+ if (from == NULL) {
+ pr_response_add_err(R_503, _("Bad sequence of commands"));
+ return PR_ERROR(cmd);
+ }
+
+ /* Construct the target file name by concatenating all the parameters after
+ * the "SITE CPTO", separating them with spaces.
+ */
+ for (i = 2; i <= cmd->argc-1; i++) {
+ to = pstrcat(cmd->tmp_pool, to, *to ? " " : "",
+ pr_fs_decode_path(cmd->tmp_pool, cmd->argv[i]), NULL);
+ }
+
+ copy_cmd = pr_cmd_alloc(cmd->tmp_pool, 3, "COPY", from, to);
+ return quotatab_post_copy_err(copy_cmd);
}
return PR_DECLINED(cmd);